Merge branch 'document_text' of https://github.com/scytacki/capybara into scytacki-document_text

This commit is contained in:
Jonas Nicklas and Nicklas Ramhöj 2011-02-28 12:56:34 +01:00
commit cb8de0c05e
5 changed files with 36 additions and 1 deletions

View File

@ -18,7 +18,7 @@ module Capybara
# @return [String] The text of the document
#
def text
find('.').text
find(:xpath, '/html').text
end
end
end

View File

@ -99,6 +99,11 @@ shared_examples_for 'driver' do
@driver.find('//option[@value="sv"]')[0].should_not be_selected
@driver.find('//h1')[0].should_not be_selected
end
it "should return document text on /html selector" do
@driver.visit('/with_simple_html')
@driver.find('/html')[0].text.should == 'Bar'
end
end
end
end

View File

@ -66,6 +66,7 @@ shared_examples_for "session" do
it_should_behave_like "has_select"
it_should_behave_like "has_table"
it_should_behave_like "select"
it_should_behave_like "text"
it_should_behave_like "uncheck"
it_should_behave_like "unselect"
it_should_behave_like "within"

View File

@ -0,0 +1,19 @@
shared_examples_for "text" do
describe '#text' do
before do
@session.visit('/with_simple_html')
end
it "should print the text of the page" do
@session.text.should == 'Bar'
end
context "with css as default selector" do
before { Capybara.default_selector = :css }
it "should print the text of the page" do
@session.text.should == 'Bar'
end
after { Capybara.default_selector = :xpath }
end
end
end

View File

@ -250,6 +250,16 @@ describe Capybara::RSpecMatchers do
page.should have_content('No such Text')
end.to raise_error(/expected there to be content "No such Text" in "(.*)This is a test(.*)"/)
end
context "with default selector CSS" do
before { Capybara.default_selector = :css }
it "fails if has_css? returns false" do
expect do
page.should have_content('No such Text')
end.to raise_error(/expected there to be content "No such Text" in "(.*)This is a test(.*)"/)
end
after { Capybara.default_selector = :xpath }
end
end
context "with should_not" do