rspec-html-matchers 0.9.2 → 0.9.3
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.md +0 -1
- data/features/step_definitions/steps.rb +3 -1
- data/features/support/env.rb +6 -2
- data/lib/rspec-html-matchers.rb +103 -88
- data/lib/rspec-html-matchers/have_tag.rb +141 -133
- data/lib/rspec-html-matchers/nokogiri_regexp_helper.rb +3 -5
- data/lib/rspec-html-matchers/nokogiri_text_helper.rb +3 -5
- data/lib/rspec-html-matchers/version.rb +3 -1
- data/spec/form_matchers_spec.rb +128 -126
- data/spec/have_empty_tag_spec.rb +5 -3
- data/spec/have_tag_spec.rb +152 -164
- data/spec/issues_spec.rb +27 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/asset_helpers.rb +5 -5
- data/spec/support/raise_spec_error_helper.rb +9 -7
- metadata +22 -6
data/spec/issues_spec.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe 'working on github issues' do
|
7
|
+
describe '#62' do # https://github.com/kucaahbe/rspec-html-matchers/issues/62
|
8
|
+
it 'should not have html tag' do
|
9
|
+
expect('<p>My paragraph.</p>').not_to have_tag('html')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should not have body tag' do
|
13
|
+
expect('<p>My paragraph.</p>').not_to have_tag('body')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it '#73' do # https://github.com/kucaahbe/rspec-html-matchers/issues/73
|
18
|
+
rendered = <<HTML
|
19
|
+
<p>
|
20
|
+
content with ignored
|
21
|
+
spaces
|
22
|
+
around
|
23
|
+
</p>
|
24
|
+
HTML
|
25
|
+
expect(rendered).to have_tag('p', :seen => 'content with ignored spaces around')
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
module AssetHelpers
|
4
|
+
ASSETS = File.expand_path('../../fixtures/%s.html', __FILE__)
|
4
5
|
|
5
6
|
def asset name
|
6
|
-
f = fixtures[name] ||= IO.read(ASSETS%name)
|
7
|
+
f = fixtures[name] ||= IO.read(ASSETS % name)
|
7
8
|
let(:rendered) { f }
|
8
9
|
end
|
9
10
|
|
10
11
|
private
|
11
12
|
|
12
13
|
def fixtures
|
13
|
-
@
|
14
|
+
@fixtures ||= {}
|
14
15
|
end
|
15
|
-
|
16
16
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec::Matchers.define :raise_spec_error do |expected_exception_msg|
|
2
4
|
define_method :actual_msg do
|
3
5
|
@actual_msg
|
@@ -8,11 +10,11 @@ RSpec::Matchers.define :raise_spec_error do |expected_exception_msg|
|
|
8
10
|
end
|
9
11
|
|
10
12
|
match do |block|
|
11
|
-
begin
|
13
|
+
begin # rubocop:disable Style/RedundantBegin
|
12
14
|
block.call
|
13
15
|
false
|
14
|
-
rescue RSpec::Expectations::ExpectationNotMetError =>
|
15
|
-
@actual_msg =
|
16
|
+
rescue RSpec::Expectations::ExpectationNotMetError => e
|
17
|
+
@actual_msg = e.message
|
16
18
|
|
17
19
|
case expected_exception_msg
|
18
20
|
when String
|
@@ -28,9 +30,9 @@ RSpec::Matchers.define :raise_spec_error do |expected_exception_msg|
|
|
28
30
|
|
29
31
|
supports_block_expectations
|
30
32
|
|
31
|
-
failure_message do |
|
33
|
+
failure_message do |_block|
|
32
34
|
if actual_msg
|
33
|
-
<<MSG
|
35
|
+
<<MSG # rubocop:disable Layout/IndentationWidth
|
34
36
|
expected RSpec::Expectations::ExpectationNotMetError with message:
|
35
37
|
#{expected_exception_msg}
|
36
38
|
|
@@ -38,12 +40,12 @@ got:
|
|
38
40
|
#{actual_msg}
|
39
41
|
|
40
42
|
Diff:
|
41
|
-
#{RSpec::Support::Differ.new.diff_as_string(actual_msg,expected_exception_msg.to_s)}
|
43
|
+
#{RSpec::Support::Differ.new.diff_as_string(actual_msg, expected_exception_msg.to_s)}
|
42
44
|
MSG
|
43
45
|
elsif catched_exception
|
44
46
|
"expected RSpec::Expectations::ExpectationNotMetError, but was #{catched_exception.inspect}"
|
45
47
|
else
|
46
|
-
|
48
|
+
'expected RSpec::Expectations::ExpectationNotMetError, but was no exception'
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-html-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kucaahbe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -170,6 +170,20 @@ dependencies:
|
|
170
170
|
- - ">="
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0'
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: rubocop
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - '='
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: 0.76.0
|
180
|
+
type: :development
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - '='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: 0.76.0
|
173
187
|
description: 'Nokogiri based ''have_tag'' and ''with_tag'' matchers for rspec 3. Does
|
174
188
|
not depend on assert_select matcher, provides useful error messages.
|
175
189
|
|
@@ -196,6 +210,7 @@ files:
|
|
196
210
|
- spec/form_matchers_spec.rb
|
197
211
|
- spec/have_empty_tag_spec.rb
|
198
212
|
- spec/have_tag_spec.rb
|
213
|
+
- spec/issues_spec.rb
|
199
214
|
- spec/spec_helper.rb
|
200
215
|
- spec/support/asset_helpers.rb
|
201
216
|
- spec/support/raise_spec_error_helper.rb
|
@@ -218,17 +233,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
233
|
- !ruby/object:Gem::Version
|
219
234
|
version: '0'
|
220
235
|
requirements: []
|
221
|
-
rubygems_version: 3.
|
236
|
+
rubygems_version: 3.1.2
|
222
237
|
signing_key:
|
223
238
|
specification_version: 4
|
224
239
|
summary: Nokogiri based 'have_tag' and 'with_tag' matchers for rspec 3
|
225
240
|
test_files:
|
226
|
-
- spec/have_tag_spec.rb
|
227
|
-
- spec/support/asset_helpers.rb
|
228
241
|
- spec/support/raise_spec_error_helper.rb
|
229
|
-
- spec/
|
242
|
+
- spec/support/asset_helpers.rb
|
230
243
|
- spec/have_empty_tag_spec.rb
|
231
244
|
- spec/form_matchers_spec.rb
|
245
|
+
- spec/spec_helper.rb
|
246
|
+
- spec/issues_spec.rb
|
247
|
+
- spec/have_tag_spec.rb
|
232
248
|
- features/support/env.rb
|
233
249
|
- features/step_definitions/steps.rb
|
234
250
|
- features/js_generated_content.feature
|