Michael Durrant
Michael Durrant

Reputation: 96544

rails - how can I show a page's HTML source in the debugger with a request spec?

I've tried p page and p page.source and also:

(rdb:1) find ('page')
(rdb:1) find ('bosy')
(rdb:1) find ('body')
(rdb:1) find
(rdb:1) p page
(rdb:1) p html
(rdb:1) p source
(rdb:1) p page.source

but all I get is variations on:

*** Unknown command: "page".  Try "help".

Code:

describe "For a user who is not logged in." do

  context "Visiting the home page." do
    before(:each) { visit root_path }

    describe "The page." do
      subject { page }

      debugger
      1   

      it "Has a 'login' link." do
        should have_link('Sign In')
      end 

      it "does NOT have a 'logout' link." do
        should have_no_link('Logout')
      end 

    end 

  end

end

Upvotes: 0

Views: 155

Answers (2)

bento
bento

Reputation: 2099

Hm. I can't answer your question, but if you goal is to peek at the page, you could use

save_and_open_page

which requires the launchy gem in test & development scope.

(assuming you're using capybara?)

Upvotes: 1

Wizard of Ogz
Wizard of Ogz

Reputation: 12643

Where your current debugger line is won't get executed in the scope where page is defined. Maybe before(:each) { visit root_path; debugger } would work. Completely untested.

Upvotes: 1

Related Questions