/usr/lib/ruby/vendor_ruby/capybara/spec/session/unselect_spec.rb is in ruby-capybara 2.2.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | Capybara::SpecHelper.spec "#unselect" do
before do
@session.visit('/form')
end
context "with multiple select" do
it "should unselect an option from a select box by id" do
@session.unselect('Commando', :from => 'form_underwear')
@session.click_button('awesome')
extract_results(@session)['underwear'].should include('Briefs', 'Boxerbriefs')
extract_results(@session)['underwear'].should_not include('Commando')
end
it "should unselect an option without a select box" do
@session.unselect('Commando')
@session.click_button('awesome')
extract_results(@session)['underwear'].should include('Briefs', 'Boxerbriefs')
extract_results(@session)['underwear'].should_not include('Commando')
end
it "should unselect an option from a select box by label" do
@session.unselect('Commando', :from => 'Underwear')
@session.click_button('awesome')
extract_results(@session)['underwear'].should include('Briefs', 'Boxerbriefs')
extract_results(@session)['underwear'].should_not include('Commando')
end
it "should favour exact matches to option labels" do
@session.unselect("Briefs", :from => 'Underwear')
@session.click_button('awesome')
extract_results(@session)['underwear'].should include('Commando', 'Boxerbriefs')
extract_results(@session)['underwear'].should_not include('Briefs')
end
it "should escape quotes" do
@session.unselect("Frenchman's Pantalons", :from => 'Underwear')
@session.click_button('awesome')
extract_results(@session)['underwear'].should_not include("Frenchman's Pantalons")
end
it "casts to string" do
@session.unselect(:"Briefs", :from => :'Underwear')
@session.click_button('awesome')
extract_results(@session)['underwear'].should include('Commando', 'Boxerbriefs')
extract_results(@session)['underwear'].should_not include('Briefs')
end
end
context "with single select" do
it "should raise an error" do
expect { @session.unselect("English", :from => 'form_locale') }.to raise_error(Capybara::UnselectNotAllowed)
end
end
context "with a locator that doesn't exist" do
it "should raise an error" do
msg = "Unable to find select box \"does not exist\""
expect do
@session.unselect('foo', :from => 'does not exist')
end.to raise_error(Capybara::ElementNotFound, msg)
end
end
context "with an option that doesn't exist" do
it "should raise an error" do
msg = "Unable to find option \"Does not Exist\""
expect do
@session.unselect('Does not Exist', :from => 'form_underwear')
end.to raise_error(Capybara::ElementNotFound, msg)
end
end
context "with :exact option" do
context "when `false`" do
it "can match select box approximately" do
@session.unselect("Boxerbriefs", :from => "Under", :exact => false)
@session.click_button("awesome")
extract_results(@session)["underwear"].should_not include("Boxerbriefs")
end
it "can match option approximately" do
@session.unselect("Boxerbr", :from => "Underwear", :exact => false)
@session.click_button("awesome")
extract_results(@session)["underwear"].should_not include("Boxerbriefs")
end
it "can match option approximately when :from not given" do
@session.unselect("Boxerbr", :exact => false)
@session.click_button("awesome")
extract_results(@session)["underwear"].should_not include("Boxerbriefs")
end
end
context "when `true`" do
it "can match select box approximately" do
expect do
@session.unselect("Boxerbriefs", :from => "Under", :exact => true)
end.to raise_error(Capybara::ElementNotFound)
end
it "can match option approximately" do
expect do
@session.unselect("Boxerbr", :from => "Underwear", :exact => true)
end.to raise_error(Capybara::ElementNotFound)
end
it "can match option approximately when :from not given" do
expect do
@session.unselect("Boxerbr", :exact => true)
end.to raise_error(Capybara::ElementNotFound)
end
end
end
end
|