rspec-rabl 1.1.0 → 1.1.1
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/.travis.yml +2 -4
- data/lib/rspec/rabl/attribute_matcher.rb +6 -3
- data/lib/rspec/rabl/version.rb +1 -1
- data/spec/fixtures/user_aliases.rabl +2 -0
- data/spec/functional/custom_matchers_spec.rb +2 -0
- data/spec/functional/matcher_errors_spec.rb +15 -12
- data/spec/support/user_context.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53940a4a41092ab090cda50e3b4aa9c7c5e34b60
|
4
|
+
data.tar.gz: 4e50171150a0e9819439e807f8ef3361131b5512
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51e74dad39d51f02879c2f4a6cecc438b630971596009f4cee8fc901ff445c01f457595b1b2f7309a842c29318a9f4788c6306be4392f69f650fab355fd009e3
|
7
|
+
data.tar.gz: f5322992ad11e2bd1d567698f9e8d50bea8c5af592698a07b1319a4087502f0586db780600bf24f9829402f80b9b1151bcd7253aec05f784b74477cae761aea3
|
data/.travis.yml
CHANGED
@@ -16,7 +16,7 @@ module RSpec
|
|
16
16
|
|
17
17
|
def matches?(subject)
|
18
18
|
@subject = subject
|
19
|
-
attribute_rendered? && rendered_value == expected_value
|
19
|
+
attribute_rendered? && (!expected_value_set || rendered_value == expected_value)
|
20
20
|
end
|
21
21
|
|
22
22
|
def with(model_attribute)
|
@@ -25,12 +25,13 @@ module RSpec
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def with_value(expected_value)
|
28
|
+
@expected_value_set = true
|
28
29
|
@expected_value = expected_value
|
29
30
|
self
|
30
31
|
end
|
31
32
|
|
32
33
|
private
|
33
|
-
attr_reader :rendered_attribute, :subject, :opts
|
34
|
+
attr_reader :rendered_attribute, :subject, :opts, :expected_value_set
|
34
35
|
|
35
36
|
def attribute_path
|
36
37
|
@attribute_path ||= begin
|
@@ -45,8 +46,10 @@ module RSpec
|
|
45
46
|
@model_attribute ||= rendered_attribute
|
46
47
|
end
|
47
48
|
|
49
|
+
# The expected value may be set to nil or false. Retrieving the value from the rendered object
|
50
|
+
# will then fail if the attribute is calculated from a node
|
48
51
|
def expected_value
|
49
|
-
@expected_value ||= get_attribute_from_rendered_object
|
52
|
+
@expected_value ||= @expected_value_set ? @expected_value : get_attribute_from_rendered_object
|
50
53
|
end
|
51
54
|
|
52
55
|
def rendered_value
|
data/lib/rspec/rabl/version.rb
CHANGED
@@ -14,6 +14,8 @@ describe "Customer Matchers" do
|
|
14
14
|
rabl_data(:root => 'user'){ user }
|
15
15
|
it{ expect(subject).to render_attribute(:id).with(:guid) }
|
16
16
|
it{ expect(subject).to render_attribute(:team).with_value('Gorby Puff') }
|
17
|
+
it{ expect(subject).to render_attribute(:feed_is_deleted).with_value(false) }
|
18
|
+
it{ expect(subject).to render_attribute(:i_am_nil).with_value(nil) }
|
17
19
|
end
|
18
20
|
|
19
21
|
describe "index.rabl" do
|
@@ -6,11 +6,12 @@ describe "Error Messages" do
|
|
6
6
|
example = it{ expect(subject).to render_attribute(:guid).with_value("Imma derp derp") }
|
7
7
|
end
|
8
8
|
group.run
|
9
|
-
lines = RSpec::Core::Notifications::FailedExampleNotification.new(example).message_lines
|
9
|
+
lines = RSpec::Core::Notifications::FailedExampleNotification.new(example).message_lines.join("\n")
|
10
10
|
|
11
|
-
expect(lines
|
12
|
-
expect(lines
|
13
|
-
expect(lines
|
11
|
+
expect(lines).to include("with_value(")
|
12
|
+
expect(lines).to include("Imma derp derp")
|
13
|
+
expect(lines).to include(" expected \"Imma derp derp\" in [\"guid\"]")
|
14
|
+
expect(lines).to include(" got nil")
|
14
15
|
end
|
15
16
|
|
16
17
|
it "renders a helpful error message for root and object_root" do
|
@@ -21,11 +22,12 @@ describe "Error Messages" do
|
|
21
22
|
example = it{ expect(subject).to render_attribute(:guid).with_value("Imma derp derp") }
|
22
23
|
end
|
23
24
|
group.run
|
24
|
-
lines = RSpec::Core::Notifications::FailedExampleNotification.new(example).message_lines
|
25
|
+
lines = RSpec::Core::Notifications::FailedExampleNotification.new(example).message_lines.join("\n")
|
25
26
|
|
26
|
-
expect(lines
|
27
|
-
expect(lines
|
28
|
-
expect(lines
|
27
|
+
expect(lines).to include("with_value(")
|
28
|
+
expect(lines).to include("Imma derp derp")
|
29
|
+
expect(lines).to include(" expected \"Imma derp derp\" in [\"user\"][\"guid\"]")
|
30
|
+
expect(lines).to include(" got \"abc\"")
|
29
31
|
end
|
30
32
|
|
31
33
|
it "renders a helpful error message for root and object_root" do
|
@@ -36,10 +38,11 @@ describe "Error Messages" do
|
|
36
38
|
example = it{ expect(subject).to render_attribute(:guid).with_value("Imma derp derp") }
|
37
39
|
end
|
38
40
|
group.run
|
39
|
-
lines = RSpec::Core::Notifications::FailedExampleNotification.new(example).message_lines
|
41
|
+
lines = RSpec::Core::Notifications::FailedExampleNotification.new(example).message_lines.join("\n")
|
40
42
|
|
41
|
-
expect(lines
|
42
|
-
expect(lines
|
43
|
-
expect(lines
|
43
|
+
expect(lines).to include("with_value(")
|
44
|
+
expect(lines).to include("Imma derp derp")
|
45
|
+
expect(lines).to include(" expected \"Imma derp derp\" in [\"users\"][\"user\"][\"guid\"]")
|
46
|
+
expect(lines).to include(" got \"abc\"")
|
44
47
|
end
|
45
48
|
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.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Ries
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.5.1
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Provides a more declarative form of view testing for users of rabl
|