1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Fix some specs, due to visibility changes

This commit is contained in:
Jonas Nicklas 2013-02-15 22:09:40 +01:00
parent 4a617bcafc
commit 0303ed84c5
4 changed files with 21 additions and 16 deletions

View file

@ -48,22 +48,23 @@ Capybara::SpecHelper.spec "#all" do
@session.all('h1').first.text.should == 'This is a test'
@session.all("input[id='test_field']").first[:value].should == 'monkey'
end
after { Capybara.default_selector = :xpath }
end
context "with visible filter" do
after { Capybara.ignore_hidden_elements = true }
it "should only find visible nodes" do
@session.all(:css, "a.simple").should have(1).elements
Capybara.ignore_hidden_elements = false
@session.all(:css, "a.simple").should have(2).elements
it "should only find visible nodes when true" do
@session.all(:css, "a.simple", :visible => true).should have(1).elements
end
it "should only find invisible nodes" do
Capybara.ignore_hidden_elements = true
it "should find nodes regardless of whether they are invisible when false" do
@session.all(:css, "a.simple", :visible => false).should have(2).elements
end
it "should default to Capybara.ignore_hidden_elements" do
Capybara.ignore_hidden_elements = true
@session.all(:css, "a.simple").should have(1).elements
Capybara.ignore_hidden_elements = false
@session.all(:css, "a.simple").should have(2).elements
end
end
context "within a scope" do

View file

@ -38,22 +38,24 @@ Capybara::SpecHelper.spec '#first' do
@session.first('h1').text.should == 'This is a test'
@session.first("input[id='test_field']")[:value].should == 'monkey'
end
after { Capybara.default_selector = :xpath }
end
context "with visible filter" do
after { Capybara.ignore_hidden_elements = false }
it "should only find visible nodes if true given" do
@session.first(:css, "a#invisible").should_not be_nil
it "should only find visible nodes when true" do
@session.first(:css, "a#invisible", :visible => true).should be_nil
Capybara.ignore_hidden_elements = true
@session.first(:css, "a#invisible").should be_nil
end
it "should include invisible nodes if false given" do
Capybara.ignore_hidden_elements = true
it "should find nodes regardless of whether they are invisible when false" do
@session.first(:css, "a#invisible", :visible => false).should_not be_nil
@session.first(:css, "a", :visible => false).should_not be_nil
end
it "should default to Capybara.ignore_hidden_elements" do
Capybara.ignore_hidden_elements = true
@session.first(:css, "a#invisible").should be_nil
Capybara.ignore_hidden_elements = false
@session.first(:css, "a#invisible").should_not be_nil
@session.first(:css, "a").should_not be_nil
end
end

View file

@ -83,6 +83,7 @@ Capybara::SpecHelper.spec "node" do
describe "#visible?" do
it "should extract node visibility" do
Capybara.ignore_hidden_elements = false
@session.first('//a').should be_visible
@session.find('//div[@id="hidden"]').should_not be_visible

View file

@ -19,6 +19,7 @@ module Capybara
Capybara.app_host = nil
Capybara.default_selector = :xpath
Capybara.default_wait_time = 1
Capybara.ignore_hidden_elements = true
Capybara.exact = false
Capybara.match = :smart
end