Last active
August 29, 2015 14:06
-
-
Save fidothe/cbb1f0d7b484d0e414d7 to your computer and use it in GitHub Desktop.
Capybara CSS / XPath selector spec problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2.1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org/" | |
gem "capybara" | |
gem "rspec" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GEM | |
remote: https://rubygems.org/ | |
specs: | |
capybara (2.4.3) | |
mime-types (>= 1.16) | |
nokogiri (>= 1.3.3) | |
rack (>= 1.0.0) | |
rack-test (>= 0.5.4) | |
xpath (~> 2.0) | |
diff-lcs (1.2.5) | |
mime-types (2.3) | |
mini_portile (0.6.0) | |
nokogiri (1.6.3.1) | |
mini_portile (= 0.6.0) | |
rack (1.5.2) | |
rack-test (0.6.2) | |
rack (>= 1.0) | |
rspec (3.1.0) | |
rspec-core (~> 3.1.0) | |
rspec-expectations (~> 3.1.0) | |
rspec-mocks (~> 3.1.0) | |
rspec-core (3.1.4) | |
rspec-support (~> 3.1.0) | |
rspec-expectations (3.1.1) | |
diff-lcs (>= 1.2.0, < 2.0) | |
rspec-support (~> 3.1.0) | |
rspec-mocks (3.1.1) | |
rspec-support (~> 3.1.0) | |
rspec-support (3.1.0) | |
xpath (2.0.0) | |
nokogiri (~> 1.3) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
capybara | |
rspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'capybara/rspec' | |
RSpec.configure do |config| | |
config.include(Capybara::RSpecMatchers) | |
end | |
describe "Capybara selectors not working as expected" do | |
let(:html) { "<html><head><title>t</title></head><body><p>p</p></body>" } | |
context "css" do | |
it "should report that the document has an html tag" do | |
expect(html).to have_css('html') | |
end | |
it "should report that the document has a head tag" do | |
expect(html).to have_css('head') | |
end | |
it "should report that the document has a head tag descendant of html" do | |
expect(html).to have_css('html head') | |
end | |
it "should report that the document has a head tag child of html" do | |
expect(html).to have_css('html > head') | |
end | |
end | |
context "xpath" do | |
it "should report that the document has an html tag" do | |
expect(html).to have_xpath('/html') | |
end | |
it "should report that the document has a head tag" do | |
expect(html).to have_xpath('//head') | |
end | |
it "should report that the document has a head tag child of html" do | |
expect(html).to have_xpath('/html/head') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment