2008-11-06 20:37:16 +00:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
|
|
|
2009-08-20 02:43:23 +00:00
|
|
|
# if defined?(Nokogiri::XML) && Webrat.configuration.parse_with_nokogiri?
|
2008-11-11 05:28:15 +00:00
|
|
|
describe "Nokogiri Extension" do
|
|
|
|
include Webrat::Matchers
|
2008-11-06 20:37:16 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
def fail
|
|
|
|
raise_error(Spec::Expectations::ExpectationNotMetError)
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
before(:each) do
|
|
|
|
@text_and_password = <<-HTML
|
|
|
|
<div>
|
|
|
|
<input type="text"/>
|
|
|
|
<input type="password"/>
|
|
|
|
<span type="text"/>
|
|
|
|
</div>
|
|
|
|
HTML
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
@text_only = <<-HTML
|
|
|
|
<div>
|
|
|
|
<input type="text" disabled="disabled" />
|
|
|
|
</div>
|
|
|
|
HTML
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
@password_only = <<-HTML
|
|
|
|
<div>
|
|
|
|
<input type="password"/>
|
|
|
|
<div>
|
|
|
|
HTML
|
2008-11-06 20:37:16 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
|
|
|
describe ":text" do
|
2008-11-11 05:28:15 +00:00
|
|
|
it "passes have_selector(:text) if a node with type=text exists" do
|
|
|
|
@text_and_password.should have_selector(":text")
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
it "passes not have_selector(:text) if no node with text=text exists" do
|
|
|
|
@password_only.should_not have_selector(":text")
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
it "fails have_selector(:text) if no node with type=text exists" do
|
|
|
|
lambda { @password_only.should have_selector(":text") }.should fail
|
|
|
|
end
|
2008-11-06 20:37:16 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
it "fails not have_selector(:text) if a node with type=text exists" do
|
|
|
|
lambda { @text_only.should_not have_selector(":text") }.should fail
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
it "works together with other selectors" do
|
|
|
|
@text_and_password.should have_selector("input:text[type*='te']")
|
|
|
|
end
|
2008-11-06 20:37:16 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
describe ":password" do
|
|
|
|
it "passes have_selector(:password) if a node with type=password exists" do
|
|
|
|
@text_and_password.should have_selector(":password")
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
it "passes not have_selector(:text) if no node with text=text exists" do
|
|
|
|
@text_only.should_not have_selector(":password")
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
it "fails have_selector(:password) if no node with type=password exists" do
|
|
|
|
lambda { @text_only.should have_selector(":password") }.should fail
|
|
|
|
end
|
2008-11-06 20:37:16 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
it "fails not have_selector(:password) if a node with type=password exists" do
|
|
|
|
lambda { @password_only.should_not have_selector(":password") }.should fail
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-11 05:28:15 +00:00
|
|
|
it "works together with other selectors" do
|
|
|
|
@text_and_password.should have_selector("input:password[type*='pa']")
|
2009-04-08 00:30:12 +00:00
|
|
|
end
|
2008-11-11 05:28:15 +00:00
|
|
|
end
|
2008-11-06 20:37:16 +00:00
|
|
|
end
|
2009-08-20 02:43:23 +00:00
|
|
|
# end
|