Opening a response in browser (webrat)

Given I am running an rspec story
And it uses webrat
And I am using rdebug

When I am at a breakpoint (eg after a ‘visits’ in a step)

Then how can I open the current response in a browser to see what the
page actually looks like at that point?

In the past I’ve done this…

File.open(RAILS_ROOT + “/public/duh.html”, “w”){ |f| f.puts
response.body }

And then in terminal I go to my project root and type “open
public/duh.html”. Although you may be able to get away with doing this
in your debugging session:

system “open #{RAILS_ROOT}/public/duh.html”

HTH,

Zach

On Mon, Sep 1, 2008 at 1:28 PM, Jonathan L.
[email protected] wrote:


rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users


Zach D.
http://www.continuousthinking.com

thanks
perhaps a bit hackery, I’ve added this to my shared steps file:

Given “(show me)” do
show_me
end
When “(show me)” do
show_me
end
Then “(show me)” do
show_me
end

and to my helper.rb

def show_me
File.open(RAILS_ROOT + “/public/dbug.html”, “w”){ |f| f.puts
response.body }
system “open http://localhost:3000/dbug.html
#debugger
end

so now anywhere in any story i can add (for debugging)

And (show me)

:slight_smile:

Actually, webrat already has a method for this. It will even modify the
CSS and image’s paths to work correctly… In your step simply type:

save_and_open_page

-Ben