jsontest 1.0.0
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 +7 -0
- data/.gitignore +4 -0
- data/.travis.yml +21 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +20 -0
- data/README.md +343 -0
- data/Rakefile +18 -0
- data/features/equivalence.feature +286 -0
- data/features/files.feature +89 -0
- data/features/inclusion.feature +154 -0
- data/features/memory.feature +221 -0
- data/features/paths.feature +74 -0
- data/features/sizes.feature +38 -0
- data/features/step_definitions/steps.rb +7 -0
- data/features/support/env.rb +9 -0
- data/features/types.feature +24 -0
- data/gemfiles/rspec2.gemfile +10 -0
- data/gemfiles/rspec3.gemfile +10 -0
- data/jsontest.gemspec +22 -0
- data/lib/jsontest.rb +14 -0
- data/lib/jsontest/configuration.rb +30 -0
- data/lib/jsontest/cucumber.rb +95 -0
- data/lib/jsontest/errors.rb +46 -0
- data/lib/jsontest/exclusion.rb +26 -0
- data/lib/jsontest/helpers.rb +62 -0
- data/lib/jsontest/matchers.rb +33 -0
- data/lib/jsontest/matchers/be_json_eql.rb +66 -0
- data/lib/jsontest/matchers/have_json_path.rb +32 -0
- data/lib/jsontest/matchers/have_json_size.rb +39 -0
- data/lib/jsontest/matchers/have_json_type.rb +52 -0
- data/lib/jsontest/matchers/include_json.rb +63 -0
- data/lib/jsontest/memory.rb +19 -0
- data/lib/jsontest/messages.rb +8 -0
- data/spec/jsontest/configuration_spec.rb +62 -0
- data/spec/jsontest/helpers_spec.rb +111 -0
- data/spec/jsontest/matchers/be_json_eql_spec.rb +111 -0
- data/spec/jsontest/matchers/have_json_path_spec.rb +29 -0
- data/spec/jsontest/matchers/have_json_size_spec.rb +61 -0
- data/spec/jsontest/matchers/have_json_type_spec.rb +92 -0
- data/spec/jsontest/matchers/include_json_spec.rb +96 -0
- data/spec/jsontest/matchers_spec.rb +77 -0
- data/spec/jsontest/memory_spec.rb +32 -0
- data/spec/spec_helper.rb +23 -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 +182 -0
@@ -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": "jsontest",
|
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": "jsontest",
|
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"
|
@@ -0,0 +1,154 @@
|
|
1
|
+
Feature: Inclusion
|
2
|
+
Background:
|
3
|
+
Given the JSON is:
|
4
|
+
"""
|
5
|
+
{
|
6
|
+
"array": [
|
7
|
+
"json",
|
8
|
+
"spec"
|
9
|
+
],
|
10
|
+
"created_at": "2011-07-08 02:27:34",
|
11
|
+
"empty_array": [
|
12
|
+
|
13
|
+
],
|
14
|
+
"empty_hash": {
|
15
|
+
},
|
16
|
+
"false": false,
|
17
|
+
"float": 10.0,
|
18
|
+
"hash": {
|
19
|
+
"json": "spec"
|
20
|
+
},
|
21
|
+
"id": 1,
|
22
|
+
"integer": 10,
|
23
|
+
"negative": -10,
|
24
|
+
"null": null,
|
25
|
+
"string": "jsontest",
|
26
|
+
"true": true,
|
27
|
+
"updated_at": "2011-07-08 02:28:50",
|
28
|
+
"nested": {
|
29
|
+
"id": 2,
|
30
|
+
"key": "value"
|
31
|
+
}
|
32
|
+
}
|
33
|
+
"""
|
34
|
+
|
35
|
+
Scenario: String
|
36
|
+
When I get the JSON
|
37
|
+
Then the JSON should include "jsontest"
|
38
|
+
And the JSON should include:
|
39
|
+
"""
|
40
|
+
"jsontest"
|
41
|
+
"""
|
42
|
+
|
43
|
+
Scenario: Integer
|
44
|
+
When I get the JSON
|
45
|
+
Then the JSON should include 10
|
46
|
+
And the JSON should include:
|
47
|
+
"""
|
48
|
+
10
|
49
|
+
"""
|
50
|
+
|
51
|
+
Scenario: Negative integer
|
52
|
+
When I get the JSON
|
53
|
+
Then the JSON should include -10
|
54
|
+
And the JSON should include:
|
55
|
+
"""
|
56
|
+
-10
|
57
|
+
"""
|
58
|
+
|
59
|
+
Scenario: Float
|
60
|
+
When I get the JSON
|
61
|
+
Then the JSON should include 10.0
|
62
|
+
And the JSON should include 10.0e0
|
63
|
+
And the JSON should include 10.0e+0
|
64
|
+
And the JSON should include 10.0e-0
|
65
|
+
And the JSON should include 10e0
|
66
|
+
And the JSON should include 10e+0
|
67
|
+
And the JSON should include 10e-0
|
68
|
+
And the JSON should include 1.0e1
|
69
|
+
And the JSON should include 1.0e+1
|
70
|
+
And the JSON should include 1e1
|
71
|
+
And the JSON should include 1e+1
|
72
|
+
And the JSON should include 100.0e-1
|
73
|
+
And the JSON should include 100e-1
|
74
|
+
And the JSON should include:
|
75
|
+
"""
|
76
|
+
10.0
|
77
|
+
"""
|
78
|
+
|
79
|
+
Scenario: Array
|
80
|
+
When I get the JSON
|
81
|
+
Then the JSON should include ["json","spec"]
|
82
|
+
And the JSON at "array" should include "json"
|
83
|
+
And the JSON at "array" should include "spec"
|
84
|
+
And the JSON should include:
|
85
|
+
"""
|
86
|
+
[
|
87
|
+
"json",
|
88
|
+
"spec"
|
89
|
+
]
|
90
|
+
"""
|
91
|
+
|
92
|
+
Scenario: Empty array
|
93
|
+
When I get the JSON
|
94
|
+
Then the JSON should include []
|
95
|
+
And the JSON should include:
|
96
|
+
"""
|
97
|
+
[
|
98
|
+
|
99
|
+
]
|
100
|
+
"""
|
101
|
+
|
102
|
+
Scenario: Hash
|
103
|
+
When I get the JSON
|
104
|
+
Then the JSON should include {"json":"spec"}
|
105
|
+
And the JSON at "hash" should include "spec"
|
106
|
+
And the JSON should include:
|
107
|
+
"""
|
108
|
+
{
|
109
|
+
"json": "spec"
|
110
|
+
}
|
111
|
+
"""
|
112
|
+
|
113
|
+
Scenario: Empty hash
|
114
|
+
When I get the JSON
|
115
|
+
Then the JSON should include {}
|
116
|
+
And the JSON should include:
|
117
|
+
"""
|
118
|
+
{
|
119
|
+
}
|
120
|
+
"""
|
121
|
+
|
122
|
+
Scenario: True
|
123
|
+
When I get the JSON
|
124
|
+
Then the JSON should include true
|
125
|
+
And the JSON should include:
|
126
|
+
"""
|
127
|
+
true
|
128
|
+
"""
|
129
|
+
|
130
|
+
Scenario: False
|
131
|
+
When I get the JSON
|
132
|
+
Then the JSON should include false
|
133
|
+
And the JSON should include:
|
134
|
+
"""
|
135
|
+
false
|
136
|
+
"""
|
137
|
+
|
138
|
+
Scenario: Null
|
139
|
+
When I get the JSON
|
140
|
+
Then the JSON should include null
|
141
|
+
And the JSON should include:
|
142
|
+
"""
|
143
|
+
null
|
144
|
+
"""
|
145
|
+
|
146
|
+
Scenario: Excluded value
|
147
|
+
When I get the JSON
|
148
|
+
Then the JSON should include "2011-07-08 02:27:34"
|
149
|
+
And the JSON should include 1
|
150
|
+
And the JSON should include "2011-07-08 02:28:50"
|
151
|
+
|
152
|
+
Scenario: Nested exclusions
|
153
|
+
When I get the JSON
|
154
|
+
Then the JSON should include {"key":"value"}
|
@@ -0,0 +1,221 @@
|
|
1
|
+
Feature: Memory
|
2
|
+
Background:
|
3
|
+
Given the JSON is:
|
4
|
+
"""
|
5
|
+
{
|
6
|
+
"array": [
|
7
|
+
|
8
|
+
],
|
9
|
+
"false": false,
|
10
|
+
"float": 10.0,
|
11
|
+
"hash": {
|
12
|
+
},
|
13
|
+
"integer": 10,
|
14
|
+
"null": null,
|
15
|
+
"string": "jsontest",
|
16
|
+
"true": true
|
17
|
+
}
|
18
|
+
"""
|
19
|
+
And I get the JSON
|
20
|
+
|
21
|
+
Scenario: Entire JSON
|
22
|
+
When I keep the JSON as "JSON"
|
23
|
+
Then the JSON should be %{JSON}
|
24
|
+
And the JSON should be:
|
25
|
+
"""
|
26
|
+
%{JSON}
|
27
|
+
"""
|
28
|
+
|
29
|
+
Scenario: String
|
30
|
+
When I keep the JSON at "string" as "STRING"
|
31
|
+
Then the JSON at "string" should be %{STRING}
|
32
|
+
And the JSON should be:
|
33
|
+
"""
|
34
|
+
{
|
35
|
+
"array": [
|
36
|
+
|
37
|
+
],
|
38
|
+
"false": false,
|
39
|
+
"float": 10.0,
|
40
|
+
"hash": {
|
41
|
+
},
|
42
|
+
"integer": 10,
|
43
|
+
"null": null,
|
44
|
+
"string": %{STRING},
|
45
|
+
"true": true
|
46
|
+
}
|
47
|
+
"""
|
48
|
+
|
49
|
+
Scenario: Integer
|
50
|
+
When I keep the JSON at "integer" as "INTEGER"
|
51
|
+
Then the JSON at "integer" should be %{INTEGER}
|
52
|
+
And the JSON should be:
|
53
|
+
"""
|
54
|
+
{
|
55
|
+
"array": [
|
56
|
+
|
57
|
+
],
|
58
|
+
"false": false,
|
59
|
+
"float": 10.0,
|
60
|
+
"hash": {
|
61
|
+
},
|
62
|
+
"integer": %{INTEGER},
|
63
|
+
"null": null,
|
64
|
+
"string": "jsontest",
|
65
|
+
"true": true
|
66
|
+
}
|
67
|
+
"""
|
68
|
+
|
69
|
+
Scenario: Float
|
70
|
+
When I keep the JSON at "float" as "FLOAT"
|
71
|
+
Then the JSON at "float" should be %{FLOAT}
|
72
|
+
And the JSON should be:
|
73
|
+
"""
|
74
|
+
{
|
75
|
+
"array": [
|
76
|
+
|
77
|
+
],
|
78
|
+
"false": false,
|
79
|
+
"float": %{FLOAT},
|
80
|
+
"hash": {
|
81
|
+
},
|
82
|
+
"integer": 10,
|
83
|
+
"null": null,
|
84
|
+
"string": "jsontest",
|
85
|
+
"true": true
|
86
|
+
}
|
87
|
+
"""
|
88
|
+
|
89
|
+
Scenario: Array
|
90
|
+
When I keep the JSON at "array" as "ARRAY"
|
91
|
+
Then the JSON at "array" should be %{ARRAY}
|
92
|
+
And the JSON should be:
|
93
|
+
"""
|
94
|
+
{
|
95
|
+
"array": %{ARRAY},
|
96
|
+
"false": false,
|
97
|
+
"float": 10.0,
|
98
|
+
"hash": {
|
99
|
+
},
|
100
|
+
"integer": 10,
|
101
|
+
"null": null,
|
102
|
+
"string": "jsontest",
|
103
|
+
"true": true
|
104
|
+
}
|
105
|
+
"""
|
106
|
+
|
107
|
+
Scenario: Hash
|
108
|
+
When I keep the JSON at "hash" as "HASH"
|
109
|
+
Then the JSON at "hash" should be %{HASH}
|
110
|
+
And the JSON should be:
|
111
|
+
"""
|
112
|
+
{
|
113
|
+
"array": [
|
114
|
+
|
115
|
+
],
|
116
|
+
"false": false,
|
117
|
+
"float": 10.0,
|
118
|
+
"hash": %{HASH},
|
119
|
+
"integer": 10,
|
120
|
+
"null": null,
|
121
|
+
"string": "jsontest",
|
122
|
+
"true": true
|
123
|
+
}
|
124
|
+
"""
|
125
|
+
|
126
|
+
Scenario: True
|
127
|
+
When I keep the JSON at "true" as "TRUE"
|
128
|
+
Then the JSON at "true" should be %{TRUE}
|
129
|
+
And the JSON should be:
|
130
|
+
"""
|
131
|
+
{
|
132
|
+
"array": [
|
133
|
+
|
134
|
+
],
|
135
|
+
"false": false,
|
136
|
+
"float": 10.0,
|
137
|
+
"hash": {
|
138
|
+
},
|
139
|
+
"integer": 10,
|
140
|
+
"null": null,
|
141
|
+
"string": "jsontest",
|
142
|
+
"true": %{TRUE}
|
143
|
+
}
|
144
|
+
"""
|
145
|
+
|
146
|
+
Scenario: False
|
147
|
+
When I keep the JSON at "false" as "FALSE"
|
148
|
+
Then the JSON at "false" should be %{FALSE}
|
149
|
+
And the JSON should be:
|
150
|
+
"""
|
151
|
+
{
|
152
|
+
"array": [
|
153
|
+
|
154
|
+
],
|
155
|
+
"false": %{FALSE},
|
156
|
+
"float": 10.0,
|
157
|
+
"hash": {
|
158
|
+
},
|
159
|
+
"integer": 10,
|
160
|
+
"null": null,
|
161
|
+
"string": "jsontest",
|
162
|
+
"true": true
|
163
|
+
}
|
164
|
+
"""
|
165
|
+
|
166
|
+
Scenario: Null
|
167
|
+
When I keep the JSON at "null" as "NULL"
|
168
|
+
Then the JSON at "null" should be %{NULL}
|
169
|
+
And the JSON should be:
|
170
|
+
"""
|
171
|
+
{
|
172
|
+
"array": [
|
173
|
+
|
174
|
+
],
|
175
|
+
"false": false,
|
176
|
+
"float": 10.0,
|
177
|
+
"hash": {
|
178
|
+
},
|
179
|
+
"integer": 10,
|
180
|
+
"null": %{NULL},
|
181
|
+
"string": "jsontest",
|
182
|
+
"true": true
|
183
|
+
}
|
184
|
+
"""
|
185
|
+
|
186
|
+
Scenario: Table format
|
187
|
+
When I keep the JSON at "string" as "STRING"
|
188
|
+
And I keep the JSON at "integer" as "INTEGER"
|
189
|
+
And I keep the JSON at "float" as "FLOAT"
|
190
|
+
And I keep the JSON at "array" as "ARRAY"
|
191
|
+
And I keep the JSON at "hash" as "HASH"
|
192
|
+
And I keep the JSON at "true" as "TRUE"
|
193
|
+
And I keep the JSON at "false" as "FALSE"
|
194
|
+
And I keep the JSON at "null" as "NULL"
|
195
|
+
Then the JSON should have the following:
|
196
|
+
| string | %{STRING} |
|
197
|
+
| integer | %{INTEGER} |
|
198
|
+
| float | %{FLOAT} |
|
199
|
+
| array | %{ARRAY} |
|
200
|
+
| hash | %{HASH} |
|
201
|
+
| true | %{TRUE} |
|
202
|
+
| false | %{FALSE} |
|
203
|
+
| null | %{NULL} |
|
204
|
+
|
205
|
+
Scenario: Inclusion
|
206
|
+
When I keep the JSON at "string" as "STRING"
|
207
|
+
And I keep the JSON at "integer" as "INTEGER"
|
208
|
+
And I keep the JSON at "float" as "FLOAT"
|
209
|
+
And I keep the JSON at "array" as "ARRAY"
|
210
|
+
And I keep the JSON at "hash" as "HASH"
|
211
|
+
And I keep the JSON at "true" as "TRUE"
|
212
|
+
And I keep the JSON at "false" as "FALSE"
|
213
|
+
And I keep the JSON at "null" as "NULL"
|
214
|
+
Then the JSON should include %{STRING}
|
215
|
+
And the JSON should include %{INTEGER}
|
216
|
+
And the JSON should include %{FLOAT}
|
217
|
+
And the JSON should include %{ARRAY}
|
218
|
+
And the JSON should include %{HASH}
|
219
|
+
And the JSON should include %{TRUE}
|
220
|
+
And the JSON should include %{FALSE}
|
221
|
+
And the JSON should include %{NULL}
|