Sha256: 8829ebd0371bf3f64167d40c5357ea0db1ef4e4f9b8c6c3250ceaceb1a1866d0
Contents?: true
Size: 1.5 KB
Versions: 3
Compression:
Stored size: 1.5 KB
Contents
module MockSpecHelper def mock_rest_client @api_version = RightApi::Client::API_VERSION @test_account_id = '1' @rest_client = RestClient::Resource.new(RightApi::Client::DEFAULT_API_URL) flexmock(RestClient::Resource).should_receive(:new).and_return(@rest_client) @session = flexmock(:cookies => {}) @header = {'X_API_VERSION' => @api_version, 'X_ACCOUNT' => @test_account_id, :cookies => {}, :accept => :json} end def given_user_facing_client mock_rest_client flexmock(@rest_client).should_receive(:post).with( {'email' => 'email', 'password' => 'password', 'account_href' => '/api/accounts/1'}, {'X_API_VERSION' => @api_version}, Proc).and_return(@session) flexmock(@rest_client).should_receive(:get).with(@header, Proc).and_return(['', '{}']) @client = RightApi::Client.new(:email => 'email', :password => 'password', :account_id => @test_account_id) end def given_instance_facing_client mock_rest_client flexmock(@rest_client).should_receive(:post).with( {'instance_token' => 'instance_token', 'account_href' => '/api/accounts/1'}, {'X_API_VERSION' => @api_version}, Proc).and_return(@session) flexmock(@rest_client).should_receive(:get).with(@header, Proc).and_return(['', '{"links": [ { "href": "/api/clouds/1/instances/1", "rel": "self" }]}']) @client = RightApi::Client.new(:instance_token => 'instance_token', :account_id => @test_account_id) end end $config.include MockSpecHelper
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
right_api_client-1.5.15 | spec/support/mock_spec_helper.rb |
right_api_client-1.5.14 | spec/support/mock_spec_helper.rb |
right_api_client-1.5.13 | spec/support/mock_spec_helper.rb |