Sha256: de7632248bfcf54e770fd5b5eae23e39368caedd973fe52a5f26e8f732770cd7
Contents?: true
Size: 1.6 KB
Versions: 4
Compression:
Stored size: 1.6 KB
Contents
require 'simplecov' SimpleCov.start if ENV["COVERAGE"] require File.expand_path('../../lib/right_api_client', __FILE__) require 'spec' require 'rest_client' Spec::Runner.configure do |config| config.mock_with :flexmock end module MockSpecHelper def mock_rest_client @api_version = RightApi::Client::API_VERSION @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, :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 => '1') 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 => '1') end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
right_api_client-1.5.4 | spec/spec_helper.rb |
right_api_client-1.5.3 | spec/spec_helper.rb |
right_api_client-1.5.2 | spec/spec_helper.rb |
right_api_client-1.5.1 | spec/spec_helper.rb |