Skip to content

Instantly share code, notes, and snippets.

# Specify gems that this application depends on in test env and have them installed with rake gems:install RAILS_ENV="test"
config.gem "fakeweb"
config.gem "shoulda"
context "logged in user" do
setup do
@user_resp = load_xml_fixture_file('user')
FakeWeb.register_uri(:get, "http://api.sample.com/users/123.xml", :body => @user_resp, :status => ["200", "OK"])
end
should "be able to retrieve user object with given id" do
user = User.find(123)
assert_equal 123, user.id
assert_equal "test@example.com", user.email
require 'test_helper'
require 'fakeweb'
require 'shoulda'
class UserTest < ActiveSupport::TestCase
def setup
FakeWeb.allow_net_connect = false
end
# Add more helper methods to be used by all tests here...
def load_xml_fixture_file(name)
path = RAILS_ROOT + "/test/fixtures/#{name}.xml"
if File.exists?(path)
contents = ""
File.open(path).each do |line|
contents << line
end
return contents
else
require 'rubygems'
require 'abebooks4r'
Abebooks4r::Abe.configure do |options|
options[:clientkey] = ABE_ACCESS_KEY
end
Abebooks4r::Abe.debug = true
res = Abebooks4r::Abe.search(:author => 'Brad Ediger', :title => 'Advanced Rails')