rspec-rabl 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/lib/rspec/rabl/attribute_matcher.rb +11 -2
- data/lib/rspec/rabl/version.rb +1 -1
- data/spec/functional/matcher_errors_spec.rb +45 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 031ec2eaee71bfd8fb8143fe99668fe40dac2ea2
|
4
|
+
data.tar.gz: 74c53ebd89efbcb43ae92b1c2df888f4781641d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cfccc0d17522afe45fdfbefa4eaa3e6961a47283a8cc70f52ee42386b2c683ed92e579ab9ec6c7bf4131e03d4ba95c12526d5488a4da7f3e4f2cecf3397cf28
|
7
|
+
data.tar.gz: e08a943077e9ac9e718e5ceec0bbfc5ad2f87cb0fbea0c32996beca31433e6c1e901f7adede70bc0d4d2083cd57188f5b91f939dab7f8f11faec39e8a381c7bc
|
data/.travis.yml
CHANGED
@@ -11,7 +11,7 @@ module RSpec
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def failure_message
|
14
|
-
"expected #{
|
14
|
+
"expected #{expected_value.inspect} in #{attribute_path}\n got #{rendered_value.inspect}"
|
15
15
|
end
|
16
16
|
|
17
17
|
def matches?(subject)
|
@@ -32,6 +32,15 @@ module RSpec
|
|
32
32
|
private
|
33
33
|
attr_reader :rendered_attribute, :subject, :opts
|
34
34
|
|
35
|
+
def attribute_path
|
36
|
+
@attribute_path ||= begin
|
37
|
+
path = ""
|
38
|
+
path << "[\"#{opts[:root]}\"]" if opts[:root]
|
39
|
+
path << "[\"#{opts[:object_root]}\"]" if opts[:object_root]
|
40
|
+
path << "[\"#{rendered_attribute}\"]"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
35
44
|
def model_attribute
|
36
45
|
@model_attribute ||= rendered_attribute
|
37
46
|
end
|
@@ -49,7 +58,7 @@ module RSpec
|
|
49
58
|
end
|
50
59
|
|
51
60
|
def attribute_rendered?
|
52
|
-
parsed_object.
|
61
|
+
parsed_object.key?(rendered_attribute.to_s)
|
53
62
|
end
|
54
63
|
|
55
64
|
def get_attribute_from_rendered_object
|
data/lib/rspec/rabl/version.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
describe "Error Messages" do
|
2
|
+
it "renders a helpful error message without root or object_root options" do
|
3
|
+
example = nil
|
4
|
+
group = RSpec.describe "user.rabl" do
|
5
|
+
include_context "user_context"
|
6
|
+
example = it{ expect(subject).to render_attribute(:guid).with_value("Imma derp derp") }
|
7
|
+
end
|
8
|
+
group.run
|
9
|
+
lines = RSpec::Core::Notifications::FailedExampleNotification.new(example).message_lines
|
10
|
+
|
11
|
+
expect(lines[0]).to include("with_value(\"Imma derp derp\")")
|
12
|
+
expect(lines[1]).to include(" expected \"Imma derp derp\" in [\"guid\"]")
|
13
|
+
expect(lines[2]).to include(" got nil")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "renders a helpful error message for root and object_root" do
|
17
|
+
example = nil
|
18
|
+
group = RSpec.describe "user.rabl" do
|
19
|
+
include_context "user_context"
|
20
|
+
rabl_data(:object_root => "user"){ [user] }
|
21
|
+
example = it{ expect(subject).to render_attribute(:guid).with_value("Imma derp derp") }
|
22
|
+
end
|
23
|
+
group.run
|
24
|
+
lines = RSpec::Core::Notifications::FailedExampleNotification.new(example).message_lines
|
25
|
+
|
26
|
+
expect(lines[0]).to include("with_value(\"Imma derp derp\")")
|
27
|
+
expect(lines[1]).to include(" expected \"Imma derp derp\" in [\"user\"][\"guid\"]")
|
28
|
+
expect(lines[2]).to include(" got \"abc\"")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "renders a helpful error message for root and object_root" do
|
32
|
+
example = nil
|
33
|
+
group = RSpec.describe "index.rabl" do
|
34
|
+
include_context "user_context"
|
35
|
+
rabl_data(:root => "users", :object_root => "user"){ [user] }
|
36
|
+
example = it{ expect(subject).to render_attribute(:guid).with_value("Imma derp derp") }
|
37
|
+
end
|
38
|
+
group.run
|
39
|
+
lines = RSpec::Core::Notifications::FailedExampleNotification.new(example).message_lines
|
40
|
+
|
41
|
+
expect(lines[0]).to include("with_value(\"Imma derp derp\")")
|
42
|
+
expect(lines[1]).to include(" expected \"Imma derp derp\" in [\"users\"][\"user\"][\"guid\"]")
|
43
|
+
expect(lines[2]).to include(" got \"abc\"")
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-rabl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Ries
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- spec/fixtures/user.rabl
|
111
111
|
- spec/fixtures/user_aliases.rabl
|
112
112
|
- spec/functional/custom_matchers_spec.rb
|
113
|
+
- spec/functional/matcher_errors_spec.rb
|
113
114
|
- spec/functional/render_object_spec.rb
|
114
115
|
- spec/functional/shared_examples_spec.rb
|
115
116
|
- spec/spec_helper.rb
|
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
136
|
version: '0'
|
136
137
|
requirements: []
|
137
138
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.4.
|
139
|
+
rubygems_version: 2.4.8
|
139
140
|
signing_key:
|
140
141
|
specification_version: 4
|
141
142
|
summary: Provides a more declarative form of view testing for users of rabl
|
@@ -147,6 +148,7 @@ test_files:
|
|
147
148
|
- spec/fixtures/user.rabl
|
148
149
|
- spec/fixtures/user_aliases.rabl
|
149
150
|
- spec/functional/custom_matchers_spec.rb
|
151
|
+
- spec/functional/matcher_errors_spec.rb
|
150
152
|
- spec/functional/render_object_spec.rb
|
151
153
|
- spec/functional/shared_examples_spec.rb
|
152
154
|
- spec/spec_helper.rb
|