api_matchers 0.6.2 → 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.
Files changed (116) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +30 -0
  3. data/.gitignore +1 -0
  4. data/Gemfile +1 -1
  5. data/History.markdown +62 -50
  6. data/README.markdown +1070 -114
  7. data/TODO.markdown +39 -3
  8. data/api_matchers.gemspec +13 -6
  9. data/lib/api_matchers/collection/base.rb +65 -0
  10. data/lib/api_matchers/collection/be_sorted_by.rb +97 -0
  11. data/lib/api_matchers/collection/have_json_size.rb +54 -0
  12. data/lib/api_matchers/core/exceptions.rb +5 -0
  13. data/lib/api_matchers/core/find_in_json.rb +57 -28
  14. data/lib/api_matchers/core/http_status_codes.rb +118 -0
  15. data/lib/api_matchers/core/json_path_finder.rb +87 -0
  16. data/lib/api_matchers/core/parser.rb +4 -2
  17. data/lib/api_matchers/core/rspec_matchers.rb +130 -37
  18. data/lib/api_matchers/core/setup.rb +49 -23
  19. data/lib/api_matchers/core/value_normalizer.rb +26 -0
  20. data/lib/api_matchers/error_response/base.rb +77 -0
  21. data/lib/api_matchers/error_response/have_error.rb +69 -0
  22. data/lib/api_matchers/error_response/have_error_on.rb +173 -0
  23. data/lib/api_matchers/hateoas/base.rb +77 -0
  24. data/lib/api_matchers/hateoas/have_link.rb +102 -0
  25. data/lib/api_matchers/headers/base.rb +7 -7
  26. data/lib/api_matchers/headers/be_json.rb +2 -4
  27. data/lib/api_matchers/headers/be_xml.rb +2 -4
  28. data/lib/api_matchers/headers/have_cache_control.rb +90 -0
  29. data/lib/api_matchers/headers/have_cors_headers.rb +102 -0
  30. data/lib/api_matchers/headers/have_header.rb +102 -0
  31. data/lib/api_matchers/http_status/base.rb +48 -0
  32. data/lib/api_matchers/http_status/be_client_error.rb +17 -0
  33. data/lib/api_matchers/http_status/be_forbidden.rb +17 -0
  34. data/lib/api_matchers/http_status/be_no_content.rb +17 -0
  35. data/lib/api_matchers/http_status/be_not_found.rb +17 -0
  36. data/lib/api_matchers/http_status/be_redirect.rb +17 -0
  37. data/lib/api_matchers/http_status/be_server_error.rb +17 -0
  38. data/lib/api_matchers/http_status/be_successful.rb +17 -0
  39. data/lib/api_matchers/http_status/be_unauthorized.rb +17 -0
  40. data/lib/api_matchers/http_status/be_unprocessable.rb +17 -0
  41. data/lib/api_matchers/http_status/have_http_status.rb +39 -0
  42. data/lib/api_matchers/json_api/base.rb +83 -0
  43. data/lib/api_matchers/json_api/be_json_api_compliant.rb +158 -0
  44. data/lib/api_matchers/json_api/have_json_api_attributes.rb +62 -0
  45. data/lib/api_matchers/json_api/have_json_api_data.rb +110 -0
  46. data/lib/api_matchers/json_api/have_json_api_relationships.rb +62 -0
  47. data/lib/api_matchers/json_structure/base.rb +65 -0
  48. data/lib/api_matchers/json_structure/have_json_keys.rb +55 -0
  49. data/lib/api_matchers/json_structure/have_json_type.rb +72 -0
  50. data/lib/api_matchers/pagination/base.rb +73 -0
  51. data/lib/api_matchers/pagination/be_paginated.rb +73 -0
  52. data/lib/api_matchers/pagination/have_pagination_links.rb +74 -0
  53. data/lib/api_matchers/pagination/have_total_count.rb +77 -0
  54. data/lib/api_matchers/response_body/base.rb +10 -9
  55. data/lib/api_matchers/response_body/have_json.rb +2 -4
  56. data/lib/api_matchers/response_body/have_json_node.rb +45 -1
  57. data/lib/api_matchers/response_body/have_node.rb +2 -0
  58. data/lib/api_matchers/response_body/have_xml_node.rb +13 -14
  59. data/lib/api_matchers/response_body/match_json_schema.rb +89 -0
  60. data/lib/api_matchers/version.rb +3 -1
  61. data/lib/api_matchers.rb +75 -14
  62. data/spec/api_matchers/collection/be_sorted_by_spec.rb +110 -0
  63. data/spec/api_matchers/collection/have_json_size_spec.rb +101 -0
  64. data/spec/api_matchers/error_response/have_error_on_spec.rb +123 -0
  65. data/spec/api_matchers/error_response/have_error_spec.rb +108 -0
  66. data/spec/api_matchers/hateoas/have_link_spec.rb +105 -0
  67. data/spec/api_matchers/headers/base_spec.rb +8 -3
  68. data/spec/api_matchers/headers/be_json_spec.rb +1 -1
  69. data/spec/api_matchers/headers/be_xml_spec.rb +1 -1
  70. data/spec/api_matchers/headers/have_cache_control_spec.rb +102 -0
  71. data/spec/api_matchers/headers/have_cors_headers_spec.rb +74 -0
  72. data/spec/api_matchers/headers/have_header_spec.rb +88 -0
  73. data/spec/api_matchers/http_status/be_client_error_spec.rb +53 -0
  74. data/spec/api_matchers/http_status/be_forbidden_spec.rb +33 -0
  75. data/spec/api_matchers/http_status/be_no_content_spec.rb +33 -0
  76. data/spec/api_matchers/http_status/be_not_found_spec.rb +39 -0
  77. data/spec/api_matchers/http_status/be_redirect_spec.rb +55 -0
  78. data/spec/api_matchers/http_status/be_server_error_spec.rb +49 -0
  79. data/spec/api_matchers/http_status/be_successful_spec.rb +78 -0
  80. data/spec/api_matchers/http_status/be_unauthorized_spec.rb +33 -0
  81. data/spec/api_matchers/http_status/be_unprocessable_spec.rb +39 -0
  82. data/spec/api_matchers/http_status/have_http_status_spec.rb +81 -0
  83. data/spec/api_matchers/json_api/be_json_api_compliant_spec.rb +109 -0
  84. data/spec/api_matchers/json_api/have_json_api_attributes_spec.rb +61 -0
  85. data/spec/api_matchers/json_api/have_json_api_data_spec.rb +95 -0
  86. data/spec/api_matchers/json_api/have_json_api_relationships_spec.rb +61 -0
  87. data/spec/api_matchers/json_structure/have_json_keys_spec.rb +81 -0
  88. data/spec/api_matchers/json_structure/have_json_type_spec.rb +134 -0
  89. data/spec/api_matchers/pagination/be_paginated_spec.rb +95 -0
  90. data/spec/api_matchers/pagination/have_pagination_links_spec.rb +80 -0
  91. data/spec/api_matchers/pagination/have_total_count_spec.rb +85 -0
  92. data/spec/api_matchers/response_body/base_spec.rb +15 -7
  93. data/spec/api_matchers/response_body/have_json_node_spec.rb +57 -0
  94. data/spec/api_matchers/response_body/match_json_schema_spec.rb +86 -0
  95. metadata +152 -47
  96. data/.rvmrc.example +0 -1
  97. data/.travis.yml +0 -12
  98. data/Gemfile.lock +0 -46
  99. data/lib/api_matchers/http_status_code/base.rb +0 -32
  100. data/lib/api_matchers/http_status_code/be_bad_request.rb +0 -25
  101. data/lib/api_matchers/http_status_code/be_forbidden.rb +0 -21
  102. data/lib/api_matchers/http_status_code/be_internal_server_error.rb +0 -25
  103. data/lib/api_matchers/http_status_code/be_not_found.rb +0 -25
  104. data/lib/api_matchers/http_status_code/be_ok.rb +0 -25
  105. data/lib/api_matchers/http_status_code/be_unauthorized.rb +0 -25
  106. data/lib/api_matchers/http_status_code/be_unprocessable_entity.rb +0 -25
  107. data/lib/api_matchers/http_status_code/create_resource.rb +0 -25
  108. data/spec/api_matchers/http_status_code/base_spec.rb +0 -12
  109. data/spec/api_matchers/http_status_code/be_bad_request_spec.rb +0 -49
  110. data/spec/api_matchers/http_status_code/be_forbidden_spec.rb +0 -49
  111. data/spec/api_matchers/http_status_code/be_internal_server_error_spec.rb +0 -49
  112. data/spec/api_matchers/http_status_code/be_not_found_spec.rb +0 -49
  113. data/spec/api_matchers/http_status_code/be_ok_spec.rb +0 -49
  114. data/spec/api_matchers/http_status_code/be_unauthorized_spec.rb +0 -49
  115. data/spec/api_matchers/http_status_code/be_unprocessable_entity_spec.rb +0 -27
  116. data/spec/api_matchers/http_status_code/create_resource_spec.rb +0 -49
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas D'Stefano
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-25 00:00:00.000000000 Z
11
+ date: 2026-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -16,55 +16,93 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '3.12'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '3.1'
29
+ version: '3.12'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: activesupport
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: 3.2.5
39
+ version: '7.0'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '9.0'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
47
  - - ">="
