Module: CcApiStub::Applications

Extended by:
Helper
Defined in:
lib/cc_api_stub/applications.rb

Class Method Summary collapse

Methods included from Helper

fail_request, fail_to_load, fail_to_load_many, fail_to_update, fail_with_error, find_fixture, fixture_prefix, host, host=, load_fixtures, object_class, object_name, response, response, stub_delete, stub_get, stub_post, stub_put, stub_request, succeed_to_create, succeed_to_delete, succeed_to_load, succeed_to_load_empty, succeed_to_load_many, succeed_to_update

Class Method Details

.fail_to_find(app_id) ⇒ Object



46
47
48
# File 'lib/cc_api_stub/applications.rb', line 46

def fail_to_find(app_id)
  stub_get(%r{/v2/apps/#{app_id}}, {}, response(404, {:code => 100004, :description => "The app name could not be found:"}))
end

.succeed_to_createObject



11
12
13
14
# File 'lib/cc_api_stub/applications.rb', line 11

def succeed_to_create
  response_body = Helper.load_fixtures("fake_cc_created_application")
  stub_post(%r{/v2/apps$}, nil, response(201, response_body))
end

.succeed_to_load(options = {}) ⇒ Object



6
7
8
9
# File 'lib/cc_api_stub/applications.rb', line 6

def succeed_to_load(options={})
  response_body = Helper.load_fixtures(options.delete(:fixture) || "fake_cc_#{object_name}", options)
  stub_get(object_endpoint(options[:id]), {}, response(200, response_body))
end

.succeed_to_load_service_bindingsObject



41
42
43
44
# File 'lib/cc_api_stub/applications.rb', line 41

def succeed_to_load_service_bindings
  response_body = Helper.load_fixtures("fake_cc_service_bindings")
  stub_get(%r{/v2/apps/[^/]+/service_bindings/?(?:\?.+)?$}, {}, response(200, response_body))
end

.succeed_to_load_statsObject



25
26
27
28
# File 'lib/cc_api_stub/applications.rb', line 25

def succeed_to_load_stats
  response_body = Helper.load_fixtures("fake_cc_stats")
  stub_get(%r{/v2/apps/[^/]+/stats$}, {}, response(200, response_body))
end

.succeed_to_load_summary(options = {}) ⇒ Object



34
35
36
37
38
39
# File 'lib/cc_api_stub/applications.rb', line 34

def succeed_to_load_summary(options={})
  response = summary_fixture
  response["state"] = options[:state] if options.has_key?(:state)
  response["routes"] = options[:routes] if options.has_key?(:routes)
  stub_get(%r{/v2/apps/[^/]+/summary$}, {}, response(200, response))
end

.succeed_to_map_routeObject



21
22
23
# File 'lib/cc_api_stub/applications.rb', line 21

def succeed_to_map_route
  stub_put(%r{/v2/apps/[^/]+/routes/[^/]+$}, {}, response(201, {}))
end

.succeed_to_update(options = {}) ⇒ Object



16
17
18
19
# File 'lib/cc_api_stub/applications.rb', line 16

def succeed_to_update(options={})
  response_body = Helper.load_fixtures(:fake_cc_application, options)
  stub_put(object_endpoint(options[:id]), nil, response(200, response_body))
end

.summary_fixtureObject



30
31
32
# File 'lib/cc_api_stub/applications.rb', line 30

def summary_fixture
  Helper.load_fixtures("fake_cc_application_summary")
end