module DoSnapshot::RSpec::ApiV2Helpers
Public Instance Methods
stub_droplet(id)
click to toggle source
Droplet data
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 38 def stub_droplet(id) stub_with_id(droplet_find_uri, id, 'v2/show_droplet') end
stub_droplet_fail(id)
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 42 def stub_droplet_fail(id) stub_with_id(droplet_find_uri, id, 'v2/error_message') end
stub_droplet_inactive(id)
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 46 def stub_droplet_inactive(id) stub_with_id(droplet_find_uri, id, 'v2/show_droplet_inactive') end
stub_droplet_snapshot(id, name)
click to toggle source
Snapshot
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 87 def stub_droplet_snapshot(id, name) stub_with_id_name(snapshot_uri, id, name, 'v2/response_event', :post, type: 'snapshot', name: name ) end
stub_droplet_snapshot_fail(id, name)
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 94 def stub_droplet_snapshot_fail(id, name) stub_with_id_name(snapshot_uri, id, name, 'v2/error_message', :post, { type: 'snapshot', name: name }, 404 ) end
stub_droplet_start(id)
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 67 def stub_droplet_start(id) stub_with_id(droplet_start_uri, id, 'v2/show_event_power_on_start', :post, type: 'power_on' ) end
stub_droplet_start_done(id)
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 73 def stub_droplet_start_done(id) stub_with_id(droplet_start_uri, id, 'v2/show_event_power_on_done', :post, type: 'power_on' ) end
stub_droplet_start_fail(id)
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 79 def stub_droplet_start_fail(id) stub_with_id(droplet_start_uri, id, 'v2/error_message', :post, type: 'power_on' ) end
stub_droplet_stop(id)
click to toggle source
Droplet actions
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 52 def stub_droplet_stop(id) stub_with_id(droplet_stop_uri, id, 'v2/show_event_power_off_start', :post, type: 'power_off' ) end
stub_droplet_stop_fail(id)
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 58 def stub_droplet_stop_fail(id) stub_with_id(droplet_stop_uri, id, 'v2/error_message', :post, { type: 'power_off' }, 404 ) end
stub_droplets()
click to toggle source
List of droplets
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 24 def stub_droplets stub_without_id(droplets_uri, 'v2/show_droplets') end
stub_droplets_empty()
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 28 def stub_droplets_empty stub_without_id(droplets_uri, 'v2/show_droplets_empty') end
stub_droplets_fail()
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 32 def stub_droplets_fail stub_without_id(droplets_uri, 'v2/error_message') end
stub_event_done(id)
click to toggle source
Event status
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 106 def stub_event_done(id) stub_with_id(action_find_uri, id, 'v2/show_event_done') end
stub_event_fail(id)
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 110 def stub_event_fail(id) stub_with_id(action_find_uri, id, 'v2/error_message') end
stub_event_running(id)
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 114 def stub_event_running(id) stub_with_id(action_find_uri, id, 'v2/show_event_start') end
stub_image_destroy(id)
click to toggle source
Image actions
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 120 def stub_image_destroy(id) stub_with_id(image_destroy_uri, id, 'v2/empty', :delete, nil, 204) end
stub_image_destroy_fail(id)
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 124 def stub_image_destroy_fail(id) stub_with_id(image_destroy_uri, id, 'v2/error_message', :delete, nil, 404) end
stub_request_body(type, request, body)
click to toggle source
Body Helpers
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 150 def stub_request_body(type, request, body) stub_response = stub_request(type, request).with(headers: { 'Authorization' => api_access_token }) return stub_response.with(body: body) if body stub_response end
stub_with_id(request, id, fixture, type = :get, body = nil, status = 200)
click to toggle source
Stub helpers
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 130 def stub_with_id(request, id, fixture, type = :get, body = nil, status = 200) # rubocop:disable Metrics/ParameterLists return unless request && fixture && id stub_request_body(type, url_with_id(request, id), body) .to_return(status: status, body: fixture(fixture)) end
stub_with_id_name(request, id, name, fixture, type = :get, body = nil, status = 200)
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 142 def stub_with_id_name(request, id, name, fixture, type = :get, body = nil, status = 200) # rubocop:disable Metrics/ParameterLists return unless request && fixture && id && name stub_request_body(type, url_with_id_name(request, id, name), body) .to_return(status: status, body: fixture(fixture)) end
stub_without_id(request, fixture, type = :get, body = nil, status = 200)
click to toggle source
# File lib/do_snapshot/rspec/api_v2_helpers.rb, line 136 def stub_without_id(request, fixture, type = :get, body = nil, status = 200) return unless request && fixture stub_request_body(type, request, body) .to_return(status: status, body: fixture(fixture)) end