capybara 2.2.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +26 -0
  3. data/README.md +36 -14
  4. data/lib/capybara.rb +6 -3
  5. data/lib/capybara/driver/base.rb +37 -1
  6. data/lib/capybara/driver/node.rb +10 -2
  7. data/lib/capybara/helpers.rb +21 -13
  8. data/lib/capybara/node/base.rb +12 -7
  9. data/lib/capybara/node/element.rb +17 -1
  10. data/lib/capybara/node/finders.rb +22 -1
  11. data/lib/capybara/node/matchers.rb +26 -5
  12. data/lib/capybara/node/simple.rb +9 -2
  13. data/lib/capybara/rack_test/css_handlers.rb +3 -1
  14. data/lib/capybara/rack_test/form.rb +3 -2
  15. data/lib/capybara/rack_test/node.rb +3 -3
  16. data/lib/capybara/rspec.rb +1 -0
  17. data/lib/capybara/rspec/features.rb +2 -1
  18. data/lib/capybara/rspec/matchers.rb +50 -5
  19. data/lib/capybara/selenium/driver.rb +76 -12
  20. data/lib/capybara/selenium/node.rb +8 -0
  21. data/lib/capybara/server.rb +1 -1
  22. data/lib/capybara/session.rb +234 -29
  23. data/lib/capybara/spec/public/jquery.js +1 -1
  24. data/lib/capybara/spec/public/test.js +7 -0
  25. data/lib/capybara/spec/session/all_spec.rb +88 -17
  26. data/lib/capybara/spec/session/assert_selector.rb +6 -0
  27. data/lib/capybara/spec/session/attach_file_spec.rb +15 -15
  28. data/lib/capybara/spec/session/body_spec.rb +4 -4
  29. data/lib/capybara/spec/session/check_spec.rb +16 -16
  30. data/lib/capybara/spec/session/choose_spec.rb +5 -5
  31. data/lib/capybara/spec/session/click_button_spec.rb +93 -84
  32. data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -8
  33. data/lib/capybara/spec/session/click_link_spec.rb +26 -19
  34. data/lib/capybara/spec/session/current_scope_spec.rb +3 -3
  35. data/lib/capybara/spec/session/current_url_spec.rb +8 -8
  36. data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -1
  37. data/lib/capybara/spec/session/execute_script_spec.rb +2 -2
  38. data/lib/capybara/spec/session/fill_in_spec.rb +22 -22
  39. data/lib/capybara/spec/session/find_button_spec.rb +4 -4
  40. data/lib/capybara/spec/session/find_by_id_spec.rb +3 -3
  41. data/lib/capybara/spec/session/find_field_spec.rb +7 -7
  42. data/lib/capybara/spec/session/find_link_spec.rb +4 -4
  43. data/lib/capybara/spec/session/find_spec.rb +46 -46
  44. data/lib/capybara/spec/session/first_spec.rb +23 -23
  45. data/lib/capybara/spec/session/go_back_spec.rb +3 -3
  46. data/lib/capybara/spec/session/go_forward_spec.rb +4 -4
  47. data/lib/capybara/spec/session/has_button_spec.rb +13 -13
  48. data/lib/capybara/spec/session/has_css_spec.rb +87 -87
  49. data/lib/capybara/spec/session/has_field_spec.rb +87 -87
  50. data/lib/capybara/spec/session/has_link_spec.rb +11 -11
  51. data/lib/capybara/spec/session/has_select_spec.rb +58 -58
  52. data/lib/capybara/spec/session/has_selector_spec.rb +48 -48
  53. data/lib/capybara/spec/session/has_table_spec.rb +7 -7
  54. data/lib/capybara/spec/session/has_text_spec.rb +73 -73
  55. data/lib/capybara/spec/session/has_title_spec.rb +10 -10
  56. data/lib/capybara/spec/session/has_xpath_spec.rb +44 -44
  57. data/lib/capybara/spec/session/headers.rb +1 -1
  58. data/lib/capybara/spec/session/html_spec.rb +9 -9
  59. data/lib/capybara/spec/session/node_spec.rb +81 -65
  60. data/lib/capybara/spec/session/reset_session_spec.rb +15 -15
  61. data/lib/capybara/spec/session/response_code.rb +1 -1
  62. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +46 -0
  63. data/lib/capybara/spec/session/save_page_spec.rb +9 -9
  64. data/lib/capybara/spec/session/{screenshot.rb → screenshot_spec.rb} +4 -2
  65. data/lib/capybara/spec/session/select_spec.rb +22 -22
  66. data/lib/capybara/spec/session/text_spec.rb +15 -10
  67. data/lib/capybara/spec/session/title_spec.rb +2 -2
  68. data/lib/capybara/spec/session/uncheck_spec.rb +7 -7
  69. data/lib/capybara/spec/session/unselect_spec.rb +14 -14
  70. data/lib/capybara/spec/session/visit_spec.rb +24 -17
  71. data/lib/capybara/spec/session/window/become_closed_spec.rb +84 -0
  72. data/lib/capybara/spec/session/window/current_window_spec.rb +25 -0
  73. data/lib/capybara/spec/session/window/open_new_window_spec.rb +28 -0
  74. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +114 -0
  75. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +83 -0
  76. data/lib/capybara/spec/session/window/window_spec.rb +141 -0
  77. data/lib/capybara/spec/session/window/windows_spec.rb +31 -0
  78. data/lib/capybara/spec/session/window/within_window_spec.rb +188 -0
  79. data/lib/capybara/spec/session/within_frame_spec.rb +9 -9
  80. data/lib/capybara/spec/session/within_spec.rb +16 -16
  81. data/lib/capybara/spec/spec_helper.rb +14 -4
  82. data/lib/capybara/spec/views/form.erb +7 -0
  83. data/lib/capybara/spec/views/popup_one.erb +1 -1
  84. data/lib/capybara/spec/views/popup_two.erb +1 -1
  85. data/lib/capybara/spec/views/with_js.erb +2 -0
  86. data/lib/capybara/spec/views/with_windows.erb +38 -0
  87. data/lib/capybara/version.rb +1 -1
  88. data/lib/capybara/window.rb +123 -0
  89. data/spec/basic_node_spec.rb +32 -32
  90. data/spec/capybara_spec.rb +6 -7
  91. data/spec/dsl_spec.rb +48 -48
  92. data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
  93. data/spec/fixtures/selenium_driver_rspec_success.rb +2 -2
  94. data/spec/rack_test_spec.rb +33 -19
  95. data/spec/result_spec.rb +13 -13
  96. data/spec/rspec/features_spec.rb +20 -15
  97. data/spec/rspec/matchers_spec.rb +109 -109
  98. data/spec/rspec_spec.rb +10 -10
  99. data/spec/selenium_spec.rb +31 -6
  100. data/spec/selenium_spec_chrome.rb +2 -2
  101. data/spec/server_spec.rb +13 -13
  102. metadata +51 -62
  103. checksums.yaml.gz.sig +0 -0
  104. data.tar.gz.sig +0 -0
  105. data/lib/capybara/spec/session/within_window_spec.rb +0 -45
  106. data/lib/capybara/spec/views/within_popups.erb +0 -25
  107. metadata.gz.sig +0 -0
@@ -4768,7 +4768,7 @@ if ( document.documentElement.compareDocumentPosition ) {
4768
4768
  };
4769
4769
  }
4770
4770
 
4771
- // Utility function for retreiving the text value of an array of DOM nodes
4771
+ // Utility function for retrieving the text value of an array of DOM nodes
4772
4772
  Sizzle.getText = function( elems ) {
4773
4773
  var ret = "", elem;
4774
4774
 
@@ -60,4 +60,11 @@ $(function() {
60
60
  $('title').text('changed title')
61
61
  }, 250)
62
62
  });
63
+ $('#click-test').dblclick(function() {
64
+ $(this).after('<a id="has-been-double-clicked" href="#">Has been double clicked</a>');
65
+ });
66
+ $('#click-test').bind('contextmenu', function(e) {
67
+ e.preventDefault();
68
+ $(this).after('<a id="has-been-right-clicked" href="#">Has been right clicked</a>');
69
+ });
63
70
  });
@@ -4,20 +4,20 @@ Capybara::SpecHelper.spec "#all" do
4
4
  end
5
5
 
6
6
  it "should find all elements using the given locator" do
7
- @session.all('//p').should have(3).elements
8
- @session.all('//h1').first.text.should == 'This is a test'
9
- @session.all("//input[@id='test_field']").first[:value].should == 'monkey'
7
+ expect(@session.all('//p').size).to eq(3)
8
+ expect(@session.all('//h1').first.text).to eq('This is a test')
9
+ expect(@session.all("//input[@id='test_field']").first[:value]).to eq('monkey')
10
10
  end
11
11
 
12
12
  it "should return an empty array when nothing was found" do
13
- @session.all('//div[@id="nosuchthing"]').should be_empty
13
+ expect(@session.all('//div[@id="nosuchthing"]')).to be_empty
14
14
  end
15
15
 
16
16
  it "should accept an XPath instance" do
17
17
  @session.visit('/form')
18
18
  @xpath = XPath::HTML.fillable_field('Name')
19
19
  @result = @session.all(@xpath).map { |r| r.value }
20
- @result.should include('Smith', 'John', 'John Smith')
20
+ expect(@result).to include('Smith', 'John', 'John Smith')
21
21
  end
22
22
 
23
23
  it "should raise an error when given invalid options" do
@@ -26,44 +26,115 @@ Capybara::SpecHelper.spec "#all" do
26
26
 
27
27
  context "with css selectors" do
28
28
  it "should find all elements using the given selector" do
29
- @session.all(:css, 'h1').first.text.should == 'This is a test'
30
- @session.all(:css, "input[id='test_field']").first[:value].should == 'monkey'
29
+ expect(@session.all(:css, 'h1').first.text).to eq('This is a test')
30
+ expect(@session.all(:css, "input[id='test_field']").first[:value]).to eq('monkey')
31
31
  end
32
32
 
33
33
  it "should find all elements when given a list of selectors" do
34
- @session.all(:css, 'h1, p').should have(4).elements
34
+ expect(@session.all(:css, 'h1, p').size).to eq(4)
35
35
  end
36
36
  end
37
37
 
38
38
  context "with xpath selectors" do
39
39
  it "should find the first element using the given locator" do
40
- @session.all(:xpath, '//h1').first.text.should == 'This is a test'
41
- @session.all(:xpath, "//input[@id='test_field']").first[:value].should == 'monkey'
40
+ expect(@session.all(:xpath, '//h1').first.text).to eq('This is a test')
41
+ expect(@session.all(:xpath, "//input[@id='test_field']").first[:value]).to eq('monkey')
42
42
  end
43
43
  end
44
44
 
45
45
  context "with css as default selector" do
46
46
  before { Capybara.default_selector = :css }
47
47
  it "should find the first element using the given locator" do
48
- @session.all('h1').first.text.should == 'This is a test'
49
- @session.all("input[id='test_field']").first[:value].should == 'monkey'
48
+ expect(@session.all('h1').first.text).to eq('This is a test')
49
+ expect(@session.all("input[id='test_field']").first[:value]).to eq('monkey')
50
50
  end
51
51
  end
52
52
 
53
53
  context "with visible filter" do
54
54
  it "should only find visible nodes when true" do
55
- @session.all(:css, "a.simple", :visible => true).should have(1).elements
55
+ expect(@session.all(:css, "a.simple", :visible => true).size).to eq(1)
56
56
  end
57
57
 
58
58
  it "should find nodes regardless of whether they are invisible when false" do
59
- @session.all(:css, "a.simple", :visible => false).should have(2).elements
59
+ expect(@session.all(:css, "a.simple", :visible => false).size).to eq(2)
60
60
  end
61
61
 
62
62
  it "should default to Capybara.ignore_hidden_elements" do
63
63
  Capybara.ignore_hidden_elements = true
64
- @session.all(:css, "a.simple").should have(1).elements
64
+ expect(@session.all(:css, "a.simple").size).to eq(1)
65
65
  Capybara.ignore_hidden_elements = false
66
- @session.all(:css, "a.simple").should have(2).elements
66
+ expect(@session.all(:css, "a.simple").size).to eq(2)
67
+ end
68
+ end
69
+
70
+ context 'with element count filters' do
71
+ context ':count' do
72
+ it 'should succeed when the number of elements founds matches the expectation' do
73
+ expect { @session.all(:css, 'h1, p', :count => 4) }.to_not raise_error
74
+ end
75
+ it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
76
+ expect { @session.all(:css, 'h1, p', :count => 5) }.to raise_error(Capybara::ExpectationNotMet)
77
+ end
78
+ end
79
+ context ':minimum' do
80
+ it 'should succeed when the number of elements founds matches the expectation' do
81
+ expect { @session.all(:css, 'h1, p', :minimum => 0) }.to_not raise_error
82
+ end
83
+ it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
84
+ expect { @session.all(:css, 'h1, p', :minimum => 5) }.to raise_error(Capybara::ExpectationNotMet)
85
+ end
86
+ end
87
+ context ':maximum' do
88
+ it 'should succeed when the number of elements founds matches the expectation' do
89
+ expect { @session.all(:css, 'h1, p', :maximum => 4) }.to_not raise_error
90
+ end
91
+ it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
92
+ expect { @session.all(:css, 'h1, p', :maximum => 0) }.to raise_error(Capybara::ExpectationNotMet)
93
+ end
94
+ end
95
+ context ':between' do
96
+ it 'should succeed when the number of elements founds matches the expectation' do
97
+ expect { @session.all(:css, 'h1, p', :between => 2..7) }.to_not raise_error
98
+ end
99
+ it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
100
+ expect { @session.all(:css, 'h1, p', :between => 0..3) }.to raise_error(Capybara::ExpectationNotMet)
101
+ end
102
+ end
103
+
104
+ context 'with multiple count filters' do
105
+ it 'ignores other filters when :count is specified' do
106
+ o = {:count => 4,
107
+ :minimum => 5,
108
+ :maximum => 0,
109
+ :between => 0..3}
110
+ expect { @session.all(:css, 'h1, p', o) }.to_not raise_error
111
+ end
112
+ context 'with no :count expectation' do
113
+ it 'fails if :minimum is not met' do
114
+ o = {:minimum => 5,
115
+ :maximum => 4,
116
+ :between => 2..7}
117
+ expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
118
+ end
119
+ it 'fails if :maximum is not met' do
120
+ o = {:minimum => 0,
121
+ :maximum => 0,
122
+ :between => 2..7}
123
+ expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
124
+ end
125
+ it 'fails if :between is not met' do
126
+ o = {:minimum => 0,
127
+ :maximum => 4,
128
+ :between => 0..3}
129
+ expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
130
+ end
131
+ it 'succeeds if all combineable expectations are met' do
132
+ o = {:minimum => 0,
133
+ :maximum => 4,
134
+ :between => 2..7}
135
+ expect { @session.all(:css, 'h1, p', o) }.to_not raise_error
136
+ end
137
+ end
67
138
  end
68
139
  end
69
140
 
@@ -74,7 +145,7 @@ Capybara::SpecHelper.spec "#all" do
74
145
 
75
146
  it "should find any element using the given locator" do
76
147
  @session.within(:xpath, "//div[@id='for_bar']") do
77
- @session.all('.//li').should have(2).elements
148
+ expect(@session.all('.//li').size).to eq(2)
78
149
  end
79
150
  end
80
151
  end
@@ -70,6 +70,12 @@ Capybara::SpecHelper.spec '#assert_selector' do
70
70
  end
71
71
  end
72
72
 
73
+ Capybara::SpecHelper.spec '#refute_selector' do
74
+ it "should be an alias of #assert_no_selector" do
75
+ expect(Capybara::Node::Matchers.instance_method(:refute_selector)).to eq Capybara::Node::Matchers.instance_method(:assert_no_selector)
76
+ end
77
+ end
78
+
73
79
  Capybara::SpecHelper.spec '#assert_no_selector' do
74
80
  before do
75
81
  @session.visit('/with_html')
@@ -10,19 +10,19 @@ Capybara::SpecHelper.spec "#attach_file" do
10
10
  it "should set a file path by id" do
11
11
  @session.attach_file "form_image", __FILE__
12
12
  @session.click_button('awesome')
13
- extract_results(@session)['image'].should == File.basename(__FILE__)
13
+ expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
14
14
  end
15
15
 
16
16
  it "should set a file path by label" do
17
17
  @session.attach_file "Image", __FILE__
18
18
  @session.click_button('awesome')
19
- extract_results(@session)['image'].should == File.basename(__FILE__)
19
+ expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
20
20
  end
21
21
 
22
22
  it "casts to string" do
23
23
  @session.attach_file :"form_image", __FILE__
24
24
  @session.click_button('awesome')
25
- extract_results(@session)['image'].should == File.basename(__FILE__)
25
+ expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
26
26
  end
27
27
  end
28
28
 
@@ -30,51 +30,51 @@ Capybara::SpecHelper.spec "#attach_file" do
30
30
  it "should set a file path by id" do
31
31
  @session.attach_file "form_document", @test_file_path
32
32
  @session.click_button('Upload Single')
33
- @session.should have_content(File.read(@test_file_path))
33
+ expect(@session).to have_content(File.read(@test_file_path))
34
34
  end
35
35
 
36
36
  it "should set a file path by label" do
37
37
  @session.attach_file "Single Document", @test_file_path
38
38
  @session.click_button('Upload Single')
39
- @session.should have_content(File.read(@test_file_path))
39
+ expect(@session).to have_content(File.read(@test_file_path))
40
40
  end
41
41
 
42
42
  it "should not break if no file is submitted" do
43
43
  @session.click_button('Upload Single')
44
- @session.should have_content('No file uploaded')
44
+ expect(@session).to have_content('No file uploaded')
45
45
  end
46
46
 
47
47
  it "should send content type text/plain when uploading a text file" do
48
48
  @session.attach_file "Single Document", @test_file_path
49
49
  @session.click_button 'Upload Single'
50
- @session.should have_content('text/plain')
50
+ expect(@session).to have_content('text/plain')
51
51
  end
52
52
 
53
53
  it "should send content type image/jpeg when uploading an image" do
54
54
  @session.attach_file "Single Document", @test_jpg_file_path
55
55
  @session.click_button 'Upload Single'
56
- @session.should have_content('image/jpeg')
56
+ expect(@session).to have_content('image/jpeg')
57
57
  end
58
58
 
59
59
  it "should not break when using HTML5 multiple file input" do
60
60
  @session.attach_file "Multiple Documents", @test_file_path
61
61
  @session.click_button('Upload Multiple')
62
- @session.body.should include("1 | ")#number of files
63
- @session.should have_content(File.read(@test_file_path))
62
+ expect(@session.body).to include("1 | ")#number of files
63
+ expect(@session).to have_content(File.read(@test_file_path))
64
64
  end
65
65
 
66
66
  it "should not break when using HTML5 multiple file input uploading multiple files" do
67
67
  pending "Selenium is buggy on this, see http://code.google.com/p/selenium/issues/detail?id=2239" if @session.respond_to?(:mode) && @session.mode.to_s =~ /^selenium/
68
68
  @session.attach_file "Multiple Documents", [@test_file_path, @another_test_file_path]
69
69
  @session.click_button('Upload Multiple')
70
- @session.body.should include("2 | ")#number of files
71
- @session.body.should include(File.read(@test_file_path))
72
- @session.body.should include(File.read(@another_test_file_path))
70
+ expect(@session.body).to include("2 | ")#number of files
71
+ expect(@session.body).to include(File.read(@test_file_path))
72
+ expect(@session.body).to include(File.read(@another_test_file_path))
73
73
  end
74
74
 
75
75
  it "should not send anything when attaching no files to a multiple upload field" do
76
76
  @session.click_button('Upload Empty Multiple')
77
- @session.body.should include("Successfully ignored empty file field")
77
+ expect(@session.body).to include("Successfully ignored empty file field")
78
78
  end
79
79
  end
80
80
 
@@ -97,7 +97,7 @@ Capybara::SpecHelper.spec "#attach_file" do
97
97
  it "should set a file path by partial label when false" do
98
98
  @session.attach_file "Imag", __FILE__, :exact => false
99
99
  @session.click_button('awesome')
100
- extract_results(@session)['image'].should == File.basename(__FILE__)
100
+ expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
101
101
  end
102
102
 
103
103
  it "not allow partial matches when true" do
@@ -1,20 +1,20 @@
1
1
  Capybara::SpecHelper.spec '#body' do
