json_spec 0.8.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -4
- data/Gemfile +1 -1
- data/{LICENSE.md → LICENSE} +0 -0
- data/README.md +221 -210
- data/features/files.feature +89 -0
- data/features/support/env.rb +3 -0
- data/features/types.feature +7 -1
- data/json_spec.gemspec +16 -20
- data/lib/json_spec/configuration.rb +10 -2
- data/lib/json_spec/cucumber.rb +18 -3
- data/lib/json_spec/errors.rb +22 -1
- data/lib/json_spec/helpers.rb +17 -2
- data/lib/json_spec/matchers/be_json_eql.rb +63 -0
- data/lib/json_spec/matchers/have_json_path.rb +30 -0
- data/lib/json_spec/matchers/have_json_size.rb +35 -0
- data/lib/json_spec/matchers/have_json_type.rb +49 -0
- data/lib/json_spec/matchers/include_json.rb +57 -0
- data/lib/json_spec/matchers.rb +9 -218
- data/lib/json_spec/memory.rb +2 -3
- data/lib/json_spec/messages.rb +8 -0
- data/lib/json_spec.rb +3 -1
- data/spec/json_spec/configuration_spec.rb +10 -0
- data/spec/json_spec/helpers_spec.rb +33 -1
- data/spec/json_spec/matchers/be_json_eql_spec.rb +109 -0
- data/spec/json_spec/matchers/have_json_path_spec.rb +29 -0
- data/spec/json_spec/matchers/have_json_size_spec.rb +47 -0
- data/spec/json_spec/matchers/have_json_type_spec.rb +89 -0
- data/spec/json_spec/matchers/include_json_spec.rb +76 -0
- data/spec/json_spec/matchers_spec.rb +43 -287
- data/spec/json_spec/memory_spec.rb +8 -3
- data/spec/spec_helper.rb +4 -0
- data/spec/support/files/one.json +1 -0
- data/spec/support/files/project/one.json +1 -0
- data/spec/support/files/project/two.json +18 -0
- data/spec/support/files/project/version/one.json +1 -0
- data/spec/support/files/project/version/two.json +3 -0
- data/spec/support/files/two.json +24 -0
- metadata +49 -20
- data/lib/json_spec/version.rb +0 -3
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/{LICENSE.md → LICENSE}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -1,24 +1,11 @@
|
|
1
1
|
json_spec [![Build Status](https://secure.travis-ci.org/collectiveidea/json_spec.png)](http://travis-ci.org/collectiveidea/json_spec) [![Dependency Status](https://gemnasium.com/collectiveidea/json_spec.png)](https://gemnasium.com/collectiveidea/json_spec)
|
2
|
-
|
2
|
+
=========
|
3
3
|
|
4
4
|
Easily handle JSON in RSpec and Cucumber
|
5
5
|
|
6
|
-
Installation
|
7
|
-
------------
|
8
|
-
gem install json_spec
|
9
|
-
|
10
|
-
or with Bundler:
|
11
|
-
|
12
|
-
gem "json_spec"
|
13
|
-
|
14
|
-
Documentation
|
15
|
-
-------------
|
16
|
-
Please help write documentation!
|
17
|
-
|
18
|
-
[http://rdoc.info/gems/json_spec](http://rdoc.info/gems/json_spec)
|
19
|
-
|
20
6
|
RSpec
|
21
7
|
--------------
|
8
|
+
|
22
9
|
json_spec defines five new RSpec matchers:
|
23
10
|
|
24
11
|
* `be_json_eql`
|
@@ -29,43 +16,50 @@ json_spec defines five new RSpec matchers:
|
|
29
16
|
|
30
17
|
The new matchers could be used in RSpec as follows:
|
31
18
|
|
32
|
-
|
33
|
-
|
19
|
+
```ruby
|
20
|
+
describe User do
|
21
|
+
let(:user){ User.create!(first_name: "Steve", last_name: "Richert") }
|
22
|
+
|
23
|
+
context "#to_json" do
|
24
|
+
it "includes names" do
|
25
|
+
names = %({"first_name":"Steve","last_name":"Richert"})
|
26
|
+
user.to_json.should be_json_eql(names).excluding("friends")
|
27
|
+
end
|
34
28
|
|
35
|
-
|
36
|
-
|
29
|
+
it "includes the ID" do
|
30
|
+
user.to_json.should have_json_path("id")
|
31
|
+
user.to_json.should have_json_type(Integer).at_path("id")
|
32
|
+
end
|
37
33
|
|
38
|
-
|
39
|
-
|
40
|
-
end
|
34
|
+
it "includes friends" do
|
35
|
+
user.to_json.should have_json_size(0).at_path("friends")
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
json.should have_json_type(Integer).at_path("id")
|
45
|
-
end
|
37
|
+
friend = User.create!(first_name: "Catie", last_name: "Richert")
|
38
|
+
user.friends << friend
|
46
39
|
|
47
|
-
|
48
|
-
|
49
|
-
user.friends << User.create!(:first_name => "Catie", :last_name => "Richert")
|
50
|
-
json.should have_json_size(1).at_path("friends")
|
51
|
-
json.should include_json(%({"first_name":"Catie","last_name":"Richert"}))
|
52
|
-
end
|
53
|
-
end
|
40
|
+
user.to_json.should have_json_size(1).at_path("friends")
|
41
|
+
user.to_json.should include_json(friend.to_json)
|
54
42
|
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
```
|
55
46
|
|
56
|
-
|
47
|
+
json_spec also provides some useful helpers for RSpec tests:
|
57
48
|
|
58
49
|
* `parse_json`
|
59
50
|
* `normalize_json`
|
60
51
|
* `generate_normalized_json`
|
52
|
+
* `load_json`
|
61
53
|
|
62
|
-
To start using them add include
|
54
|
+
To start using them add an include them in your RSpec configuration:
|
63
55
|
|
64
|
-
|
65
|
-
|
66
|
-
|
56
|
+
```ruby
|
57
|
+
RSpec.configure do |config|
|
58
|
+
config.include JsonSpec::Helpers
|
59
|
+
end
|
60
|
+
```
|
67
61
|
|
68
|
-
|
62
|
+
You can find usage examples for the helpers in [`spec/json_spec/helpers_spec.rb`](https://github.com/collectiveidea/json_spec/blob/master/spec/json_spec/helpers_spec.rb)
|
69
63
|
|
70
64
|
### Exclusions
|
71
65
|
|
@@ -79,13 +73,15 @@ It's oftentimes helpful when evaluating JSON representations of newly-created Ac
|
|
79
73
|
so that the new ID and timestamps don't have to be known. These exclusions are globally
|
80
74
|
customizeable:
|
81
75
|
|
82
|
-
|
83
|
-
|
84
|
-
|
76
|
+
```ruby
|
77
|
+
JsonSpec.configure do
|
78
|
+
exclude_keys "created_at", "updated_at"
|
79
|
+
end
|
80
|
+
```
|
85
81
|
|
86
82
|
Now, the `id` key will be included in json_spec's comparisons. Keys can also be excluded/included
|
87
|
-
per matcher by chaining the `excluding` or `including` methods (as shown above) which will add or
|
88
|
-
the globally excluded keys, respectively.
|
83
|
+
per matcher by chaining the `excluding` or `including` methods (as shown above) which will add or
|
84
|
+
subtract from the globally excluded keys, respectively.
|
89
85
|
|
90
86
|
### Paths
|
91
87
|
|
@@ -107,151 +103,168 @@ We could access the first friend's first name with the path `"friends/0/first_na
|
|
107
103
|
|
108
104
|
Cucumber
|
109
105
|
--------
|
106
|
+
|
110
107
|
json_spec provides Cucumber steps that utilize its RSpec matchers and that's where json_spec really
|
111
108
|
shines. This is perfect for testing your app's JSON API.
|
112
109
|
|
113
110
|
In order to use the Cucumber steps, in your `env.rb` you must:
|
114
111
|
|
115
|
-
|
112
|
+
```ruby
|
113
|
+
require "json_spec/cucumber"
|
114
|
+
```
|
116
115
|
|
117
116
|
You also need to define a `last_json` method. If you're using Capybara, it could be as simple as:
|
118
117
|
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
```ruby
|
119
|
+
def last_json
|
120
|
+
page.source
|
121
|
+
end
|
122
|
+
```
|
122
123
|
|
123
124
|
Now, you can use the json_spec steps in your features:
|
124
125
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
[
|
148
|
-
{
|
149
|
-
"id": 2,
|
150
|
-
"first_name": "Catie",
|
151
|
-
"last_name": "Richert"
|
152
|
-
}
|
153
|
-
]
|
154
|
-
"""
|
155
|
-
|
156
|
-
The background steps above aren't provided by json_spec and the "visit" steps are provided by
|
157
|
-
Capybara. The remaining steps, json_spec provides. They're versatile and can be used in plenty of
|
158
|
-
different formats:
|
159
|
-
|
160
|
-
Then the JSON should be:
|
161
|
-
"""
|
162
|
-
{
|
163
|
-
"key": "value"
|
164
|
-
}
|
165
|
-
"""
|
166
|
-
Then the JSON at "path" should be:
|
126
|
+
```cucumber
|
127
|
+
Feature: User API
|
128
|
+
Background:
|
129
|
+
Given the following users exist:
|
130
|
+
| id | first_name | last_name |
|
131
|
+
| 1 | Steve | Richert |
|
132
|
+
| 2 | Catie | Richert |
|
133
|
+
And "Steve Richert" is friends with "Catie Richert"
|
134
|
+
|
135
|
+
Scenario: Index action
|
136
|
+
When I visit "/users.json"
|
137
|
+
Then the JSON response should have 2 users
|
138
|
+
And the JSON response at "0/id" should be 1
|
139
|
+
And the JSON response at "1/id" should be 2
|
140
|
+
|
141
|
+
Scenario: Show action
|
142
|
+
When I visit "/users/1.json"
|
143
|
+
Then the JSON response at "first_name" should be "Steve"
|
144
|
+
And the JSON response at "last_name" should be "Richert"
|
145
|
+
And the JSON response should have "created_at"
|
146
|
+
And the JSON response at "created_at" should be a string
|
147
|
+
And the JSON response at "friends" should be:
|
167
148
|
"""
|
168
149
|
[
|
169
|
-
|
170
|
-
|
150
|
+
{
|
151
|
+
"id": 2,
|
152
|
+
"first_name": "Catie",
|
153
|
+
"last_name": "Richert"
|
154
|
+
}
|
171
155
|
]
|
172
156
|
"""
|
157
|
+
```
|
173
158
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
Then the JSON at "path" should be ["entry","entry"]
|
178
|
-
Then the JSON at "path" should be "string"
|
179
|
-
Then the JSON at "path" should be 10
|
180
|
-
Then the JSON at "path" should be 10.0
|
181
|
-
Then the JSON at "path" should be 1e+1
|
182
|
-
Then the JSON at "path" should be true
|
183
|
-
Then the JSON at "path" should be false
|
184
|
-
Then the JSON at "path" should be null
|
185
|
-
|
186
|
-
Then the JSON should include:
|
187
|
-
"""
|
188
|
-
{
|
189
|
-
"key": "value"
|
190
|
-
}
|
191
|
-
"""
|
192
|
-
Then the JSON at "path" should include:
|
193
|
-
"""
|
194
|
-
[
|
195
|
-
"entry",
|
196
|
-
"entry"
|
197
|
-
]
|
198
|
-
"""
|
159
|
+
The background steps above aren't provided by json_spec and the "visit" steps are provided by
|
160
|
+
Capybara. The remaining steps, json_spec provides. They're versatile and can be used in plenty of
|
161
|
+
different formats:
|
199
162
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
163
|
+
```cucumber
|
164
|
+
Then the JSON should be:
|
165
|
+
"""
|
166
|
+
{
|
167
|
+
"key": "value"
|
168
|
+
}
|
169
|
+
"""
|
170
|
+
Then the JSON at "path" should be:
|
171
|
+
"""
|
172
|
+
[
|
173
|
+
"entry",
|
174
|
+
"entry"
|
175
|
+
]
|
176
|
+
"""
|
177
|
+
|
178
|
+
Then the JSON should be {"key":"value"}
|
179
|
+
Then the JSON at "path" should be {"key":"value"}
|
180
|
+
Then the JSON should be ["entry","entry"]
|
181
|
+
Then the JSON at "path" should be ["entry","entry"]
|
182
|
+
Then the JSON at "path" should be "string"
|
183
|
+
Then the JSON at "path" should be 10
|
184
|
+
Then the JSON at "path" should be 10.0
|
185
|
+
Then the JSON at "path" should be 1e+1
|
186
|
+
Then the JSON at "path" should be true
|
187
|
+
Then the JSON at "path" should be false
|
188
|
+
Then the JSON at "path" should be null
|
189
|
+
|
190
|
+
Then the JSON should include:
|
191
|
+
"""
|
192
|
+
{
|
193
|
+
"key": "value"
|
194
|
+
}
|
195
|
+
"""
|
196
|
+
Then the JSON at "path" should include:
|
197
|
+
"""
|
198
|
+
[
|
199
|
+
"entry",
|
200
|
+
"entry"
|
201
|
+
]
|
202
|
+
"""
|
203
|
+
|
204
|
+
Then the JSON should include {"key":"value"}
|
205
|
+
Then the JSON at "path" should include {"key":"value"}
|
206
|
+
Then the JSON should include ["entry","entry"]
|
207
|
+
Then the JSON at "path" should include ["entry","entry"]
|
208
|
+
Then the JSON should include "string"
|
209
|
+
Then the JSON at "path" should include "string"
|
210
|
+
Then the JSON should include 10
|
211
|
+
Then the JSON at "path" should include 10
|
212
|
+
Then the JSON should include 10.0
|
213
|
+
Then the JSON at "path" should include 10.0
|
214
|
+
Then the JSON should include 1e+1
|
215
|
+
Then the JSON at "path" should include 1e+1
|
216
|
+
Then the JSON should include true
|
217
|
+
Then the JSON at "path" should include true
|
218
|
+
Then the JSON should include false
|
219
|
+
Then the JSON at "path" should include false
|
220
|
+
Then the JSON should include null
|
221
|
+
Then the JSON at "path" should include null
|
222
|
+
|
223
|
+
Then the JSON should have "path"
|
224
|
+
|
225
|
+
Then the JSON should be a hash
|
226
|
+
Then the JSON at "path" should be an array
|
227
|
+
Then the JSON at "path" should be a float
|
228
|
+
|
229
|
+
Then the JSON should have 1 entry
|
230
|
+
Then the JSON at "path" should have 2 entries
|
231
|
+
Then the JSON should have 3 keys
|
232
|
+
Then the JSON should have 4 whatevers
|
233
|
+
```
|
229
234
|
|
230
235
|
_All instances of "should" above could be followed by "not" and all instances of "JSON" could be downcased and/or followed by "response."_
|
231
236
|
|
232
|
-
### Table
|
237
|
+
### Table Format
|
233
238
|
|
234
239
|
Another step exists that uses Cucumber's table formatting and wraps two of the above steps:
|
235
240
|
|
236
|
-
|
237
|
-
|
238
|
-
|
241
|
+
```cucumber
|
242
|
+
Then the JSON should have the following:
|
243
|
+
| path/0 | {"key":"value"} |
|
244
|
+
| path/1 | ["entry","entry"] |
|
245
|
+
```
|
239
246
|
|
240
247
|
Any number of rows can be given. The step above is equivalent to:
|
241
248
|
|
242
|
-
|
243
|
-
|
249
|
+
```cucumber
|
250
|
+
Then the JSON at "path/0" should be {"key":"value"}
|
251
|
+
And the JSON at "path/1" should be ["entry","entry"]
|
252
|
+
```
|
244
253
|
|
245
254
|
If only one column is given:
|
246
255
|
|
247
|
-
|
248
|
-
|
249
|
-
|
256
|
+
```cucumber
|
257
|
+
Then the JSON should have the following:
|
258
|
+
| path/0 |
|
259
|
+
| path/1 |
|
260
|
+
```
|
250
261
|
|
251
262
|
This is equivalent to:
|
252
263
|
|
253
|
-
|
254
|
-
|
264
|
+
```cucumber
|
265
|
+
Then the JSON should have "path/0"
|
266
|
+
And the JSON should have "path/1"
|
267
|
+
```
|
255
268
|
|
256
269
|
### JSON Memory
|
257
270
|
|
@@ -259,72 +272,70 @@ There's one more Cucumber step that json_spec provides which hasn't been used ab
|
|
259
272
|
memorize JSON for reuse in later steps. You can "keep" all or a portion of the JSON by giving a
|
260
273
|
name by which to remember it.
|
261
274
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
275
|
+
```cucumber
|
276
|
+
Feature: User API
|
277
|
+
Scenario: Index action includes full user JSON
|
278
|
+
Given the following user exists:
|
279
|
+
| id | first_name | last_name |
|
280
|
+
| 1 | Steve | Richert |
|
281
|
+
And I visit "/users/1.json"
|
282
|
+
And I keep the JSON response as "USER_1"
|
283
|
+
When I visit "/users.json"
|
284
|
+
Then the JSON response should be:
|
285
|
+
"""
|
286
|
+
[
|
287
|
+
%{USER_1}
|
288
|
+
]
|
289
|
+
"""
|
290
|
+
```
|
276
291
|
|
277
292
|
You can memorize JSON at a path:
|
278
293
|
|
279
|
-
|
294
|
+
```cucumber
|
295
|
+
Given I keep the JSON response at "first_name" as "FIRST_NAME"
|
296
|
+
```
|
280
297
|
|
281
298
|
You can remember JSON at a path:
|
282
299
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
300
|
+
```cucumber
|
301
|
+
Then the JSON response at "0/first_name" should be:
|
302
|
+
"""
|
303
|
+
%{FIRST_NAME}
|
304
|
+
"""
|
305
|
+
```
|
287
306
|
|
288
307
|
You can also remember JSON inline:
|
289
308
|
|
290
|
-
|
309
|
+
```cucumber
|
310
|
+
Then the JSON response at "0/first_name" should be %{FIRST_NAME}
|
311
|
+
```
|
312
|
+
|
313
|
+
### More
|
314
|
+
|
315
|
+
Check out the [specs](https://github.com/collectiveidea/json_spec/blob/master/spec)
|
316
|
+
and [features](https://github.com/collectiveidea/json_spec/blob/master/features) too see all the
|
317
|
+
various ways you can use json_spec.
|
291
318
|
|
292
319
|
Contributing
|
293
320
|
------------
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
*
|
299
|
-
*
|
300
|
-
*
|
301
|
-
*
|
302
|
-
*
|
303
|
-
*
|
304
|
-
*
|
305
|
-
*
|
306
|
-
|
307
|
-
|
308
|
-
Submitting an Issue
|
309
|
-
-------------------
|
310
|
-
We use the [GitHub issue tracker](https://github.com/collectiveidea/json_spec/issues) to track bugs
|
311
|
-
and features. Before submitting a bug report or feature request, check to make sure it hasn't already
|
312
|
-
been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
|
313
|
-
bug report, please include a [Gist](https://gist.github.com/) that includes a stack trace and any
|
314
|
-
details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
|
315
|
-
operating system. Ideally, a bug report should include a pull request with failing specs.
|
316
|
-
|
317
|
-
Submitting a Pull Request
|
318
|
-
-------------------------
|
319
|
-
1. Fork the project.
|
320
|
-
2. Create a topic branch.
|
321
|
-
3. Implement your feature or bug fix.
|
322
|
-
4. Add specs for your feature or bug fix.
|
323
|
-
5. Run `bundle exec rake`. If your changes are not 100% covered and passing, go back to step 4.
|
324
|
-
6. Commit and push your changes.
|
325
|
-
7. Submit a pull request. Please do not include changes to the gemspec, version, or history file. (If you want to create your own version for some reason, please do so in a separate commit.)
|
321
|
+
|
322
|
+
If you come across any issues, please [tell us](https://github.com/collectiveidea/json_spec/issues).
|
323
|
+
Pull requests (with tests) are appreciated. No pull request is too small. Please help with:
|
324
|
+
|
325
|
+
* Reporting bugs
|
326
|
+
* Suggesting features
|
327
|
+
* Writing or improving documentation
|
328
|
+
* Fixing typos
|
329
|
+
* Cleaning whitespace
|
330
|
+
* Refactoring code
|
331
|
+
* Adding tests
|
332
|
+
* Closing [issues](https://github.com/collectiveidea/json_spec/issues)
|
333
|
+
|
334
|
+
If you report a bug and don't include a fix, please include a failing test.
|
326
335
|
|
327
336
|
Copyright
|
328
337
|
---------
|
338
|
+
|
329
339
|
Copyright © 2011 Steve Richert
|
330
|
-
|
340
|
+
|
341
|
+
See [LICENSE](https://github.com/collectiveidea/json_spec/blob/master/LICENSE) for details.
|
@@ -0,0 +1,89 @@
|
|
1
|
+
Feature: Files
|
2
|
+
Scenario: Equivalence from a file
|
3
|
+
Given the JSON is:
|
4
|
+
"""
|
5
|
+
{
|
6
|
+
"array": [
|
7
|
+
"json",
|
8
|
+
"spec"
|
9
|
+
],
|
10
|
+
"false": false,
|
11
|
+
"float": 10.0,
|
12
|
+
"hash": {
|
13
|
+
"json": "spec"
|
14
|
+
},
|
15
|
+
"created_at": "2011-07-08 02:27:34",
|
16
|
+
"empty_array": [
|
17
|
+
|
18
|
+
],
|
19
|
+
"empty_hash": {
|
20
|
+
},
|
21
|
+
"id": 1,
|
22
|
+
"integer": 10,
|
23
|
+
"negative": -10,
|
24
|
+
"null": null,
|
25
|
+
"string": "json_spec",
|
26
|
+
"true": true,
|
27
|
+
"updated_at": "2011-07-08 02:28:50"
|
28
|
+
}
|
29
|
+
"""
|
30
|
+
When I get the JSON
|
31
|
+
Then the JSON should be file "two.json"
|
32
|
+
|
33
|
+
Scenario: Inequivalence from a file
|
34
|
+
Given the JSON is:
|
35
|
+
"""
|
36
|
+
{
|
37
|
+
"string": "json_spec",
|
38
|
+
"true": true,
|
39
|
+
"updated_at": "2011-07-08 02:28:50"
|
40
|
+
}
|
41
|
+
"""
|
42
|
+
When I get the JSON
|
43
|
+
Then the JSON should not be file "two.json"
|
44
|
+
|
45
|
+
|
46
|
+
Scenario: Inclusion from a file
|
47
|
+
Given the JSON is:
|
48
|
+
"""
|
49
|
+
{
|
50
|
+
"array": [
|
51
|
+
"json",
|
52
|
+
"spec"
|
53
|
+
],
|
54
|
+
"created_at": "2011-07-08 02:27:34",
|
55
|
+
"empty_array": [
|
56
|
+
|
57
|
+
],
|
58
|
+
"empty_hash": {
|
59
|
+
},
|
60
|
+
"false": false,
|
61
|
+
"float": 10.0,
|
62
|
+
"hash": {
|
63
|
+
"json": "spec"
|
64
|
+
}
|
65
|
+
}
|
66
|
+
"""
|
67
|
+
When I get the JSON
|
68
|
+
Then the JSON should include file "project/version/two.json"
|
69
|
+
|
70
|
+
Scenario: Exclusion from a file
|
71
|
+
Given the JSON is:
|
72
|
+
"""
|
73
|
+
{
|
74
|
+
"array": [
|
75
|
+
"json",
|
76
|
+
"spec"
|
77
|
+
],
|
78
|
+
"created_at": "2011-07-08 02:27:34",
|
79
|
+
"empty_array": [
|
80
|
+
|
81
|
+
],
|
82
|
+
"empty_hash": {
|
83
|
+
},
|
84
|
+
"false": false,
|
85
|
+
"float": 10.0
|
86
|
+
}
|
87
|
+
"""
|
88
|
+
When I get the JSON
|
89
|
+
Then the JSON should not include file "project/version/two.json"
|
data/features/support/env.rb
CHANGED
data/features/types.feature
CHANGED
@@ -4,15 +4,21 @@ Feature: Types
|
|
4
4
|
"""
|
5
5
|
{
|
6
6
|
"array": [],
|
7
|
+
"false": true,
|
7
8
|
"float": 10.0,
|
8
9
|
"hash": {},
|
9
10
|
"integer": 10,
|
10
|
-
"string": "json_spec"
|
11
|
+
"string": "json_spec",
|
12
|
+
"true": true
|
11
13
|
}
|
12
14
|
"""
|
13
15
|
When I get the JSON
|
14
16
|
Then the JSON should be a hash
|
15
17
|
And the JSON at "array" should be an array
|
18
|
+
And the JSON at "false" should be a boolean
|
16
19
|
And the JSON at "float" should be a float
|
17
20
|
And the JSON at "hash" should be a hash
|
21
|
+
And the JSON at "hash" should be an object
|
18
22
|
And the JSON at "integer" should be an integer
|
23
|
+
And the JSON at "string" should be a string
|
24
|
+
And the JSON at "true" should be a boolean
|