I have been using Rspec stories with Webrat feeling very productive and happy.
Then I needed to do something with Selenium (Webrat could have done what I needed but it does not yet have the functionality). Selenium-core as part of a rails plugin looked nice but did not seem to fit with rspec stories. So I went the Selenium-rc route. Since Selenium uses a separate instance of rails (http://www.nabble.com/stories-with-selenium-and-the-db-td16190686.html) I had to turn off the ActiveRecordSafetyListener used in rspec to make sure the db writes committed. Which in turn left me having to manually cleanup my selenium stories :( So that required writing a new, rather gritty scenario listener which dealt with the cleaning operation. It has to do lots of horrible things like remove all listeners for a selenium story and then re-add them all for the others stories. *Code Extract* def story_ended(title, narrative) case title when 'Edit a page' #We have finished the selenium story $selenium_driver.stop #Do we need to re-add some listeners if [EMAIL PROTECTED] Spec::Story::Runner.scenario_runner.add_listener(ActiveRecordSafetyListener.instance) @listener_reloaded=true end end end I had to duplicate a lot of the story steps since now any previous post/gets did not work since they post to the test instance and not the selenium rails instance. I also needed to invoke against the selenium driver so even when the steps would work I had to duplicate them with $selenium_driver.do_something() This nice Given: Given('log in as a admin user') post '/admin/sessions/create', :login => @user.login, :password => @user.password end Being duplicated with this Given('log in as a admin user') $selenium_driver.open '/admin/login' $selenium_driver.type 'login', 'developer' $selenium_driver.type 'password', 'test' $selenium_driver.click 'commit' end After some very painful testing and a lot of time I got my Selenium-rc and Webrat stories working. This experience really opened my eyes to the big void introduced by Selenium-rc running outside of the test instance. This has made me wonder whether I should have rspec stories stepping outside of the test rails instance to drive Selenium tests. Has anyone managed to make this process easier? I'm hoping I'm doing something silly which is making it all harder! Is it feasible to bring selenium into the test rails instances? Is it just always going to be painful? I was skipping along having a lot of fun with stories and Webrat, now I'm face down in a puddle of mud, dreading that Selenium moment. -- Joseph Wilk http://www.joesniff.co.uk -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users