简体   繁体   中英

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

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

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?)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM