capybara 2.12.1 → 2.13.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.
- checksums.yaml +4 -4
- data/History.md +12 -0
- data/README.md +31 -9
- data/lib/capybara/minitest.rb +297 -0
- data/lib/capybara/minitest/spec.rb +200 -0
- data/lib/capybara/queries/selector_query.rb +2 -2
- data/lib/capybara/rack_test/node.rb +10 -6
- data/lib/capybara/selenium/driver.rb +15 -1
- data/lib/capybara/selenium/node.rb +13 -4
- data/lib/capybara/session.rb +43 -23
- data/lib/capybara/spec/session/accept_prompt_spec.rb +0 -3
- data/lib/capybara/spec/session/evaluate_script_spec.rb +7 -0
- data/lib/capybara/spec/session/node_spec.rb +25 -1
- data/lib/capybara/spec/session/window/within_window_spec.rb +2 -2
- data/lib/capybara/spec/views/with_js.erb +2 -1
- data/lib/capybara/version.rb +1 -1
- data/spec/minitest_spec.rb +122 -0
- data/spec/minitest_spec_spec.rb +121 -0
- data/spec/shared_selenium_session.rb +28 -0
- metadata +26 -8
@@ -0,0 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'capybara/minitest'
|
4
|
+
require 'capybara/minitest/spec'
|
5
|
+
|
6
|
+
class MinitestSpecTest < Minitest::Spec
|
7
|
+
include ::Capybara::DSL
|
8
|
+
include ::Capybara::Minitest::Assertions
|
9
|
+
|
10
|
+
before do
|
11
|
+
visit('/form')
|
12
|
+
end
|
13
|
+
after do
|
14
|
+
Capybara.reset_sessions!
|
15
|
+
end
|
16
|
+
|
17
|
+
it "supports text expectations" do
|
18
|
+
page.must_have_text('Form', minimum: 1)
|
19
|
+
page.wont_have_text('Not a form')
|
20
|
+
form = find(:css, 'form', text: 'Title')
|
21
|
+
form.must_have_text('Customer Email')
|
22
|
+
form.wont_have_text('Some other email')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "supports current_path expectations" do
|
26
|
+
page.must_have_current_path('/form')
|
27
|
+
page.wont_have_current_path('/form2')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "supports title expectations" do
|
31
|
+
visit('/with_title')
|
32
|
+
page.must_have_title('Test Title')
|
33
|
+
page.wont_have_title('Not the title')
|
34
|
+
end
|
35
|
+
|
36
|
+
it "supports xpath expectations" do
|
37
|
+
page.must_have_xpath('.//input[@id="customer_email"]')
|
38
|
+
page.wont_have_xpath('.//select[@id="not_form_title"]')
|
39
|
+
page.wont_have_xpath('.//input[@id="customer_email"]') { |el| el[:id] == "not_customer_email" }
|
40
|
+
el = find(:select, 'form_title')
|
41
|
+
el.must_have_xpath('.//option[@class="title"]')
|
42
|
+
el.must_have_xpath('.//option', count: 1) { |el| el[:class] != 'title' && !el.disabled?}
|
43
|
+
el.wont_have_xpath('.//input[@id="customer_email"]')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "support css expectations" do
|
47
|
+
page.must_have_css('input#customer_email')
|
48
|
+
page.wont_have_css('select#not_form_title')
|
49
|
+
el = find(:select, 'form_title')
|
50
|
+
el.must_have_css('option.title')
|
51
|
+
el.wont_have_css('input#customer_email')
|
52
|
+
end
|
53
|
+
|
54
|
+
it "supports link expectations" do
|
55
|
+
visit('/with_html')
|
56
|
+
page.must_have_link('A link')
|
57
|
+
page.wont_have_link('Not on page')
|
58
|
+
end
|
59
|
+
|
60
|
+
it "supports button expectations" do
|
61
|
+
page.must_have_button('fresh_btn')
|
62
|
+
page.wont_have_button('not_btn')
|
63
|
+
end
|
64
|
+
|
65
|
+
it "supports field expectations" do
|
66
|
+
page.must_have_field('customer_email')
|
67
|
+
page.wont_have_field('not_on_the_form')
|
68
|
+
end
|
69
|
+
|
70
|
+
it "supports select expectations" do
|
71
|
+
page.must_have_select('form_title')
|
72
|
+
page.wont_have_select('not_form_title')
|
73
|
+
end
|
74
|
+
|
75
|
+
it "supports checked_field expectations" do
|
76
|
+
page.must_have_checked_field('form_pets_dog')
|
77
|
+
page.wont_have_checked_field('form_pets_cat')
|
78
|
+
end
|
79
|
+
|
80
|
+
it "supports unchecked_field expectations" do
|
81
|
+
page.must_have_unchecked_field('form_pets_cat')
|
82
|
+
page.wont_have_unchecked_field('form_pets_dog')
|
83
|
+
end
|
84
|
+
|
85
|
+
it "supports table expectations" do
|
86
|
+
visit('/tables')
|
87
|
+
page.must_have_table('agent_table')
|
88
|
+
page.wont_have_table('not_on_form')
|
89
|
+
end
|
90
|
+
|
91
|
+
it "supports match_selector expectations" do
|
92
|
+
find(:field, 'customer_email').must_match_selector(:field, 'customer_email')
|
93
|
+
find(:select, 'form_title').wont_match_selector(:field, 'customer_email')
|
94
|
+
end
|
95
|
+
|
96
|
+
it "supports match_css expectations" do
|
97
|
+
find(:select, 'form_title').must_match_css('select#form_title')
|
98
|
+
find(:select, 'form_title').wont_match_css('select#form_other_title')
|
99
|
+
end
|
100
|
+
|
101
|
+
it "supports match_xpath expectations" do
|
102
|
+
find(:select, 'form_title').must_match_xpath('.//select[@id="form_title"]')
|
103
|
+
find(:select, 'form_title').wont_match_xpath('.//select[@id="not_on_page"]')
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
RSpec.describe 'capybara/minitest/spec' do
|
108
|
+
before do
|
109
|
+
Capybara.current_driver = :rack_test
|
110
|
+
Capybara.app = TestApp
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should support minitest spec" do
|
114
|
+
output = StringIO.new
|
115
|
+
reporter = Minitest::SummaryReporter.new(output)
|
116
|
+
reporter.start
|
117
|
+
MinitestSpecTest.run reporter, {}
|
118
|
+
reporter.report
|
119
|
+
expect(output.string).to include("15 runs, 38 assertions, 0 failures, 0 errors, 0 skips")
|
120
|
+
end
|
121
|
+
end
|
@@ -119,5 +119,33 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
|
|
119
119
|
expect(element.path).to eq('/html/body/div[2]/a[1]')
|
120
120
|
end
|
121
121
|
end
|
122
|
+
|
123
|
+
describe "#evaluate_script" do
|
124
|
+
it "can return an element" do
|
125
|
+
@session.visit('/form')
|
126
|
+
element = @session.evaluate_script("document.getElementById('form_title')")
|
127
|
+
expect(element).to eq @session.find(:id, 'form_title')
|
128
|
+
end
|
129
|
+
|
130
|
+
it "can return arrays of nested elements" do
|
131
|
+
@session.visit('/form')
|
132
|
+
elements = @session.evaluate_script('document.querySelectorAll("#form_city option")')
|
133
|
+
elements.each do |el|
|
134
|
+
expect(el).to be_instance_of Capybara::Node::Element
|
135
|
+
end
|
136
|
+
expect(elements).to eq @session.find(:css, '#form_city').all(:css, 'option').to_a
|
137
|
+
end
|
138
|
+
|
139
|
+
it "can return hashes with elements" do
|
140
|
+
@session.visit('/form')
|
141
|
+
result = @session.evaluate_script("{ a: document.getElementById('form_title'), b: {c: document.querySelectorAll('#form_city option')}}")
|
142
|
+
expect(result).to eq({
|
143
|
+
'a' => @session.find(:id, 'form_title'),
|
144
|
+
'b' => {
|
145
|
+
'c' => @session.find(:css, '#form_city').all(:css, 'option').to_a
|
146
|
+
}
|
147
|
+
})
|
148
|
+
end
|
149
|
+
end
|
122
150
|
end
|
123
151
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Walpole
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain:
|
12
12
|
- gem-public_cert.pem
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-03-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -200,20 +200,34 @@ dependencies:
|
|
200
200
|
- - ">="
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: 0.10.5
|
203
|
+
- !ruby/object:Gem::Dependency
|
204
|
+
name: minitest
|
205
|
+
requirement: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
type: :development
|
211
|
+
prerelease: false
|
212
|
+
version_requirements: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
203
217
|
- !ruby/object:Gem::Dependency
|
204
218
|
name: rake
|
205
219
|
requirement: !ruby/object:Gem::Requirement
|
206
220
|
requirements:
|
207
|
-
- - "
|
221
|
+
- - ">="
|
208
222
|
- !ruby/object:Gem::Version
|
209
|
-
version: '
|
223
|
+
version: '0'
|
210
224
|
type: :development
|
211
225
|
prerelease: false
|
212
226
|
version_requirements: !ruby/object:Gem::Requirement
|
213
227
|
requirements:
|
214
|
-
- - "
|
228
|
+
- - ">="
|
215
229
|
- !ruby/object:Gem::Version
|
216
|
-
version: '
|
230
|
+
version: '0'
|
217
231
|
- !ruby/object:Gem::Dependency
|
218
232
|
name: pry
|
219
233
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,7 +243,7 @@ dependencies:
|
|
229
243
|
- !ruby/object:Gem::Version
|
230
244
|
version: '0'
|
231
245
|
- !ruby/object:Gem::Dependency
|
232
|
-
name:
|
246
|
+
name: erubi
|
233
247
|
requirement: !ruby/object:Gem::Requirement
|
234
248
|
requirements:
|
235
249
|
- - ">="
|
@@ -264,6 +278,8 @@ files:
|
|
264
278
|
- lib/capybara/driver/node.rb
|
265
279
|
- lib/capybara/dsl.rb
|
266
280
|
- lib/capybara/helpers.rb
|
281
|
+
- lib/capybara/minitest.rb
|
282
|
+
- lib/capybara/minitest/spec.rb
|
267
283
|
- lib/capybara/node/actions.rb
|
268
284
|
- lib/capybara/node/base.rb
|
269
285
|
- lib/capybara/node/document.rb
|
@@ -417,6 +433,8 @@ files:
|
|
417
433
|
- spec/fixtures/capybara.csv
|
418
434
|
- spec/fixtures/selenium_driver_rspec_failure.rb
|
419
435
|
- spec/fixtures/selenium_driver_rspec_success.rb
|
436
|
+
- spec/minitest_spec.rb
|
437
|
+
- spec/minitest_spec_spec.rb
|
420
438
|
- spec/rack_test_spec.rb
|
421
439
|
- spec/result_spec.rb
|
422
440
|
- spec/rspec/features_spec.rb
|
@@ -452,7 +470,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
452
470
|
version: '0'
|
453
471
|
requirements: []
|
454
472
|
rubyforge_project:
|
455
|
-
rubygems_version: 2.
|
473
|
+
rubygems_version: 2.5.2
|
456
474
|
signing_key:
|
457
475
|
specification_version: 4
|
458
476
|
summary: Capybara aims to simplify the process of integration testing Rack applications,
|