Module: RHC::Rest::Mock
- Defined in:
- lib/rhc/rest/mock.rb
Defined Under Namespace
Modules: Helpers Classes: MockRestActivation, MockRestAlias, MockRestApi, MockRestApplication, MockRestCartridge, MockRestClient, MockRestDeployment, MockRestDomain, MockRestGearGroup, MockRestKey, MockRestTeam, MockRestUser
Class Method Summary collapse
Class Method Details
.start ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rhc/rest/mock.rb', line 3 def self.start RHC::Helpers.warn "Running in mock mode" require 'webmock' WebMock.disable_net_connect! MockRestClient.class_eval do include WebMock::API include Helpers def user_agent_header end def user_auth {:user => nil, :password => nil} end end MockRestUser.class_eval do def add_key(*args) attributes['links'] ||= {} links['ADD_KEY'] = {'href' => 'https://test.domain.com/broker/rest/user/keys', 'method' => 'POST'} super end end MockRestClient.new.tap do |c| d = c.add_domain("test1") app = d.add_application('app1', 'carttype1') app.cartridges[0].display_name = "A display name" app.add_cartridge('mockcart2') app2 = d.add_application('app2', 'carttype2', true) c.stub_add_key_error('test', 'this failed') end end |