Skip to content

Commit

Permalink
Fix some specs, due to visibility changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed Feb 15, 2013
1 parent 4a617bc commit 0303ed8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
17 changes: 9 additions & 8 deletions lib/capybara/spec/session/all_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,23 @@
@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
Expand Down
18 changes: 10 additions & 8 deletions lib/capybara/spec/session/first_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,24 @@
@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

Expand Down
1 change: 1 addition & 0 deletions lib/capybara/spec/session/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@

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
Expand Down
1 change: 1 addition & 0 deletions lib/capybara/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def reset!
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
Expand Down

0 comments on commit 0303ed8

Please sign in to comment.