[rspec-users] [cucumber] webrat+selenium integration problem: record n

Balint Erdi lists at ruby-forum.com
Sun Apr 5 17:08:53 EDT 2009

Hi Mateusz,

> hi Ben
> I am newbie with cucumber and bdd. I was wondering if you can take a 
> look on my problems.
> I have similar problem like Balint. I test my own and clearance features 
> with selenium and webrat. I don't have to say that with werbrat 
> everything is perfect. When I run features with selenium I get error 
> nil.session what is connected with code from clearance features ie:
> <pre>
> Then /^I should not be signed in$/ do
>   assert_nil request.session[:user_id]
> end
> </pre>
> in clearance_step file
> It seems like selenium has problem with access to "request" object
> That makes my test fail all the time.

I cannot tell you whether step definitions should have access to the 
request via the request variable (they probably should). But are you 
sure you need to test the session directly like this? I searched for 
'request' or 'session' in my step definitions and have not found any. 
Usually I check whether

1.  a certain thing is on the page which usually involves checking the 
response body with the help of the webrat steps file (e.g I should see 
"You are logged in")
2. a new model instance has (not) been created or have an attribute set 
to a certain value, etc. In brief, database related things.

> Another problem I met is with waiting for response after "press button" 
> method
> All the time I get response with code before button pressed
> It's connected with selenium_session.rb code and require me to change a 
> bit
> I don't know why I have to change it
> Thanks

That's a bug in webrat I also came across and fixed:

It will surely be integrated in the next webrat release, you can use the 
supplied patch.

Hope that helps,
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list