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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9a36cec71cf30a760be8e02f5ce12fbb6659040
4
- data.tar.gz: 4ad2e2335d3b9be558e549a3047b836b70ccf724
3
+ metadata.gz: 031ec2eaee71bfd8fb8143fe99668fe40dac2ea2
4
+ data.tar.gz: 74c53ebd89efbcb43ae92b1c2df888f4781641d9
5
5
  SHA512:
6
- metadata.gz: e9c0e11a4ea868b5a3aca341cae622e4e8ba930aa7709241e9af0050579db94cb10161ad344f3dc1863a10fd5a4cd98f485c3b92a40d301462a8f7ea6c8b2efb
7
- data.tar.gz: 0ece30ab3bcbffb037e1cb4825daf3800febbb2dac3296a586fad162a462683e94b9b15f15309f749f4dadeb2314ee11b15d80e3897ecd679879acee224bea3e
6
+ metadata.gz: 8cfccc0d17522afe45fdfbefa4eaa3e6961a47283a8cc70f52ee42386b2c683ed92e579ab9ec6c7bf4131e03d4ba95c12526d5488a4da7f3e4f2cecf3397cf28
7
+ data.tar.gz: e08a943077e9ac9e718e5ceec0bbfc5ad2f87cb0fbea0c32996beca31433e6c1e901f7adede70bc0d4d2083cd57188f5b91f939dab7f8f11faec39e8a381c7bc
data/.travis.yml CHANGED
@@ -5,6 +5,11 @@ rvm:
5
5
  - 2.1
6
6
  - 2.2
7
7
  - jruby
8
+ - jruby-1.7
9
+ - jruby-9.0.3.0
8
10
  - jruby-head
11
+ before_install:
12
+ - gem update --system
13
+ - gem install bundler
9
14
  sudo: false
10
15
  cache: bundler
@@ -11,7 +11,7 @@ module RSpec
11
11
  end
12
12
 
13
13
  def failure_message
14
- "expected #{parsed} to render #{rendered_attribute} = #{expected_value}"
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.has_key?(rendered_attribute.to_s)
61
+ parsed_object.key?(rendered_attribute.to_s)
53
62
  end
54
63
 
55
64
  def get_attribute_from_rendered_object
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Rabl
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -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.0.0
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-03-17 00:00:00.000000000 Z
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.5
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