[rspec-users] Using the response object in stories
Matt Wynne
matt at mattwynne.net
Tue Sep 30 11:40:03 EDT 2008
I'm sure it's possible, but sorry I don't know how offhand. I'll tell
you what I know and see if it's enough to help you figure it out for
yourself.
The code you write in cucumber steps (which calls webrat) runs inside
the context of a rails ActionController::Integration::Session. Have a
look at the docs for that - somebody must have done this before for
rails.
You can play with this in script/console by calling the 'app' object
e.g.
$ script/console
> app.post "/session", :username => 'matt', :password => 'secret'
If you want it to behave just like in your steps, require 'webrat' so
that the ActionController::Integration::Session class is monkey-
patched with the webrat goodness.
On 30 Sep 2008, at 15:25, Juanma Cervera wrote:
> I have this statement in the layout of my application (using haml)
>
> - if request.env["HTTP_USER_AGENT"].include?("MSIE")
> = stylesheet_link_tag 'blueprint/ie.css'
> = stylesheet_link_tag 'confirm_ie.css'
>
> The problem is that request.env["HTTP_USER_AGENT"] is nil when I go to
> some page in the features I write with cucumber and webrat
>
> This is the error I get
> You have a nil object when you didn't expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.include?
> (ActionView::TemplateError)
> On line #23 of layouts/application.html.haml
>
>
> ¿How can I stub these methods for the reponse object?
>
> Thanks
> Juan M. Cervera
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
More information about the rspec-users
mailing list