Sha256: 8323d8e3ac1e36c871f4d19b9452545cc1b9f35f41fe0d5252dc6a4b04e3b76c
Contents?: true
Size: 1.37 KB
Versions: 30
Compression:
Stored size: 1.37 KB
Contents
module FixtureHelpers module InstanceMethods def stub_api_request(endpoint, options={}) options = { :method => :get, :status => 200, :api_version => Restforce.configuration.api_version }.merge(options) stub = stub_request(options[:method], %r{/services/data/v#{options[:api_version]}/#{endpoint}}) stub = stub.with(:body => options[:with_body]) if options[:with_body] && !RUBY_VERSION.match(/^1.8/) stub = stub.to_return(:status => options[:status], :body => fixture(options[:fixture]), :headers => { 'Content-Type' => 'application/json'}) if options[:fixture] stub end def stub_login_request(options={}) stub = stub_request(:post, "https://login.salesforce.com/services/oauth2/token") stub = stub.with(:body => options[:with_body]) if options[:with_body] && !RUBY_VERSION.match(/^1.8/) stub end def fixture(f) File.read(File.expand_path("../../fixtures/#{f}.yml", __FILE__)) end end module ClassMethods def requests(endpoint, options={}) before do (@requests ||= []) << stub_api_request(endpoint, options) end after do @requests.each { |request| expect(request).to have_been_requested } end end end end RSpec.configure do |config| config.include FixtureHelpers::InstanceMethods config.extend FixtureHelpers::ClassMethods end
Version data entries
30 entries across 30 versions & 2 rubygems