2
2
  it "should return the unmodified page body" do
3
3
  @session.visit('/')
4
- @session.should have_content('Hello world!') # wait for content to appear if visit is async
5
- @session.body.should include('Hello world!')
4
+ expect(@session).to have_content('Hello world!') # wait for content to appear if visit is async
5
+ expect(@session.body).to include('Hello world!')
6
6
  end
7
7
 
8
8
  if "".respond_to?(:encoding)
9
9
  context "encoding of response between ascii and utf8" do
10
10
  it "should be valid with html entities" do
11
11
  @session.visit('/with_html_entities')
12
- lambda { @session.body.encode!("UTF-8") }.should_not raise_error
12
+ expect { @session.body.encode!("UTF-8") }.not_to raise_error
13
13
  end
14
14
 
15
15
  it "should be valid without html entities" do
16
16
  @session.visit('/with_html')
17
- lambda { @session.body.encode!("UTF-8") }.should_not raise_error
17
+ expect { @session.body.encode!("UTF-8") }.not_to raise_error
18
18
  end
19
19
  end
20
20
  end
@@ -6,64 +6,64 @@ Capybara::SpecHelper.spec "#check" do
6
6
  describe "'checked' attribute" do
7
7
  it "should be true if checked" do
8
8
  @session.check("Terms of Use")
9
- @session.find(:xpath, "//input[@id='form_terms_of_use']")['checked'].should be_true
9
+ expect(@session.find(:xpath, "//input[@id='form_terms_of_use']")['checked']).to be_truthy
10
10
  end
11
11
 
12
12
  it "should be false if unchecked" do
13
- @session.find(:xpath, "//input[@id='form_terms_of_use']")['checked'].should be_false
13
+ expect(@session.find(:xpath, "//input[@id='form_terms_of_use']")['checked']).to be_falsey
14
14
  end
15
15
  end
16
16
 
17
17
  it "should trigger associated events", :requires => [:js] do
18
18
  @session.visit('/with_js')
19
19
  @session.check('checkbox_with_event')
20
- @session.should have_css('#checkbox_event_triggered');
20
+ expect(@session).to have_css('#checkbox_event_triggered');
21
21
  end
22
22
 
23
23
  describe "checking" do
24
24
  it "should not change an already checked checkbox" do
25
- @session.find(:xpath, "//input[@id='form_pets_dog']")['checked'].should be_true
25
+ expect(@session.find(:xpath, "//input[@id='form_pets_dog']")['checked']).to be_truthy
26
26
  @session.check('form_pets_dog')
27
- @session.find(:xpath, "//input[@id='form_pets_dog']")['checked'].should be_true
27
+ expect(@session.find(:xpath, "//input[@id='form_pets_dog']")['checked']).to be_truthy
28
28
  end
29
29
 
30
30
  it "should check an unchecked checkbox" do
31
- @session.find(:xpath, "//input[@id='form_pets_cat']")['checked'].should be_false
31
+ expect(@session.find(:xpath, "//input[@id='form_pets_cat']")['checked']).to be_falsey
32
32
  @session.check('form_pets_cat')
33
- @session.find(:xpath, "//input[@id='form_pets_cat']")['checked'].should be_true
33
+ expect(@session.find(:xpath, "//input[@id='form_pets_cat']")['checked']).to be_truthy
34
34
  end
35
35
  end
36
36
 
37
37
  describe "unchecking" do
38
38
  it "should not change an already unchecked checkbox" do
39
- @session.find(:xpath, "//input[@id='form_pets_cat']")['checked'].should be_false
39
+ expect(@session.find(:xpath, "//input[@id='form_pets_cat']")['checked']).to be_falsey
40
40
  @session.uncheck('form_pets_cat')
41
- @session.find(:xpath, "//input[@id='form_pets_cat']")['checked'].should be_false
41
+ expect(@session.find(:xpath, "//input[@id='form_pets_cat']")['checked']).to be_falsey
42
42
  end
43
43
 
44
44
  it "should uncheck a checked checkbox" do
45
- @session.find(:xpath, "//input[@id='form_pets_dog']")['checked'].should be_true
45
+ expect(@session.find(:xpath, "//input[@id='form_pets_dog']")['checked']).to be_truthy
46
46
  @session.uncheck('form_pets_dog')