39
48
  - !ruby/object:Gem::Version
40
- version: 3.2.5
49
+ version: '7.0'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '9.0'
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: nokogiri
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
57
  - - ">="
46
58
  - !ruby/object:Gem::Version
47
- version: 1.5.2
59
+ version: '1.15'
48
60
  type: :runtime
49
61
  prerelease: false
50
62
  version_requirements: !ruby/object:Gem::Requirement
51
63
  requirements:
52
64
  - - ">="
53
65
  - !ruby/object:Gem::Version
54
- version: 1.5.2
55
- description: Collection of RSpec matchers for create your API.
66
+ version: '1.15'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rake
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '13.0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '13.0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: json_schemer
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '2.0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '2.0'
95
+ description: Collection of RSpec matchers for your API.
56
96
  email:
57
97
  - tomas_stefano@successoft.com
58
98
  executables: []
59
99
  extensions: []
60
100
  extra_rdoc_files: []
61
101
  files:
102
+ - ".github/workflows/ci.yml"
62
103
  - ".gitignore"
63
104
  - ".rspec"
64
- - ".rvmrc.example"
65
- - ".travis.yml"
66
105
  - Gemfile
67
- - Gemfile.lock
68
106
  - History.markdown
69
107
  - LICENSE
70
108
  - README.markdown
