rspec-raml 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff971a245a14b37efeb8b65df683b7934efc1de8
|
4
|
+
data.tar.gz: 4532bec8ccfe0815fa04c505561c9f344b8adc7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f207d241cbf7505f24f69fefd1d8fc55e0af85efa551d290ea1b539dfed38fe487a910bb899d686e9a9e121c08571f0e34ed3a897e6827a01bef10c1c2d95aa4
|
7
|
+
data.tar.gz: a53252fab901a64d8f1980bdeb775470c96b427fe499b609399f8907936d3b6d247cf05133383b85fce5d7b2f0ecd4d8f0da90ae8431e2db981760a6507dbd50
|
@@ -6,6 +6,10 @@ module RSpec
|
|
6
6
|
class MatchRaml < Abstract
|
7
7
|
delegate :failure_message, :failure_message_when_negated, to: :failure
|
8
8
|
|
9
|
+
def description
|
10
|
+
'match RAML'
|
11
|
+
end
|
12
|
+
|
9
13
|
private
|
10
14
|
|
11
15
|
def matches_raml?
|
@@ -17,10 +21,25 @@ module RSpec
|
|
17
21
|
end
|
18
22
|
|
19
23
|
def matchers
|
20
|
-
(RSpec::Raml::Matchers::MATCHERS - [self.class]).map do |matcher|
|
24
|
+
@matchers ||= (RSpec::Raml::Matchers::MATCHERS - [self.class]).map do |matcher|
|
21
25
|
matcher.new(raml, verb, url, status)
|
22
26
|
end
|
23
27
|
end
|
28
|
+
|
29
|
+
def respond_to_missing?(meth, *)
|
30
|
+
matchers.any? { |m| m.respond_to?(meth) } || super
|
31
|
+
end
|
32
|
+
|
33
|
+
def method_missing(meth, *args, &block)
|
34
|
+
valid = matchers.any? do |matcher|
|
35
|
+
if matcher.respond_to?(meth)
|
36
|
+
matcher.send(meth, *args, &block)
|
37
|
+
true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
valid ? self : super
|
42
|
+
end
|
24
43
|
end
|
25
44
|
end
|
26
45
|
end
|
@@ -4,6 +4,20 @@ module RSpec
|
|
4
4
|
module Raml
|
5
5
|
module Matchers
|
6
6
|
class MatchRamlBody < Abstract
|
7
|
+
def initialize(*)
|
8
|
+
super
|
9
|
+
@except = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def description
|
13
|
+
'match RAML body'
|
14
|
+
end
|
15
|
+
|
16
|
+
def except(*keys)
|
17
|
+
@except |= keys.map(&:to_s)
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
7
21
|
def failure_message
|
8
22
|
diff = differ.diff_as_object(
|
9
23
|
response_body,
|
@@ -24,16 +38,31 @@ module RSpec
|
|
24
38
|
end
|
25
39
|
|
26
40
|
def response_body
|
27
|
-
@response_body ||=
|
41
|
+
@response_body ||= comparable(response.body)
|
28
42
|
end
|
29
43
|
|
30
44
|
def raml_body
|
31
|
-
@raml_body ||=
|
45
|
+
@raml_body ||= comparable(raml.bodies.fetch(content_type).example)
|
32
46
|
end
|
33
47
|
|
34
48
|
def differ
|
35
49
|
@differ ||= RSpec::Support::Differ.new(color: true)
|
36
50
|
end
|
51
|
+
|
52
|
+
def comparable(body)
|
53
|
+
remove_exceptions JSON.parse(body)
|
54
|
+
end
|
55
|
+
|
56
|
+
def remove_exceptions(data)
|
57
|
+
case data
|
58
|
+
when Array
|
59
|
+
data.map { |item| remove_exceptions(item) }
|
60
|
+
when Hash
|
61
|
+
data.slice(*(data.keys - @except))
|
62
|
+
else
|
63
|
+
data
|
64
|
+
end
|
65
|
+
end
|
37
66
|
end
|
38
67
|
end
|
39
68
|
end
|
data/lib/rspec/raml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-raml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Zane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: raml_ruby
|