rspec-hal 1.2.2 → 1.2.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 57f77e5c64aaf620770e38be7a6c15809223e242
|
|
4
|
+
data.tar.gz: d82d52eeb01c80639bf02516ec46d87536d72ab5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 823a5a65289cfc48eb605bbdebf15ce3278bd8caa1b49916c9539d9b600d6ba159db33f68afac5dece8c01c9fe453c853b0a38590b1418210f669c6258a58e91
|
|
7
|
+
data.tar.gz: 1db6344915aecafd2c11ee20a1bf32c8ad94f1e29647ab975293cd33a01c1bc4466916908f0bd8e751ae9c78d0e8cdd82d677821049bed8e25c6cc1abcb391e4
|
|
@@ -3,15 +3,23 @@ module RSpec
|
|
|
3
3
|
module Matchers
|
|
4
4
|
module HalMatcherHelpers
|
|
5
5
|
NullMatcher = Class.new do
|
|
6
|
-
def matches(*args)
|
|
6
|
+
def matches?(*args)
|
|
7
7
|
true
|
|
8
8
|
end
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
def failure_message
|
|
11
|
+
""
|
|
11
12
|
end
|
|
13
|
+
alias_method :failure_message_for_should, :failure_message
|
|
14
|
+
|
|
12
15
|
def description
|
|
13
16
|
""
|
|
14
17
|
end
|
|
18
|
+
|
|
19
|
+
def ===(*args)
|
|
20
|
+
true
|
|
21
|
+
end
|
|
22
|
+
|
|
15
23
|
end.new
|
|
16
24
|
|
|
17
25
|
def repr=(jsonish)
|
|
@@ -12,36 +12,23 @@ module RSpec
|
|
|
12
12
|
|
|
13
13
|
def initialize(property_name, expected=NullMatcher)
|
|
14
14
|
@prop_name = property_name
|
|
15
|
-
@expected = expected
|
|
15
|
+
@expected = matcherize expected
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def matches?(jsonish)
|
|
19
|
-
repr =
|
|
19
|
+
self.repr = jsonish
|
|
20
20
|
|
|
21
21
|
repr.property?(prop_name) &&
|
|
22
22
|
expected === repr.property(prop_name){ nil }
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def failure_message
|
|
26
|
-
|
|
27
|
-
"found only non-templated links"
|
|
28
|
-
else
|
|
29
|
-
"found none"
|
|
30
|
-
end
|
|
31
|
-
expected_clause = if expected != NullMatcher && expected.respond_to?(:description)
|
|
32
|
-
expected.description
|
|
33
|
-
elsif expected != NullMatcher
|
|
34
|
-
"matching #{expected}"
|
|
35
|
-
else
|
|
36
|
-
"to exist"
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
"Expected templated `#{link_rel}` link #{expected_clause} but #{but_clause}"
|
|
26
|
+
sentencize "Expected property `#{prop_name}`", expected.description
|
|
40
27
|
end
|
|
41
28
|
alias_method :failure_message_for_should, :failure_message
|
|
42
29
|
|
|
43
30
|
def failure_message_when_negated
|
|
44
|
-
"Expected `#{
|
|
31
|
+
sentencize "Expected property `#{prop_name}`", expected.description, "to be absent"
|
|
45
32
|
end
|
|
46
33
|
alias_method :failure_message_for_should_not, :failure_message_when_negated
|
|
47
34
|
|
data/lib/rspec/hal/version.rb
CHANGED
|
@@ -78,9 +78,15 @@ describe RSpec::Hal::Matchers::HavePropertyMatcher do
|
|
|
78
78
|
specify { expect(matcher.matches?(json_str_w_nonmatching_property)).to be_falsey}
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
|
|
82
81
|
specify { expect(matcher.description).to match "have property `#{a_prop_name}`" }
|
|
83
82
|
|
|
83
|
+
context "failed matcher" do
|
|
84
|
+
subject(:matcher) { described_class.new a_prop_name, eq("hector") }
|
|
85
|
+
before do matcher.matches?(json_str_w_nonmatching_property) end
|
|
86
|
+
|
|
87
|
+
specify { expect(matcher.failure_message).to match(/property `#{a_prop_name}`/) }
|
|
88
|
+
specify { expect(matcher.failure_message).to match(/eq "hector"/) }
|
|
89
|
+
end
|
|
84
90
|
|
|
85
91
|
|
|
86
92
|
# Background
|
|
@@ -122,5 +128,4 @@ describe RSpec::Hal::Matchers::HavePropertyMatcher do
|
|
|
122
128
|
|
|
123
129
|
let(:any_matcher) { matching_prop_value_matcher }
|
|
124
130
|
let(:matching_prop_value_matcher) { match "Alice" }
|
|
125
|
-
# let(:nonmatching_template_str_matcher) { match "hello" }
|
|
126
131
|
end
|