@@ -72,53 +110,102 @@ files:
72
110
  - TODO.markdown
73
111
  - api_matchers.gemspec
74
112
  - lib/api_matchers.rb
113
+ - lib/api_matchers/collection/base.rb
114
+ - lib/api_matchers/collection/be_sorted_by.rb
115
+ - lib/api_matchers/collection/have_json_size.rb
75
116
  - lib/api_matchers/core/exceptions.rb
76
117
  - lib/api_matchers/core/find_in_json.rb
118
+ - lib/api_matchers/core/http_status_codes.rb
119
+ - lib/api_matchers/core/json_path_finder.rb
77
120
  - lib/api_matchers/core/parser.rb
78
121
  - lib/api_matchers/core/rspec_matchers.rb
79
122
  - lib/api_matchers/core/setup.rb
123
+ - lib/api_matchers/core/value_normalizer.rb
124
+ - lib/api_matchers/error_response/base.rb
125
+ - lib/api_matchers/error_response/have_error.rb
126
+ - lib/api_matchers/error_response/have_error_on.rb
127
+ - lib/api_matchers/hateoas/base.rb
128
+ - lib/api_matchers/hateoas/have_link.rb
80
129
  - lib/api_matchers/headers/base.rb
81
130
  - lib/api_matchers/headers/be_json.rb
82
131
  - lib/api_matchers/headers/be_xml.rb
