json_spec 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,6 +49,12 @@ module JsonSpec
49
49
  message
50
50
  end
51
51
 
52
+ def description
53
+ message = "equal JSON"
54
+ message << %( at path "#{@path}") if @path
55
+ message
56
+ end
57
+
52
58
  private
53
59
  def scrub(json, path = nil)
54
60
  generate_normalized_json(exclude_keys(parse_json(json, path))).chomp + "\n"
@@ -99,6 +105,12 @@ module JsonSpec
99
105
  message << %( at path "#{@path}") if @path
100
106
  message
101
107
  end
108
+
109
+ def description
110
+ message = "include JSON"
111
+ message << %( at path "#{@path}") if @path
112
+ message
113
+ end
102
114
  end
103
115
 
104
116
  class HaveJsonPath
@@ -124,6 +136,10 @@ module JsonSpec
124
136
  def failure_message_for_should_not
125
137
  %(Expected no JSON path "#{@path}")
126
138
  end
139
+
140
+ def description
141
+ %(have JSON path "#{@path}")
142
+ end
127
143
  end
128
144
 
129
145
  class HaveJsonType
@@ -154,6 +170,12 @@ module JsonSpec
154
170
  message << %( at path "#{@path}") if @path
155
171
  message
156
172
  end
173
+
174
+ def description
175
+ message = %(have JSON type "#{@klass.to_s}")
176
+ message << %( at path "#{@path}") if @path
177
+ message
178
+ end
157
179
  end
158
180
 
159
181
  class HaveJsonSize
@@ -185,6 +207,12 @@ module JsonSpec
185
207
  message << %( at path "#{@path}") if @path
186
208
  message
187
209
  end
210
+
211
+ def description
212
+ message = %(have JSON size "#{@expected}")
213
+ message << %( at path "#{@path}") if @path
214
+ message
215
+ end
188
216
  end
189
217
 
190
218
  def be_json_eql(json)
@@ -1,3 +1,3 @@
1
1
  module JsonSpec
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -86,6 +86,18 @@ describe "Matchers:" do
86
86
  JsonSpec.excluded_keys = %w(id json)
87
87
  %({"id":1,"json":"spec"}).should_not be_json_eql(%({"id":2,"json":"different"})).including(:id, :json)
88
88
  end
89
+
90
+ it "provide a description message" do
91
+ matcher = be_json_eql(%({"id":2,"json":"spec"}))
92
+ matcher.matches?(%({"id":1,"json":"spec"}))
93
+ matcher.description.should == "equal JSON"
94
+ end
95
+
96
+ it "provide a description message with path" do
97
+ matcher = be_json_eql(%({"id":1,"json":["spec"]})).at_path("json/0")
98
+ matcher.matches?(%({"id":1,"json":["spec"]}))
99
+ matcher.description.should == %(equal JSON at path "json/0")
100
+ end
89
101
  end
90
102
 
91
103
  context "include_json" do
@@ -140,6 +152,18 @@ describe "Matchers:" do
140
152
  it "ignores excluded keys" do
141
153
  %([{"id":1,"two":3}]).should include_json(%({"two":3}))
142
154
  end
155
+
156
+ it "provide a description message" do
157
+ matcher = include_json(%({"json":"spec"}))
158
+ matcher.matches?(%({"id":1,"json":"spec"}))
159
+ matcher.description.should == "include JSON"
160
+ end
161
+
162
+ it "provide a description message with path" do
163
+ matcher = include_json(%("spec")).at_path("json/0")
164
+ matcher.matches?(%({"id":1,"json":["spec"]}))
165
+ matcher.description.should == %(include JSON at path "json/0")
166
+ end
143
167
  end
144
168
 
145
169
  context "have_json_size" do
@@ -174,6 +198,18 @@ describe "Matchers:" do
174
198
  matcher.matches?(%([1,2,3]))
175
199
  matcher.failure_message_for_should_not.should == "Expected JSON value size to not be 3, got 3"
176
200
  end
201
+
202
+ it "provide a description message" do
203
+ matcher = have_json_size(1)
204
+ matcher.matches?(%({"id":1,"json":["spec"]}))
205
+ matcher.description.should == %(have JSON size "1")
206
+ end
207
+
208
+ it "provide a description message with path" do
209
+ matcher = have_json_size(1).at_path("json")
210
+ matcher.matches?(%({"id":1,"json":["spec"]}))
211
+ matcher.description.should == %(have JSON size "1" at path "json")
212
+ end
177
213
  end
178
214
 
179
215
  context "have_json_path" do
@@ -196,6 +232,13 @@ describe "Matchers:" do
196
232
  it "matches hash keys and array indexes" do
