test-unit-capybara 1.0.5 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7cf9eb69b534f72d4a3dad72ce1a9f4cf082da1f
4
- data.tar.gz: d2d3e629a0696bcc58ed854ca54117d398ec4fc0
2
+ SHA256:
3
+ metadata.gz: 6eaf21df287fa1ff9257f14b4181d9f2a95341e0aa5cd7466eee01ab41da9b21
4
+ data.tar.gz: 1aca5c36f7fb08c0f01f6fadd9acfc86b75539c112e104e429c8fefbbcd0473c
5
5
  SHA512:
6
- metadata.gz: 05a0a4e43abd0a45fd845340d041784f05c99e645c3966f1372158c9a17834bf1ff25ddca401b47ec0d0fe80d9907ba102954abd1db4e6fee3f3e46ebc0ac516
7
- data.tar.gz: c6abb4ac9b5119a57091231fa7b2e3c0fdbde9625e45001c19ec13216f3b67c01f088776650e47096b12e1b240ea72adc921e26219ef41331aa780203a496b83
6
+ metadata.gz: b2c9baefb0b289a55fa146d7d5880d1d6e0561a4690a5740558696c36e08f21f305bcf1301e9c001341492f8bd3c35637b0e8b330cf5afafb7e3cef0423af078
7
+ data.tar.gz: cb8924383d5653b150241c29a01e766a00772f1eb693a7681d39a954f2a6db16bc830b037d879ee9ab4bb50976b92e3f199e0ec9651417e875606809ee675bb3
@@ -1,20 +1,20 @@
1
- h1. test-unit-capybara
1
+ # test-unit-capybara
2
2
 