83
- - lib/api_matchers/http_status_code/base.rb
84
- - lib/api_matchers/http_status_code/be_bad_request.rb
85
- - lib/api_matchers/http_status_code/be_forbidden.rb
86
- - lib/api_matchers/http_status_code/be_internal_server_error.rb
87
- - lib/api_matchers/http_status_code/be_not_found.rb
88
- - lib/api_matchers/http_status_code/be_ok.rb
89
- - lib/api_matchers/http_status_code/be_unauthorized.rb
90
- - lib/api_matchers/http_status_code/be_unprocessable_entity.rb
91
- - lib/api_matchers/http_status_code/create_resource.rb
132
+ - lib/api_matchers/headers/have_cache_control.rb
133
+ - lib/api_matchers/headers/have_cors_headers.rb
134
+ - lib/api_matchers/headers/have_header.rb
135
+ - lib/api_matchers/http_status/base.rb
136
+ - lib/api_matchers/http_status/be_client_error.rb
137
+ - lib/api_matchers/http_status/be_forbidden.rb
138
+ - lib/api_matchers/http_status/be_no_content.rb
139
+ - lib/api_matchers/http_status/be_not_found.rb
140
+ - lib/api_matchers/http_status/be_redirect.rb
141
+ - lib/api_matchers/http_status/be_server_error.rb
142
+ - lib/api_matchers/http_status/be_successful.rb
143
+ - lib/api_matchers/http_status/be_unauthorized.rb
144
+ - lib/api_matchers/http_status/be_unprocessable.rb
145
+ - lib/api_matchers/http_status/have_http_status.rb
146
+ - lib/api_matchers/json_api/base.rb
147
+ - lib/api_matchers/json_api/be_json_api_compliant.rb
148
+ - lib/api_matchers/json_api/have_json_api_attributes.rb
149
+ - lib/api_matchers/json_api/have_json_api_data.rb
150
+ - lib/api_matchers/json_api/have_json_api_relationships.rb
151
+ - lib/api_matchers/json_structure/base.rb
152
+ - lib/api_matchers/json_structure/have_json_keys.rb
153
+ - lib/api_matchers/json_structure/have_json_type.rb
154
+ - lib/api_matchers/pagination/base.rb
155
+ - lib/api_matchers/pagination/be_paginated.rb
156
+ - lib/api_matchers/pagination/have_pagination_links.rb
157
+ - lib/api_matchers/pagination/have_total_count.rb
92
158
  - lib/api_matchers/response_body/base.rb
93
159
  - lib/api_matchers/response_body/have_json.rb
94
160
  - lib/api_matchers/response_body/have_json_node.rb
95
161
  - lib/api_matchers/response_body/have_node.rb
96
162
  - lib/api_matchers/response_body/have_xml_node.rb
163
+ - lib/api_matchers/response_body/match_json_schema.rb
97
164
  - lib/api_matchers/version.rb
165
+ - spec/api_matchers/collection/be_sorted_by_spec.rb
166
+ - spec/api_matchers/collection/have_json_size_spec.rb
98
167
  - spec/api_matchers/core/find_in_json_spec.rb
99
168
  - spec/api_matchers/core/setup_spec.rb
169
+ - spec/api_matchers/error_response/have_error_on_spec.rb
170
+ - spec/api_matchers/error_response/have_error_spec.rb
171
+ - spec/api_matchers/hateoas/have_link_spec.rb
100
172
  - spec/api_matchers/headers/base_spec.rb
101
173
  - spec/api_matchers/headers/be_json_spec.rb
102
174
  - spec/api_matchers/headers/be_xml_spec.rb
103
- - spec/api_matchers/http_status_code/base_spec.rb
104
- - spec/api_matchers/http_status_code/be_bad_request_spec.rb
105
- - spec/api_matchers/http_status_code/be_forbidden_spec.rb
106
- - spec/api_matchers/http_status_code/be_internal_server_error_spec.rb
107
- - spec/api_matchers/http_status_code/be_not_found_spec.rb
108
- - spec/api_matchers/http_status_code/be_ok_spec.rb
109
- - spec/api_matchers/http_status_code/be_unauthorized_spec.rb
110
- - spec/api_matchers/http_status_code/be_unprocessable_entity_spec.rb
111
- - spec/api_matchers/http_status_code/create_resource_spec.rb
175
+ - spec/api_matchers/headers/have_cache_control_spec.rb
176
+ - spec/api_matchers/headers/have_cors_headers_spec.rb
177
+ - spec/api_matchers/headers/have_header_spec.rb
178
+ - spec/api_matchers/http_status/be_client_error_spec.rb
179
+ - spec/api_matchers/http_status/be_forbidden_spec.rb
180
+ - spec/api_matchers/http_status/be_no_content_spec.rb
181
+ - spec/api_matchers/http_status/be_not_found_spec.rb
182
+ - spec/api_matchers/http_status/be_redirect_spec.rb
183
+ - spec/api_matchers/http_status/be_server_error_spec.rb
184
+ - spec/api_matchers/http_status/be_successful_spec.rb
185
+ - spec/api_matchers/http_status/be_unauthorized_spec.rb
186
+ - spec/api_matchers/http_status/be_unprocessable_spec.rb
187
+ - spec/api_matchers/http_status/have_http_status_spec.rb
188
+ - spec/api_matchers/json_api/be_json_api_compliant_spec.rb
189
+ - spec/api_matchers/json_api/have_json_api_attributes_spec.rb
190
+ - spec/api_matchers/json_api/have_json_api_data_spec.rb
191
+ - spec/api_matchers/json_api/have_json_api_relationships_spec.rb
192
+ - spec/api_matchers/json_structure/have_json_keys_spec.rb
193
+ - spec/api_matchers/json_structure/have_json_type_spec.rb
194
+ - spec/api_matchers/pagination/be_paginated_spec.rb
195
+ - spec/api_matchers/pagination/have_pagination_links_spec.rb
196
+ - spec/api_matchers/pagination/have_total_count_spec.rb
112
197
  - spec/api_matchers/response_body/base_spec.rb
