Sha256: cd3d0981b8811609b10903836ec58d3bf924d1994f7080c07be5bff4cfb4dfc9

Contents?: true

Size: 786 Bytes

Versions: 4

Compression:

Stored size: 786 Bytes

Contents

$:.unshift File.expand_path("../..", __FILE__)

require 'simplecov'

SimpleCov.start do
  add_filter "spec/"
  add_filter ".bundle"
end

require 'goodreads'
require 'webmock'
require 'webmock/rspec'

def stub_get(path, params, fixture_name)
  params[:format] = 'xml'
  stub_request(:get, api_url(path)).
    with(:query => params).
    to_return(
      :status => 200,
      :body => fixture(fixture_name)
    )
end

def stub_with_key_get(path, params, fixture_name)
  params[:key] = 'SECRET_KEY'
  stub_get(path, params, fixture_name)
end

def fixture_path(file=nil)
  path = File.expand_path("../fixtures", __FILE__)
  file.nil? ? path : File.join(path, file)
end

def fixture(file)
  File.read(fixture_path(file))
end

def api_url(path)
  "#{Goodreads::Request::API_URL}#{path}"
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
goodreads-0.4.3 spec/spec_helper.rb
goodreads-0.4.2 spec/spec_helper.rb
goodreads-0.4.1 spec/spec_helper.rb
goodreads-0.4.0 spec/spec_helper.rb