Skip to content

Commit

Permalink
Factor out response readers
Browse files Browse the repository at this point in the history
  • Loading branch information
purp committed Jun 22, 2011
1 parent 70ee1b1 commit 0a530f7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions spec/spec_helper.rb
Expand Up @@ -7,12 +7,20 @@

require 'fake_name_generator'

fixtures = File.dirname(File.expand_path(__FILE__)) + "/fixtures"
FIXTURES = File.dirname(File.expand_path(__FILE__)) + "/fixtures"

def valid_api_body
File.read("#{FIXTURES}/VALID_API_KEY.json")
end

def invalid_api_body
File.read("#{FIXTURES}/INVALID_API_KEY.xml")
end

FakeWeb.allow_net_connect = false

FakeWeb.register_uri(:get, %r[http://svc\.webservius\.com/v1/CorbanWork/fakename\?(.*&|)wsvKey=VALID_API_KEY]i, :body => File.read("#{fixtures}/VALID_API_KEY.json"), :content_type => 'text/json', :status => ['200', 'OK'])
FakeWeb.register_uri(:get, %r[http://svc\.webservius\.com/v1/CorbanWork/fakename\?(.*&|)wsvKey=INVALID_API_KEY]i, :body => File.read("#{fixtures}/INVALID_API_KEY.xml"), :content_type => 'application/xml', :status => ["403", "Forbidden"])
FakeWeb.register_uri(:get, %r[http://svc\.webservius\.com/v1/CorbanWork/fakename\?(.*&|)wsvKey=VALID_API_KEY]i, :body => valid_api_body, :content_type => 'text/json', :status => ['200', 'OK'])
FakeWeb.register_uri(:get, %r[http://svc\.webservius\.com/v1/CorbanWork/fakename\?(.*&|)wsvKey=INVALID_API_KEY]i, :body => invalid_api_body, :content_type => 'application/xml', :status => ["403", "Forbidden"])

RSpec.configure do |config|
end
Expand Down

0 comments on commit 0a530f7

Please sign in to comment.