Module: ApiRspecta::ApiRequestsHelpers::JsonHelpers
- Defined in:
- lib/api_rspecta.rb
Instance Method Summary collapse
- #item_has_key(item, key) ⇒ Object
- #item_has_keys(item, keys) ⇒ Object
- #item_has_no_key(item, key) ⇒ Object
- #item_has_only_the_keys(item, the_keys) ⇒ Object
- #json ⇒ Object
- #json_has_key(key) ⇒ Object
- #json_has_keys(keys) ⇒ Object
- #json_has_no_key(key) ⇒ Object
- #print_json ⇒ Object
- #refresh_json ⇒ Object
Instance Method Details
#item_has_key(item, key) ⇒ Object
30 31 32 |
# File 'lib/api_rspecta.rb', line 30 def item_has_key(item, key) expect(item).to have_key(key.to_s) end |
#item_has_keys(item, keys) ⇒ Object
38 39 40 |
# File 'lib/api_rspecta.rb', line 38 def item_has_keys(item, keys) keys.each { |key| item_has_key(item, key) } end |
#item_has_no_key(item, key) ⇒ Object
34 35 36 |
# File 'lib/api_rspecta.rb', line 34 def item_has_no_key(item, key) expect(item).not_to have_key(key.to_s) end |
#item_has_only_the_keys(item, the_keys) ⇒ Object
42 43 44 45 |
# File 'lib/api_rspecta.rb', line 42 def item_has_only_the_keys(item, the_keys) expect(item.keys.count).to eq the_keys.count the_keys.each { |key| item_has_key(item, key) } end |
#json ⇒ Object
6 7 8 |
# File 'lib/api_rspecta.rb', line 6 def json @json ||= JSON.parse response.body end |
#json_has_key(key) ⇒ Object
18 19 20 |
# File 'lib/api_rspecta.rb', line 18 def json_has_key(key) item_has_key(json, key) end |
#json_has_keys(keys) ⇒ Object
22 23 24 |
# File 'lib/api_rspecta.rb', line 22 def json_has_keys(keys) item_has_keys(json, keys) end |
#json_has_no_key(key) ⇒ Object
26 27 28 |
# File 'lib/api_rspecta.rb', line 26 def json_has_no_key(key) item_has_no_key(json, key) end |
#print_json ⇒ Object
14 15 16 |
# File 'lib/api_rspecta.rb', line 14 def print_json puts JSON.pretty_generate(json) end |
#refresh_json ⇒ Object
10 11 12 |
# File 'lib/api_rspecta.rb', line 10 def refresh_json @json = JSON.parse response.body end |