113
198
  - spec/api_matchers/response_body/have_json_node_spec.rb
114
199
  - spec/api_matchers/response_body/have_json_spec.rb
115
200
  - spec/api_matchers/response_body/have_node_spec.rb
116
201
  - spec/api_matchers/response_body/have_xml_node_spec.rb
202
+ - spec/api_matchers/response_body/match_json_schema_spec.rb
117
203
  - spec/spec_helper.rb
118
204
  homepage: https://github.com/tomas-stefano/api_matchers
119
- licenses: []
205
+ licenses:
206
+ - MIT
120
207
  metadata: {}
121
- post_install_message:
208
+ post_install_message:
122
209
  rdoc_options: []
123
210
  require_paths:
124
211
  - lib
@@ -126,36 +213,54 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
213
  requirements:
127
214
  - - ">="
128
215
  - !ruby/object:Gem::Version
129
- version: '0'
216
+ version: '3.1'
130
217
  required_rubygems_version: !ruby/object:Gem::Requirement
131
218
  requirements:
132
219
  - - ">="
133
220
  - !ruby/object:Gem::Version
134
221
  version: '0'
135
222
  requirements: []
136
- rubyforge_project:
137
- rubygems_version: 2.4.5
138
- signing_key:
223
+ rubygems_version: 3.3.7
224
+ signing_key:
139
225
  specification_version: 4
140
- summary: Collection of RSpec matchers for create your API.
226
+ summary: Collection of RSpec matchers for your API.
141
227
  test_files:
228
+ - spec/api_matchers/collection/be_sorted_by_spec.rb
229
+ - spec/api_matchers/collection/have_json_size_spec.rb
142
230
  - spec/api_matchers/core/find_in_json_spec.rb
143
231
  - spec/api_matchers/core/setup_spec.rb
232
+ - spec/api_matchers/error_response/have_error_on_spec.rb
233
+ - spec/api_matchers/error_response/have_error_spec.rb
234
+ - spec/api_matchers/hateoas/have_link_spec.rb
144
235
  - spec/api_matchers/headers/base_spec.rb
145
236
  - spec/api_matchers/headers/be_json_spec.rb
146
237
  - spec/api_matchers/headers/be_xml_spec.rb