3
- "Web site":https://github.com/test-unit/test-unit-capybara
3
+ [Web site](https://github.com/test-unit/test-unit-capybara)
4
4
 
5
- h2. Description
5
+ ## Description
6
6
 
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.
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
- h2. Install
9
+ ## Install
10
10
 
11
- <pre>
11
+ ```
12
12
  % sudo gem install test-unit-capybara
13
- </pre>
13
+ ```
14
14
 
15
- h2. Usage
15
+ ## Usage
16
16
 
17
- <pre>
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 a element in
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
- </pre>
90
+ ```
78
91
 
79
- h2. License
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
- h2. Authors
98
+ ## Authors
86
99
 
87
100
  * Kouhei Sutou
data/Rakefile CHANGED
@@ -25,6 +25,7 @@ require 'packnga'
25
25
  require "bundler/gem_helper"
26
26
 
27
27
  base_dir = File.dirname(__FILE__)
28
+ html_base_dir = File.join(base_dir, "doc", "html")
28
29
  helper = Bundler::GemHelper.new(base_dir)
29
30
 
30
31
  def helper.version_tag
@@ -44,6 +45,13 @@ document_task = Packnga::DocumentTask.new(spec) do |task|
44
45
  end
45
46
 
46
47
  Packnga::ReleaseTask.new(spec) do |task|
48
+ test_unit_github_io_dir_candidates = [
49
+ "../../www/test-unit.github.io",
50
+ ]
51
+ test_unit_github_io_dir = test_unit_github_io_dir_candidates.find do |dir|
52
+ File.directory?(dir)
53
+ end
54
+ task.index_html_dir = test_unit_github_io_dir
47
55
  end
48
56
 
49
57
  desc "Tag the current revision."
data/doc/text/news.md ADDED
@@ -0,0 +1,124 @@
1
+ # News
2
+
3
+ ## 1.1.0 - 2021-03-15
4
+
5
+ ### Improvements
6
+
7
+ * Suppressed a keyword argument warning with Ruby 2.7 or later.
8
+
9
+ ## 1.0.9 - 2019-07-11
10
+
11
+ ### Fixes
12
+
13
+ * Fixed a bug that this doesn't work with `Rack::Test`.
14
+
15
+ ## 1.0.8 - 2019-07-11
16
+
17
+ ### Improvements
18
+
19
+ * Added support for Selenium element.
20
+
21
+ * Updated CI configurations.
22
+ [GitHub#14][Patch by neko maho]
23
+
24
+ ### Fixes
25
+
26
+ * Fixed documents.
27
+ [GitHub#12][GitHub#13][Patch by Akira Matsuda]
28
+
29
+ ### Thanks
30
+
31
+ * Akira Matsuda
32
+
33
+ ## 1.0.7 - 2018-08-27
34
+
35
+ ### Improvements
36
+
37
+ * Converted document format to Markdown.
38
+ [GitHub#8][Patch by okkez]
39
+
40
+ * Added an example for JavaScript driver.
41
+ [GitHub#4][GitHub#9][GitHub#10][Patch by okkez]
42
+
43
+ * Improved support for Capybara 3.
44
+ [GitHub#11][Patch by neko maho]
45
+
46
+ ### Thanks
47
+
48
+ * okkez
49
+
50
+ * neko maho
51
+
52
+ ## 1.0.6 - 2018-06-06
53
+
54
+ ### Improvements
55
+
56
+ * Improved release script.
57
+ [GitHub#5] [Patch by Hiroyuki Sato]
58
+
59
+ * Updated documents.
60
+ [GitHub#6] [Patch by Hiroyuki Sato]
61
+
62
+ * Added support for Capybara 3.
63
+ [GitHub#7] [Patch by neko maho]
64
+
65
+ ### Thanks
66
+
67
+ * Hiroyuki Sato
68
+
69
+ * Hiroyuki Sato
70
+
71
+ * neko maho
72
+
73
+ ## 1.0.5 - 2016-01-18
74
+
75
+ ### Improvements
76
+
77
+ * Stopped to register auto test runner.
78
+
79
+ ## 1.0.4 - 2013-05-15
80
+
81
+ A Capybara 2.1.0 support release.
82
+
83
+ ### Improvements
84
+
85
+ * Supported Capybara 2.1.0.
86
+ It requires Capybara >= 2.1.0.
87
+ Notice: Capybara < 2.1.0 aren't supported from this release.
88
+ [GitHub#2] [Reported by thelastinuit]
89
+
90
+ ### Thanks
91
+
92
+ * thelastinuit
93
+
94
+ ## 1.0.3 - 2012-11-29
95
+
96
+ A support Capybara 2.0.1 release.
97
+
98
+ ### Improvements
99
+
100
+ * Supported Capybara 2.0.1.
101
+ It requires Capybara >= 2.0.1 and test-unit >= 2.5.3.
102
+ Notice: Capybara 1.X aren't supported yet from this release.
103
+
104
+ ## 1.0.2 - 2012-03-12
105
+
106
+ A Capybara integration improvement release.
107
+
108
+ ### Improvements
109
+
110
+ * Supported Capybara 1.1.2 again.
111
+
112
+ ## 1.0.1 - 2012-01-16
113
+
114
+ A Capybara integration improvement release.
115
+
116
+ ### Improvements
117
+
118
+ * Added {Test::Unit::Capybara::Assertions#assert_all}.
119
+ * Added {Test::Unit::Capybara::Assertions#assert_not_find}.
120
+ * Supported Capybara::ElementNotFound as a failure.
121
+
122
+ ## 1.0.0 - 2011-05-01
123
+
124
+ The first release!!!
@@ -1,6 +1,4 @@
1
- # -*- ruby -*-
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,18 +64,31 @@ module Test::Unit
66
64
 
67
65
  # @private
68
66
  module FindErrorWrapper
69
- def find(*args)
70
- begin
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
+ super
72
+ rescue ::Capybara::ElementNotFound => 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)
76
+ end
77
+ else
78
+ def find(*args)
71
79
  super
72
80
  rescue ::Capybara::ElementNotFound => error
73
81
  query = ::Capybara::Query.new(*args)
74
- new_error = ElementNotFound.new(self,
75
- query.selector.name,
76
- query.locator,
77
- error.message)
78
- raise new_error
82
+ raise generate_element_not_found(query, error.message)
79
83
  end
80
84
  end
85
+
86
+ def generate_element_not_found(query, message)
87
+ ElementNotFound.new(self,
88
+ query.selector.name,
89
+ query.locator,
90
+ message)
91
+ end
81
92
  end
82
93
 
83
94
  # @private
@@ -370,13 +381,17 @@ EOT
370
381
  node = nil
371
382
  node = args.shift if args[0].is_a?(::Capybara::Node::Base)
372
383
  args = normalize_page_finder_arguments(args)
373
- if node
374
- element = node.first(*args[:finder_arguments])
375
- else
376
- element = first(*args[:finder_arguments])
384
+ begin
385
+ if node
386
+ element = node.first(*args[:finder_arguments])
387
+ else
388
+ element = first(*args[:finder_arguments])
389
+ end
390
+ rescue ::Capybara::ExpectationNotMet
391
+ element = nil
377
392
  end
378
393
  format = <<-EOT
379
- <?>(?) expected to not find a element but was
394
+ <?>(?) expected to not find an element but was
380
395
  <?> in
381
396
  <?>
382
397
  EOT
@@ -412,7 +427,7 @@ EOT
412
427
  # It should be specified for useful failure message.
413
428
  def flunk_find(base_node, options={})
414
429
  format = <<-EOT
415
- <?>(?) expected to find a element in
430
+ <?>(?) expected to find an element in
416
431
  <?>
417
432
  EOT
418
433
  base_html = AssertionMessage.literal(node_source(base_node))
@@ -471,6 +486,10 @@ EOT
471
486
  node.base.source
472
487
  elsif node.base.respond_to?(:html)
473
488
  node.base.html
489
+ elsif node.base.respond_to?(:driver) and
490
+ node.base.driver.respond_to?(:evaluate_script)
491
+ node.base.driver.evaluate_script("arguments[0].outerHTML",
492
+ node.base)
474
493
  else
475
494
  node.base.native.to_s
476
495
  end
@@ -1,6 +1,4 @@
1
- # -*- ruby -*-
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
@@ -19,7 +17,7 @@
19
17
  module Test
20
18
  module Unit
21
19
  module Capybara
22
- VERSION = "1.0.5"
20
+ VERSION = "1.1.0"
23
21
  end
24
22
  end
25
23
  end
@@ -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 a element but was
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 a element but was
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 a element but was
223
+ <"h2">(:css) expected to not find an element but was
224
224
  <#{h2_html}> in
225
225
  <#{section_html}>
226
226
  EOM
@@ -257,14 +257,15 @@ HTML
257
257
  def test_pretty_print
258
258
  visit("/")
259
259
  section_html = @html.scan(/<div class="section">.*?<\/div>/m)[0]
260
+ element_class = find("html").class
260
261
  message = <<-EOM.strip
261
262
  <"XXX"> expected but was
262
- <\#<Capybara::Element tag="div" path="/html/body/div"
263
+ <\#<#{element_class} tag="div" path="/html/body/div"
263
264
  #{section_html}>>.
264
265
 
265
266
  diff:
266
267
  - "XXX"
267
- + \#<Capybara::Element tag="div" path="/html/body/div"
268
+ + \#<#{element_class} tag="div" path="/html/body/div"
268
269
  + <div class="section">
269
270
  + <h2>World</h2>
270
271
  + </div>>
@@ -25,4 +25,8 @@ require "test/unit/capybara"
25
25
  require "pp"
26
26
 
27
27
  tmp_path = File.expand_path(File.join("tmp", "capybara"), __FILE__)
28
- Capybara.save_and_open_page_path = tmp_path
28
+ if Capybara::VERSION >= "3.0.0.rc1"
29
+ Capybara.save_path = tmp_path
30
+ else
31
+ Capybara.save_and_open_page_path= tmp_path
32
+ end
data/test/test-wrapper.rb CHANGED
@@ -77,7 +77,7 @@ HTML
77
77
  "0 omissions, 0 notifications", result.to_s)
78
78
 
79
79
  message = <<-EOM.chomp
80
- <"h3">(:css) expected to find a element in
80
+ <"h3">(:css) expected to find an element in
81
81
  <<div class="section">
82
82
  <h2>World</h2>
83
83
  </div>>
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.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-17 00:00:00.000000000 Z
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: RedCloth
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.textile
148
+ - README.md
149
149
  - Rakefile
150
- - doc/text/news.textile
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,15 +173,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  - !ruby/object:Gem::Version
174
174
  version: '0'
175
175
  requirements: []
176
- rubyforge_project:
177
- rubygems_version: 2.4.5.1
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 "Capybara":https://rubygems.org/gems/capybara
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
187
- has_rdoc:
@@ -1,54 +0,0 @@
1
- h1. News
2
-
3
- h2(#1-0-5). 1.0.5 - 2016-01-18
4
-
5
- h3. Improvements
6
-
7
- * Stopped to register auto test runner.
8
-
9
- h2(#1-0-4). 1.0.4 - 2013-05-15
10
-
11
- A Capybara 2.1.0 support release.
12
-
13
- h3. Improvments
14
-
15
- * Supported Capybara 2.1.0.
16
- It requires Capybara >= 2.1.0.
17
- Notice: Capybara < 2.1.0 aren't supported from this release.
18
- [GitHub#2] [Reported by thelastinuit]
19
-
20
- h3. Thanks
21
-
22
- * thelastinuit
23
-
24
- h2(#1-0-3). 1.0.3 - 2012-11-29
25
-
26
- A support Capybara 2.0.1 release.
27
-
28
- h3. Improvments
29
-
30
- * Supported Capybara 2.0.1.
31
- It requires Capybara >= 2.0.1 and test-unit >= 2.5.3.
32
- Notice: Capybara 1.X aren't supported yet from this release.
33
-
34
- h2(#1-0-2). 1.0.2 - 2012-03-12
35
-
36
- A Capybara integration improvement release.
37
-
38
- h3. Improvments
39
-
40
- * Supported Capybara 1.1.2 again.
41
-
42
- h2(#1-0-1). 1.0.1 - 2012-01-16
43
-
44
- A Capybara integration improvement release.
45
-
46
- h3. Improvments
47
-
48
- * Added {Test::Unit::Capybara::Assertions#assert_all}.
49
- * Added {Test::Unit::Capybara::Assertions#assert_not_find}.
50
- * Supported Capybara::ElementNotFound as a failure.
51
-
52
- h2(#1-0-0). 1.0.0 - 2011-05-01
53
-
54
- The first release!!!