Sha256: 5862e5243410b56a73f31888812ddc3e09f80b2fff703e4e47c2fa08e1c2d0f6

Contents?: true

Size: 782 Bytes

Versions: 6

Compression:

Stored size: 782 Bytes

Contents

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

require 'simplecov'
SimpleCov.start do
  add_group 'Goodreads', 'lib/goodreads'
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

6 entries across 6 versions & 2 rubygems

Version Path
goodreads-0.3.0 spec/spec_helper.rb
goodreads_17up-0.2.2 spec/spec_helper.rb
goodreads-0.2.2 spec/spec_helper.rb
goodreads_17up-0.2.1 spec/spec_helper.rb
goodreads-0.2.1 spec/spec_helper.rb
goodreads-0.2.0 spec/spec_helper.rb