webrat/spec/private/nokogiri_spec.rb

78 lines
2.3 KiB
Ruby
Raw Normal View History

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?
describe "Nokogiri Extension" do
include Webrat::Matchers
def fail
raise_error(Spec::Expectations::ExpectationNotMetError)
end
2009-04-08 00:30:12 +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
@text_only = <<-HTML
<div>
<input type="text" disabled="disabled" />
</div>
HTML
2009-04-08 00:30:12 +00:00
@password_only = <<-HTML
<div>
<input type="password"/>
<div>
HTML
end
2009-04-08 00:30:12 +00:00
describe ":text" do
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
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
it "fails have_selector(:text) if no node with type=text exists" do
lambda { @password_only.should have_selector(":text") }.should fail
end
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
it "works together with other selectors" do
@text_and_password.should have_selector("input:text[type*='te']")
end
end
2009-04-08 00:30:12 +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
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
it "fails have_selector(:password) if no node with type=password exists" do
lambda { @text_only.should have_selector(":password") }.should fail
end
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
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
end
end
2009-08-20 02:43:23 +00:00
# end