Jonathan Linowes
2008-Sep-01 17:28 UTC
[rspec-users] 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 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
Jonathan Linowes
2008-Sep-01 23:26 UTC
[rspec-users] opening a response in browser (webrat)
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
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