197
233
  %({"one":[1,2,{"three":4}]}).should have_json_path("one/2/three")
198
234
  end
235
+
236
+ it "provide a description message" do
237
+ matcher = have_json_path("json")
238
+ matcher.matches?(%({"id":1,"json":"spec"}))
239
+ matcher.description.should == %(have JSON path "json")
240
+ end
241
+
199
242
  end
200
243
 
201
244
  context "have_json_type" do
@@ -249,6 +292,18 @@ describe "Matchers:" do
249
292
  matcher.failure_message_for_should_not.should == "Expected JSON value type to not be Numeric, got Fixnum"
250
293
  end
251
294
 
295
+ it "provide a description message" do
296
+ matcher = have_json_type(String)
297
+ matcher.matches?(%({"id":1,"json":"spec"}))
298
+ matcher.description.should == %(have JSON type "String")
299
+ end
300
+
301
+ it "provide a description message with path" do
302
+ matcher = have_json_type(String).at_path("json")
303
+ matcher.matches?(%({"id":1,"json":"spec"}))
304
+ matcher.description.should == %(have JSON type "String" at path "json")
305
+ end
306
+
252
307
  context "somewhat uselessly" do
253
308
  it "matches true" do
254
309
  %(true).should have_json_type(TrueClass)
metadata CHANGED
@@ -1,100 +1,70 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: json_spec
3
- version: !ruby/object:Gem::Version
4
- hash: 63
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 8
9
- - 0
10
- version: 0.8.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Steve Richert
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-01-22 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-02-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: multi_json
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70255821517740 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 15
29
- segments:
30
- - 1
31
- - 0
32
- version: "1.0"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: rspec
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70255821517740
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70255821517240 !ruby/object:Gem::Requirement
39
28
  none: false
40
- requirements:
29
+ requirements:
41
30
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 2
46
- - 0
47
- version: "2.0"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
48
33
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: rake
52
34
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70255821517240
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70255821516760 !ruby/object:Gem::Requirement
54
39
  none: false
55
- requirements:
40
+ requirements:
56
41
  - - ~>
57
- - !ruby/object:Gem::Version
58
- hash: 25
59
- segments:
60
- - 0
61
- - 9
62
- version: "0.9"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.9'
63
44
  type: :development
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
66
- name: cucumber
67
45
  prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70255821516760
47
+ - !ruby/object:Gem::Dependency
48
+ name: cucumber
49
+ requirement: &70255821516260 !ruby/object:Gem::Requirement
69
50
  none: false
70
- requirements:
51
+ requirements:
71
52
  - - ~>
72
- - !ruby/object:Gem::Version
73
- hash: 13
74
- segments:
75
- - 1
76
- - 1
77
- version: "1.1"
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- hash: 17
81
- segments:
82
- - 1
83
- - 1
84
- - 1
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
85
57
  version: 1.1.1
86
58
  type: :development
87
- version_requirements: *id004
59
+ prerelease: false
60
+ version_requirements: *70255821516260
88
61
  description: Easily handle JSON in RSpec and Cucumber
89
- email:
62
+ email:
90
63
  - steve.richert@gmail.com
91
64
  executables: []
92
-
93
65
  extensions: []
94
-
95
66
  extra_rdoc_files: []
96
-
97
- files:
67
+ files:
98
68
  - .gitignore
99
69
  - .travis.yml
100
70
  - Gemfile
@@ -126,38 +96,29 @@ files:
126
96
  - spec/spec_helper.rb
127
97
  homepage: https://github.com/collectiveidea/json_spec
128
98
  licenses: []
129
-
130
99
  post_install_message:
131
100
  rdoc_options: []
132
-
133
- require_paths:
101
+ require_paths:
134
102
  - lib
135
- required_ruby_version: !ruby/object:Gem::Requirement
103
+ required_ruby_version: !ruby/object:Gem::Requirement
136
104
  none: false
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- hash: 3
141
- segments:
142
- - 0
143
- version: "0"
144
- required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
110
  none: false
146
- requirements:
147
- - - ">="
148
- - !ruby/object:Gem::Version
149
- hash: 3
150
- segments:
151
- - 0
152
- version: "0"
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
153
115
  requirements: []
154
-
155
116
  rubyforge_project: json_spec
156
- rubygems_version: 1.8.15
117
+ rubygems_version: 1.8.17
157
118
  signing_key:
158
119
  specification_version: 3
159
120
  summary: Easily handle JSON in RSpec and Cucumber
160
- test_files:
121
+ test_files:
161
122
  - features/equivalence.feature
162
123
  - features/inclusion.feature
163
124
  - features/memory.feature