147
- - spec/api_matchers/http_status_code/base_spec.rb
148
- - spec/api_matchers/http_status_code/be_bad_request_spec.rb
149
- - spec/api_matchers/http_status_code/be_forbidden_spec.rb
150
- - spec/api_matchers/http_status_code/be_internal_server_error_spec.rb
151
- - spec/api_matchers/http_status_code/be_not_found_spec.rb
152
- - spec/api_matchers/http_status_code/be_ok_spec.rb
153
- - spec/api_matchers/http_status_code/be_unauthorized_spec.rb
154
- - spec/api_matchers/http_status_code/be_unprocessable_entity_spec.rb
155
- - spec/api_matchers/http_status_code/create_resource_spec.rb
238
+ - spec/api_matchers/headers/have_cache_control_spec.rb
239
+ - spec/api_matchers/headers/have_cors_headers_spec.rb
240
+ - spec/api_matchers/headers/have_header_spec.rb
241
+ - spec/api_matchers/http_status/be_client_error_spec.rb
242
+ - spec/api_matchers/http_status/be_forbidden_spec.rb
243
+ - spec/api_matchers/http_status/be_no_content_spec.rb
244
+ - spec/api_matchers/http_status/be_not_found_spec.rb
245
+ - spec/api_matchers/http_status/be_redirect_spec.rb
246
+ - spec/api_matchers/http_status/be_server_error_spec.rb
247
+ - spec/api_matchers/http_status/be_successful_spec.rb
248
+ - spec/api_matchers/http_status/be_unauthorized_spec.rb
249
+ - spec/api_matchers/http_status/be_unprocessable_spec.rb
250
+ - spec/api_matchers/http_status/have_http_status_spec.rb
251
+ - spec/api_matchers/json_api/be_json_api_compliant_spec.rb
252
+ - spec/api_matchers/json_api/have_json_api_attributes_spec.rb
253
+ - spec/api_matchers/json_api/have_json_api_data_spec.rb
254
+ - spec/api_matchers/json_api/have_json_api_relationships_spec.rb
255
+ - spec/api_matchers/json_structure/have_json_keys_spec.rb
256
+ - spec/api_matchers/json_structure/have_json_type_spec.rb
257
+ - spec/api_matchers/pagination/be_paginated_spec.rb
258
+ - spec/api_matchers/pagination/have_pagination_links_spec.rb
259
+ - spec/api_matchers/pagination/have_total_count_spec.rb
156
260
  - spec/api_matchers/response_body/base_spec.rb
157
261
  - spec/api_matchers/response_body/have_json_node_spec.rb
158
262
  - spec/api_matchers/response_body/have_json_spec.rb
159
263
  - spec/api_matchers/response_body/have_node_spec.rb
160
264
  - spec/api_matchers/response_body/have_xml_node_spec.rb
265
+ - spec/api_matchers/response_body/match_json_schema_spec.rb
161
266
  - spec/spec_helper.rb
