test-unit-capybara 1.0.6 → 1.1.1
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/{README.textile → README.md} +26 -13
- data/doc/text/news.md +130 -0
- data/lib/test/unit/capybara.rb +33 -20
- data/lib/test/unit/capybara/version.rb +2 -2
- data/test/test-assertions.rb +3 -3
- data/test/test-wrapper.rb +1 -1
- metadata +8 -9
- data/doc/text/news.textile +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a18d5ed8212ca5ff31ce77c43a2787b9d3bd94d153d87fdfccfb398ff29c07ec
|
4
|
+
data.tar.gz: a0f40dedfab5904694c52d12494a019d1c8c6829e3a4e051107682bd10b49f6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3e09b4efbdf3aef89e7b5aeec1528fb0ab572e5c172c05d18b044c5c625e52138414de61459e6099c3a90a940f434c408c481f238119af311ff03fa653d93f9
|
7
|
+
data.tar.gz: 5a6023f0d362820612a7e0ecefe577072b146a0f00e26e8e9dd5e0ccf4a1cedfe813261bd1545552d0955cde6e185a16961b25f01a87b19cfc571ca78d9dbd83
|
@@ -1,20 +1,20 @@
|
|
1
|
-
|
1
|
+
# test-unit-capybara
|
2
2
|
|
3
|
-
|
3
|
+
[Web site](https://github.com/test-unit/test-unit-capybara)
|
4
4
|
|
5
|
-
|
5
|
+
## Description
|
6
6
|
|
7
|
-
test-unit-capybara is a Capybara adapter for test-unit 2. You can get
|
7
|
+
test-unit-capybara is a Capybara adapter for test-unit 2. You can get [Capybara](https://rubygems.org/gems/capybara) integrated Test::Unit::TestCase. It also provides useful assertions for Capybara.
|
8
8
|
|
9
|
-
|
9
|
+
## Install
|
10
10
|
|
11
|
-
|
11
|
+
```
|
12
12
|
% sudo gem install test-unit-capybara
|
13
|
-
|
13
|
+
```
|
14
14
|
|
15
|
-
|
15
|
+
## Usage
|
16
16
|
|
17
|
-
|
17
|
+
```ruby
|
18
18
|
require 'test/unit/capybara'
|
19
19
|
|
20
20
|
class MyRackApplication
|
@@ -63,7 +63,7 @@ class TestMyRackApplication < Test::Unit::TestCase
|
|
63
63
|
find("ol.navi")
|
64
64
|
# This fails with the following message:
|
65
65
|
#
|
66
|
-
# <"ol.navi">(:css) expected to find
|
66
|
+
# <"ol.navi">(:css) expected to find an element in
|
67
67
|
# <<div class="header">
|
68
68
|
# <p>No navigation.</p>
|
69
69
|
# </div>>
|
@@ -73,15 +73,28 @@ class TestMyRackApplication < Test::Unit::TestCase
|
|
73
73
|
# It helps you debug a problem without save_and_open_page.
|
74
74
|
end
|
75
75
|
end
|
76
|
+
|
77
|
+
attribute :js, true
|
78
|
+
def test_destroy_a_post
|
79
|
+
# JavaScript driver is used
|
80
|
+
visit("/")
|
81
|
+
page.accept_confirm do
|
82
|
+
click_on("Destroy", match: :first)
|
83
|
+
end
|
84
|
+
|
85
|
+
within(".alert") do
|
86
|
+
assert_equal("Post was successfully destroyed", text)
|
87
|
+
end
|
88
|
+
end
|
76
89
|
end
|
77
|
-
|
90
|
+
```
|
78
91
|
|
79
|
-
|
92
|
+
## License
|
80
93
|
|
81
94
|
LGPLv2.1 or later.
|
82
95
|
|
83
96
|
(Kouhei Sutou has a right to change the license including contributed patches.)
|
84
97
|
|
85
|
-
|
98
|
+
## Authors
|
86
99
|
|
87
100
|
* Kouhei Sutou
|
data/doc/text/news.md
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
# News
|
2
|
+
|
3
|
+
## 1.1.1 - 2021-03-15
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* Added support for Ruby 3.0.0.
|
8
|
+
|
9
|
+
## 1.1.0 - 2021-03-15
|
10
|
+
|
11
|
+
### Improvements
|
12
|
+
|
13
|
+
* Suppressed a keyword argument warning with Ruby 2.7 or later.
|
14
|
+
|
15
|
+
## 1.0.9 - 2019-07-11
|
16
|
+
|
17
|
+
### Fixes
|
18
|
+
|
19
|
+
* Fixed a bug that this doesn't work with `Rack::Test`.
|
20
|
+
|
21
|
+
## 1.0.8 - 2019-07-11
|
22
|
+
|
23
|
+
### Improvements
|
24
|
+
|
25
|
+
* Added support for Selenium element.
|
26
|
+
|
27
|
+
* Updated CI configurations.
|
28
|
+
[GitHub#14][Patch by neko maho]
|
29
|
+
|
30
|
+
### Fixes
|
31
|
+
|
32
|
+
* Fixed documents.
|
33
|
+
[GitHub#12][GitHub#13][Patch by Akira Matsuda]
|
34
|
+
|
35
|
+
### Thanks
|
36
|
+
|
37
|
+
* Akira Matsuda
|
38
|
+
|
39
|
+
## 1.0.7 - 2018-08-27
|
40
|
+
|
41
|
+
### Improvements
|
42
|
+
|
43
|
+
* Converted document format to Markdown.
|
44
|
+
[GitHub#8][Patch by okkez]
|
45
|
+
|
46
|
+
* Added an example for JavaScript driver.
|
47
|
+
[GitHub#4][GitHub#9][GitHub#10][Patch by okkez]
|
48
|
+
|
49
|
+
* Improved support for Capybara 3.
|
50
|
+
[GitHub#11][Patch by neko maho]
|
51
|
+
|
52
|
+
### Thanks
|
53
|
+
|
54
|
+
* okkez
|
55
|
+
|
56
|
+
* neko maho
|
57
|
+
|
58
|
+
## 1.0.6 - 2018-06-06
|
59
|
+
|
60
|
+
### Improvements
|
61
|
+
|
62
|
+
* Improved release script.
|
63
|
+
[GitHub#5] [Patch by Hiroyuki Sato]
|
64
|
+
|
65
|
+
* Updated documents.
|
66
|
+
[GitHub#6] [Patch by Hiroyuki Sato]
|
67
|
+
|
68
|
+
* Added support for Capybara 3.
|
69
|
+
[GitHub#7] [Patch by neko maho]
|
70
|
+
|
71
|
+
### Thanks
|
72
|
+
|
73
|
+
* Hiroyuki Sato
|
74
|
+
|
75
|
+
* Hiroyuki Sato
|
76
|
+
|
77
|
+
* neko maho
|
78
|
+
|
79
|
+
## 1.0.5 - 2016-01-18
|
80
|
+
|
81
|
+
### Improvements
|
82
|
+
|
83
|
+
* Stopped to register auto test runner.
|
84
|
+
|
85
|
+
## 1.0.4 - 2013-05-15
|
86
|
+
|
87
|
+
A Capybara 2.1.0 support release.
|
88
|
+
|
89
|
+
### Improvements
|
90
|
+
|
91
|
+
* Supported Capybara 2.1.0.
|
92
|
+
It requires Capybara >= 2.1.0.
|
93
|
+
Notice: Capybara < 2.1.0 aren't supported from this release.
|
94
|
+
[GitHub#2] [Reported by thelastinuit]
|
95
|
+
|
96
|
+
### Thanks
|
97
|
+
|
98
|
+
* thelastinuit
|
99
|
+
|
100
|
+
## 1.0.3 - 2012-11-29
|
101
|
+
|
102
|
+
A support Capybara 2.0.1 release.
|
103
|
+
|
104
|
+
### Improvements
|
105
|
+
|
106
|
+
* Supported Capybara 2.0.1.
|
107
|
+
It requires Capybara >= 2.0.1 and test-unit >= 2.5.3.
|
108
|
+
Notice: Capybara 1.X aren't supported yet from this release.
|
109
|
+
|
110
|
+
## 1.0.2 - 2012-03-12
|
111
|
+
|
112
|
+
A Capybara integration improvement release.
|
113
|
+
|
114
|
+
### Improvements
|
115
|
+
|
116
|
+
* Supported Capybara 1.1.2 again.
|
117
|
+
|
118
|
+
## 1.0.1 - 2012-01-16
|
119
|
+
|
120
|
+
A Capybara integration improvement release.
|
121
|
+
|
122
|
+
### Improvements
|
123
|
+
|
124
|
+
* Added {Test::Unit::Capybara::Assertions#assert_all}.
|
125
|
+
* Added {Test::Unit::Capybara::Assertions#assert_not_find}.
|
126
|
+
* Supported Capybara::ElementNotFound as a failure.
|
127
|
+
|
128
|
+
## 1.0.0 - 2011-05-01
|
129
|
+
|
130
|
+
The first release!!!
|
data/lib/test/unit/capybara.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2011-2013 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2011-2019 Sutou Kouhei <kou@clear-code.com>
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -66,21 +64,30 @@ module Test::Unit
|
|
66
64
|
|
67
65
|
# @private
|
68
66
|
module FindErrorWrapper
|
69
|
-
|
70
|
-
|
67
|
+
find_method = ::Capybara::Node::Finders.instance_method(:find)
|
68
|
+
find_parameters = find_method.parameters
|
69
|
+
if find_parameters.any? {|_name, type| type == :options}
|
70
|
+
def find(*args, **options, &optional_filter_block)
|
71
71
|
super
|
72
72
|
rescue ::Capybara::ElementNotFound => error
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
query = ::Capybara::Query.new(*args)
|
77
|
-
end
|
78
|
-
new_error = ElementNotFound.new(self,
|
79
|
-
query.selector.name,
|
80
|
-
query.locator,
|
81
|
-
error.message)
|
82
|
-
raise new_error
|
73
|
+
options[:session_options] = session_options
|
74
|
+
query = ::Capybara::Queries::SelectorQuery.new(*args, **options, &optional_filter_block)
|
75
|
+
raise generate_element_not_found(query, error.message)
|
83
76
|
end
|
77
|
+
else
|
78
|
+
def find(*args)
|
79
|
+
super
|
80
|
+
rescue ::Capybara::ElementNotFound => error
|
81
|
+
query = ::Capybara::Query.new(*args)
|
82
|
+
raise generate_element_not_found(query, error.message)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def generate_element_not_found(query, message)
|
87
|
+
ElementNotFound.new(self,
|
88
|
+
query.selector.name,
|
89
|
+
query.locator,
|
90
|
+
message)
|
84
91
|
end
|
85
92
|
end
|
86
93
|
|
@@ -376,15 +383,17 @@ EOT
|
|
376
383
|
args = normalize_page_finder_arguments(args)
|
377
384
|
begin
|
378
385
|
if node
|
379
|
-
element = node.first(*args[:finder_arguments]
|
386
|
+
element = node.first(*args[:finder_arguments],
|
387
|
+
**args[:finder_options])
|
380
388
|
else
|
381
|
-
element = first(*args[:finder_arguments]
|
389
|
+
element = first(*args[:finder_arguments],
|
390
|
+
**args[:finder_options])
|
382
391
|
end
|
383
392
|
rescue ::Capybara::ExpectationNotMet
|
384
393
|
element = nil
|
385
394
|
end
|
386
395
|
format = <<-EOT
|
387
|
-
<?>(?) expected to not find
|
396
|
+
<?>(?) expected to not find an element but was
|
388
397
|
<?> in
|
389
398
|
<?>
|
390
399
|
EOT
|
@@ -420,7 +429,7 @@ EOT
|
|
420
429
|
# It should be specified for useful failure message.
|
421
430
|
def flunk_find(base_node, options={})
|
422
431
|
format = <<-EOT
|
423
|
-
<?>(?) expected to find
|
432
|
+
<?>(?) expected to find an element in
|
424
433
|
<?>
|
425
434
|
EOT
|
426
435
|
base_html = AssertionMessage.literal(node_source(base_node))
|
@@ -463,13 +472,13 @@ EOT
|
|
463
472
|
else
|
464
473
|
kind, locator, = args
|
465
474
|
end
|
466
|
-
args << options
|
467
475
|
|
468
476
|
{
|
469
477
|
:kind => kind,
|
470
478
|
:locator => locator,
|
471
479
|
:message => options.delete(:message),
|
472
480
|
:finder_arguments => args,
|
481
|
+
:finder_options => options,
|
473
482
|
}
|
474
483
|
end
|
475
484
|
|
@@ -479,6 +488,10 @@ EOT
|
|
479
488
|
node.base.source
|
480
489
|
elsif node.base.respond_to?(:html)
|
481
490
|
node.base.html
|
491
|
+
elsif node.base.respond_to?(:driver) and
|
492
|
+
node.base.driver.respond_to?(:evaluate_script)
|
493
|
+
node.base.driver.evaluate_script("arguments[0].outerHTML",
|
494
|
+
node.base)
|
482
495
|
else
|
483
496
|
node.base.native.to_s
|
484
497
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2011-
|
1
|
+
# Copyright (C) 2011-2021 Sutou Kouhei <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -17,7 +17,7 @@
|
|
17
17
|
module Test
|
18
18
|
module Unit
|
19
19
|
module Capybara
|
20
|
-
VERSION = "1.
|
20
|
+
VERSION = "1.1.1"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/test/test-assertions.rb
CHANGED
@@ -167,7 +167,7 @@ HTML
|
|
167
167
|
visit("/")
|
168
168
|
h1_html = @html.scan(/<h1>.*?<\/h1>/m)[0]
|
169
169
|
message = <<-EOM.strip
|
170
|
-
<"h1">(:css) expected to not find
|
170
|
+
<"h1">(:css) expected to not find an element but was
|
171
171
|
<#{h1_html}> in
|
172
172
|
<#{@html}>
|
173
173
|
EOM
|
@@ -182,7 +182,7 @@ EOM
|
|
182
182
|
section_html = @html.scan(/<div class="section">.*?<\/div>/m)[0]
|
183
183
|
h2_in_section_html = section_html.scan(/<h2>.*?<\/h2>/m)[0]
|
184
184
|
message = <<-EOM.strip
|
185
|
-
<"h2">(:css) expected to not find
|
185
|
+
<"h2">(:css) expected to not find an element but was
|
186
186
|
<#{h2_in_section_html}> in
|
187
187
|
<#{section_html}>
|
188
188
|
EOM
|
@@ -220,7 +220,7 @@ EOM
|
|
220
220
|
section_html = @html.scan(/<div class="section">.*?<\/div>/m)[0]
|
221
221
|
h2_html = section_html.scan(/<h2>.*?<\/h2>/m)[0]
|
222
222
|
message = <<-EOM.strip
|
223
|
-
<"h2">(:css) expected to not find
|
223
|
+
<"h2">(:css) expected to not find an element but was
|
224
224
|
<#{h2_html}> in
|
225
225
|
<#{section_html}>
|
226
226
|
EOM
|
data/test/test-wrapper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-unit-capybara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: redcarpet
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -145,9 +145,9 @@ extra_rdoc_files: []
|
|
145
145
|
files:
|
146
146
|
- COPYING
|
147
147
|
- Gemfile
|
148
|
-
- README.
|
148
|
+
- README.md
|
149
149
|
- Rakefile
|
150
|
-
- doc/text/news.
|
150
|
+
- doc/text/news.md
|
151
151
|
- lib/test/unit/capybara.rb
|
152
152
|
- lib/test/unit/capybara/version.rb
|
153
153
|
- test/run-test.rb
|
@@ -173,14 +173,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
173
|
- !ruby/object:Gem::Version
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
|
-
|
177
|
-
rubygems_version: 2.7.6
|
176
|
+
rubygems_version: 3.3.0.dev
|
178
177
|
signing_key:
|
179
178
|
specification_version: 4
|
180
|
-
summary: test-unit-capybara is a Capybara adapter for test-unit 2. You can get
|
179
|
+
summary: test-unit-capybara is a Capybara adapter for test-unit 2. You can get [Capybara](https://rubygems.org/gems/capybara)
|
181
180
|
integrated Test::Unit::TestCase. It also provides useful assertions for Capybara.
|
182
181
|
test_files:
|
183
|
-
- test/test-assertions.rb
|
184
182
|
- test/run-test.rb
|
183
|
+
- test/test-assertions.rb
|
185
184
|
- test/test-unit-capybara-test-utils.rb
|
186
185
|
- test/test-wrapper.rb
|
data/doc/text/news.textile
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
h1. News
|
2
|
-
|
3
|
-
h2(#1-0-6). 1.0.6 - 2018-06-06
|
4
|
-
|
5
|
-
h3. Improvements
|
6
|
-
|
7
|
-
* Improved release script.
|
8
|
-
[GitHub#5] [Patch by Hiroyuki Sato]
|
9
|
-
|
10
|
-
* Updated documents.
|
11
|
-
[GitHub#6] [Patch by Hiroyuki Sato]
|
12
|
-
|
13
|
-
* Added support for Capybara 3.
|
14
|
-
[GitHub#7] [Patch by neko maho]
|
15
|
-
|
16
|
-
h3. Thanks
|
17
|
-
|
18
|
-
* Hiroyuki Sato
|
19
|
-
|
20
|
-
* Hiroyuki Sato
|
21
|
-
|
22
|
-
* neko maho
|
23
|
-
|
24
|
-
h2(#1-0-5). 1.0.5 - 2016-01-18
|
25
|
-
|
26
|
-
h3. Improvements
|
27
|
-
|
28
|
-
* Stopped to register auto test runner.
|
29
|
-
|
30
|
-
h2(#1-0-4). 1.0.4 - 2013-05-15
|
31
|
-
|
32
|
-
A Capybara 2.1.0 support release.
|
33
|
-
|
34
|
-
h3. Improvements
|
35
|
-
|
36
|
-
* Supported Capybara 2.1.0.
|
37
|
-
It requires Capybara >= 2.1.0.
|
38
|
-
Notice: Capybara < 2.1.0 aren't supported from this release.
|
39
|
-
[GitHub#2] [Reported by thelastinuit]
|
40
|
-
|
41
|
-
h3. Thanks
|
42
|
-
|
43
|
-
* thelastinuit
|
44
|
-
|
45
|
-
h2(#1-0-3). 1.0.3 - 2012-11-29
|
46
|
-
|
47
|
-
A support Capybara 2.0.1 release.
|
48
|
-
|
49
|
-
h3. Improvments
|
50
|
-
|
51
|
-
* Supported Capybara 2.0.1.
|
52
|
-
It requires Capybara >= 2.0.1 and test-unit >= 2.5.3.
|
53
|
-
Notice: Capybara 1.X aren't supported yet from this release.
|
54
|
-
|
55
|
-
h2(#1-0-2). 1.0.2 - 2012-03-12
|
56
|
-
|
57
|
-
A Capybara integration improvement release.
|
58
|
-
|
59
|
-
h3. Improvments
|
60
|
-
|
61
|
-
* Supported Capybara 1.1.2 again.
|
62
|
-
|
63
|
-
h2(#1-0-1). 1.0.1 - 2012-01-16
|
64
|
-
|
65
|
-
A Capybara integration improvement release.
|
66
|
-
|
67
|
-
h3. Improvments
|
68
|
-
|
69
|
-
* Added {Test::Unit::Capybara::Assertions#assert_all}.
|
70
|
-
* Added {Test::Unit::Capybara::Assertions#assert_not_find}.
|
71
|
-
* Supported Capybara::ElementNotFound as a failure.
|
72
|
-
|
73
|
-
h2(#1-0-0). 1.0.0 - 2011-05-01
|
74
|
-
|
75
|
-
The first release!!!
|