47
- @session.find(:xpath, "//input[@id='form_pets_dog']")['checked'].should be_false
47
+ expect(@session.find(:xpath, "//input[@id='form_pets_dog']")['checked']).to be_falsey
48
48
  end
49
49
  end
50
50
 
51
51
  it "should check a checkbox by id" do
52
52
  @session.check("form_pets_cat")
53
53
  @session.click_button('awesome')
54
- extract_results(@session)['pets'].should include('dog', 'cat', 'hamster')
54
+ expect(extract_results(@session)['pets']).to include('dog', 'cat', 'hamster')
55
55
  end
56
56
 
57
57
  it "should check a checkbox by label" do
58
58
  @session.check("Cat")
59
59
  @session.click_button('awesome')
60
- extract_results(@session)['pets'].should include('dog', 'cat', 'hamster')
60
+ expect(extract_results(@session)['pets']).to include('dog', 'cat', 'hamster')
61
61
  end
62
62
 
63
63
  it "casts to string" do
64
64
  @session.check(:"form_pets_cat")
65
65
  @session.click_button('awesome')
66
- extract_results(@session)['pets'].should include('dog', 'cat', 'hamster')
66
+ expect(extract_results(@session)['pets']).to include('dog', 'cat', 'hamster')
67
67
  end
68
68
 
69
69
  context "with a locator that doesn't exist" do
@@ -87,7 +87,7 @@ Capybara::SpecHelper.spec "#check" do
87
87
  it "should accept partial matches when false" do
88
88
  @session.check('Ham', :exact => false)
89
89
  @session.click_button('awesome')
90
- extract_results(@session)['pets'].should include('hamster')
90
+ expect(extract_results(@session)['pets']).to include('hamster')
91
91
  end
92
92
 
93
93
  it "should not accept partial matches when true" do
@@ -101,7 +101,7 @@ Capybara::SpecHelper.spec "#check" do
101
101
  it "can check boxes by their value" do
102
102
  @session.check('form[pets][]', :option => "cat")
103
103
  @session.click_button('awesome')
104
- extract_results(@session)['pets'].should include('cat')
104
+ expect(extract_results(@session)['pets']).to include('cat')
105
105
  end
106
106
 
107
107
  it "should raise an error if option not found" do
@@ -6,19 +6,19 @@ Capybara::SpecHelper.spec "#choose" do
6
6
  it "should choose a radio button by id" do
7
7
  @session.choose("gender_male")
8
8
  @session.click_button('awesome')
9
- extract_results(@session)['gender'].should == 'male'
9
+ expect(extract_results(@session)['gender']).to eq('male')
10
10
  end
11
11
 
12
12
  it "should choose a radio button by label" do
13
13
  @session.choose("Both")
14
14
  @session.click_button('awesome')
15
- extract_results(@session)['gender'].should == 'both'
15
+ expect(extract_results(@session)['gender']).to eq('both')
16
16
  end
17
17
 
18
18
  it "casts to string" do
19
19
  @session.choose("Both")
20
20
  @session.click_button(:'awesome')
21
- extract_results(@session)['gender'].should == 'both'
21
+ expect(extract_results(@session)['gender']).to eq('both')
22
22
  end
23
23
 
24
24
  context "with a locator that doesn't exist" do
@@ -42,7 +42,7 @@ Capybara::SpecHelper.spec "#choose" do
42
42
  it "should accept partial matches when false" do
43
43
  @session.choose("Mal", :exact => false)
44
44
  @session.click_button('awesome')
45
- extract_results(@session)['gender'].should == 'male'
45
+ expect(extract_results(@session)['gender']).to eq('male')
46
46
  end
47
47
 
48
48
  it "should not accept partial matches when true" do
@@ -56,7 +56,7 @@ Capybara::SpecHelper.spec "#choose" do
56
56
  it "can check radio buttons by their value" do
57
57
  @session.choose('form[gender]', :option => "male")
58
58
  @session.click_button('awesome')
59
- extract_results(@session)['gender'].should == "male"
59
+ expect(extract_results(@session)['gender']).to eq("male")
60
60
  end
61
61
 
62
62
  it "should raise an error if option not found" do