data/.rvmrc.example DELETED
@@ -1 +0,0 @@
1
- rvm 1.9.2@api_matchers --create
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- language: ruby
2
- script:
3
- - bundle exec rspec spec
4
- rvm:
5
- - rbx-2
6
- - jruby-head
7
- - ruby-head
8
- - ruby
9
- - jruby
10
- - 2.1.2
11
- - 2.0.0
12
- - 1.9.3
data/Gemfile.lock DELETED
@@ -1,46 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- api_matchers (0.6.1)
5
- activesupport (>= 3.2.5)
6
- nokogiri (>= 1.5.2)
7
- rspec (>= 3.1)
8
-
9
- GEM
10
- remote: http://rubygems.org/
11
- specs:
12
- activesupport (4.2.2)
13
- i18n (~> 0.7)
14
- json (~> 1.7, >= 1.7.7)
15
- minitest (~> 5.1)
16
- thread_safe (~> 0.3, >= 0.3.4)
17
- tzinfo (~> 1.1)
18
- diff-lcs (1.2.5)
19
- i18n (0.7.0)
20
- json (1.8.3)
21
- mini_portile (0.6.2)
22
- minitest (5.7.0)
23
- nokogiri (1.6.6.2)
24
- mini_portile (~> 0.6.0)
25
- rspec (3.3.0)
26
- rspec-core (~> 3.3.0)
27
- rspec-expectations (~> 3.3.0)
28
- rspec-mocks (~> 3.3.0)
29
- rspec-core (3.3.0)
30
- rspec-support (~> 3.3.0)
31
- rspec-expectations (3.3.0)
32
- diff-lcs (>= 1.2.0, < 2.0)
33
- rspec-support (~> 3.3.0)
34
- rspec-mocks (3.3.0)
35
- diff-lcs (>= 1.2.0, < 2.0)
36
- rspec-support (~> 3.3.0)
37
- rspec-support (3.3.0)
38
- thread_safe (0.3.5)
39
- tzinfo (1.2.2)
40
- thread_safe (~> 0.1)
41
-
42
- PLATFORMS
43
- ruby
44
-
45
- DEPENDENCIES
46
- api_matchers!
@@ -1,32 +0,0 @@
1
- module APIMatchers
2
- module HTTPStatusCode
3
- class Base
4
- attr_reader :setup
5
-
6
- def initialize(setup)
7
- @setup = setup
8
- end
9
-
10
- # Matches the actual with the expected http status code
11
- #
12
- def matches?(actual)
13
- @http_status_code = find_http_status_code(actual)
14
- @http_status_code.equal?(expected_status_code)
15
- end
16
-
17
- def expected_status_code
18
- raise NotImplementedError, "not implemented on #{self}"
19
- end
20
-
21
- # If have some configuration about the method to call on actual that method will be called.
22
- #
23
- def find_http_status_code(actual)
24
- if @setup.http_status_method.present?
25
- actual.send(@setup.http_status_method)
26
- else
27
- actual
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,25 +0,0 @@
1
- module APIMatchers
2
- module HTTPStatusCode
3
- class BeBadRequest < Base
4
- def expected_status_code
5
- 400
6
- end
7
-
8
- def failure_message
9
- %Q{expected that '#{@http_status_code}' to be a Bad Request with the status '400'.}
10
- end
11
-
12
- def failure_message_when_negated
13
- %Q{expected that '#{@http_status_code}' to NOT be a Bad Request with the status '400'.}
14
- end
15
-
16
- def description
17
- "be a Bad Request with the status '400'"
18
- end
19
-
20
- # RSpec 2 compatibility:
21
- alias_method :failure_message_for_should, :failure_message
22
- alias_method :failure_message_for_should_not, :failure_message_when_negated
23
- end
24
- end
25
- end
@@ -1,21 +0,0 @@
1
- module APIMatchers
2
- module HTTPStatusCode
3
- class BeForbidden < Base
4
- def expected_status_code
5
- 403
6
- end
7
-
8
- def failure_message
9
- %Q{expected that '#{@http_status_code}' to be Forbidden with the status '403'.}
10
- end
11
-
12
- def failure_message_when_negated
13
- %Q{expected that '#{@http_status_code}' to NOT be Forbidden.}
14
- end
15
-
16
- # RSpec 2 compatibility:
17
- alias_method :failure_message_for_should, :failure_message
18
- alias_method :failure_message_for_should_not, :failure_message_when_negated
19
- end
20
- end
21
- end
@@ -1,25 +0,0 @@
1
- module APIMatchers
2
- module HTTPStatusCode
3
- class BeInternalServerError < Base
4
- def expected_status_code
5
- 500
6
- end
7
-
8
- def failure_message
9
- %Q{expected that '#{@http_status_code}' to be Internal Server Error with the status '500'.}
10
- end
11
-
12
- def failure_message_when_negated
13
- %Q{expected that '#{@http_status_code}' to NOT be Internal Server Error.}
14
- end
15
-
16
- def description
17
- "be Internal Server Error with the status '500'"
18
- end
19
-
20
- # RSpec 2 compatibility:
21
- alias_method :failure_message_for_should, :failure_message
22
- alias_method :failure_message_for_should_not, :failure_message_when_negated
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- module APIMatchers
2
- module HTTPStatusCode
3
- class BeNotFound < Base
4
- def expected_status_code
5
- 404
6
- end
7
-
8
- def failure_message
9
- %Q{expected that '#{@http_status_code}' to be Not Found with the status '404'.}
10
- end
11
-
12
- def failure_message_when_negated
13
- %Q{expected that '#{@http_status_code}' to NOT be Not Found with the status '404'.}
14
- end
15
-
16
- def description
17
- "be Not Found with the status '404'"
18
- end
19
-
20
- # RSpec 2 compatibility:
21
- alias_method :failure_message_for_should, :failure_message
22
- alias_method :failure_message_for_should_not, :failure_message_when_negated
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- module APIMatchers
2
- module HTTPStatusCode
3
- class BeOk < Base
4
- def expected_status_code
5
- 200
6
- end
7
-
8
- def failure_message
9
- %Q{expected that '#{@http_status_code}' to be ok with the status '200'.}
10
- end
11
-
12
- def failure_message_when_negated
13
- %Q{expected that '#{@http_status_code}' to NOT be ok with the status '200'.}
14
- end
15
-
16
- def description
17
- "be ok with the status '200'"
18
- end
19
-
20
- # RSpec 2 compatibility:
21
- alias_method :failure_message_for_should, :failure_message
22
- alias_method :failure_message_for_should_not, :failure_message_when_negated
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- module APIMatchers
2
- module HTTPStatusCode
3
- class BeUnauthorized < Base
4
- def expected_status_code
5
- 401
6
- end
7
-
8
- def failure_message
9
- %Q{expected that '#{@http_status_code}' to be Unauthorized with the status '401'.}
10
- end
11
-
12
- def failure_message_when_negated
13
- %Q{expected that '#{@http_status_code}' to NOT be Unauthorized.}
14
- end
15
-
16
- def description
17
- "be Unauthorized with the status '401'"
18
- end
19
-
20
- # RSpec 2 compatibility:
21
- alias_method :failure_message_for_should, :failure_message
22
- alias_method :failure_message_for_should_not, :failure_message_when_negated
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- module APIMatchers
2
- module HTTPStatusCode
3
- class BeUnprocessableEntity < Base
4
- def expected_status_code
5
- 422
6
- end
7
-
8
- def failure_message
9
- %Q{expected that '#{@http_status_code}' to be Unprocessable entity with the status '#{expected_status_code}'.}
10
- end
11
-
12
- def failure_message_when_negated
13
- %Q{expected that '#{@http_status_code}' to NOT be Unprocessable entity with the status '#{expected_status_code}'.}
14
- end
15
-
16
- def description
17
- "be Unprocessable entity with the status '422'"
18
- end
19
-
20
- # RSpec 2 compatibility:
21
- alias_method :failure_message_for_should, :failure_message
22
- alias_method :failure_message_for_should_not, :failure_message_when_negated
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- module APIMatchers
2
- module HTTPStatusCode
3
- class CreateResource < Base
4
- def expected_status_code
5
- 201
6
- end
7
-
8
- def failure_message
9
- %Q{expected that '#{@http_status_code}' to be Created Resource with the status '201'.}
10
- end
11
-
12
- def failure_message_when_negated
13
- %Q{expected that '#{@http_status_code}' to NOT be Created Resource.}
14
- end
15
-
16
- def description
17
- "be Created Resource with the status '201'"
18
- end
19
-
20
- # RSpec 2 compatibility:
21
- alias_method :failure_message_for_should, :failure_message
22
- alias_method :failure_message_for_should_not, :failure_message_when_negated
23
- end
24
- end
25
- end
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe APIMatchers::HTTPStatusCode::Base do
4
- let(:setup) { OpenStruct.new }
5
- subject { APIMatchers::HTTPStatusCode::Base.new(setup) }
6
-
7
- describe "#matches?" do
8
- it "should raise Not Implement Exception" do
9
- expect { subject.matches?(302) }.to raise_error(NotImplementedError, "not implemented on #{subject}")
10
- end
11
- end
12
- end
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe APIMatchers::HTTPStatusCode::BeBadRequest do
4
- describe "should be_bad_request" do
5
- it "should passes if the actual is equal to 400" do
6
- expect(400).to be_bad_request
7
- end
8
-
9
- it "should fails if the actual is not equal to 400" do
10
- expect {
11
- expect(401).to be_bad_request
12
- }.to fail_with(%Q{expected that '401' to be a Bad Request with the status '400'.})
13
- end
14
- end
15
-
16
- describe "should_not be_bad_request" do
17
- it "should passes if the actual is not equal to 400" do
18
- expect(401).not_to be_bad_request
19
- end
20
-
21
- it "should fail if the actual is equal to 400" do
22
- expect {
23
- expect(400).not_to be_bad_request
24
- }.to fail_with(%Q{expected that '400' to NOT be a Bad Request with the status '400'.})
25
- end
26
- end
27
-
28
- describe "with change configuration" do
29
- before do
30
- APIMatchers.setup { |config| config.http_status_method = :http_status }
31
- end
32
-
33
- after do
34
- APIMatchers.setup { |config| config.http_status_method = nil }
35
- end
36
-
37
- it "should pass if the actual.http_status is equal to 400" do
38
- response = OpenStruct.new(:http_status => 400)
39
- expect(response).to be_bad_request
40
- end
41
-
42
- it "should fail if the actual.http_status is not equal to 400" do
43
- response = OpenStruct.new(:http_status => 500)
44
- expect {
45
- expect(response).to be_bad_request
46
- }.to fail_with(%Q{expected that '500' to be a Bad Request with the status '400'.})
47
- end
48
- end
49
- end