[rspec-users] opening a response in browser (webrat)

Ben Mabey ben at benmabey.com
Mon Sep 1 20:41:49 EDT 2008


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

Jonathan Linowes wrote:
> 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)
>
> :)
>
> On Sep 1, 2008, at 2:32 PM, Zach Dennis wrote:
>
>> 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 Linowes
>> <jonathan at parkerhill.com> wrote:
>>> 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?
>>>
>>>
>>> _______________________________________________
>>> rspec-users mailing list
>>> rspec-users at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>>
>>
>>
>>
>> -- 
>> Zach Dennis
>> http://www.continuousthinking.com
>> http://www.mutuallyhuman.com
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list