Sha256: a660b6ec9fdbe70b03edd8f4dde08a927d572b5621b8798722f9a74802e41333

Contents?: true

Size: 614 Bytes

Versions: 2

Compression:

Stored size: 614 Bytes

Contents

module Fake
  @@base_url = "https://api.phaxio.com/v1"
  @@base_response_dir = "#{File.dirname(__FILE__)}/responses"

  def self.body(response)
    File.open(File.join(@@base_response_dir, "#{response.to_s}.json")).read
  end

  def self.content_type
    "application/json"
  end

  def self.register(action)
    FakeWeb.register_uri(:post, "#{@@base_url}/#{action.to_s}", body:body(action), content_type:content_type)
  end
end

# load all the fakeweb responses and register them by name/API call
Dir[File.dirname(__FILE__) + "/responses/*.json"].each do |file| 
  Fake.register(File.basename(file, ".*" ))
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phaxion-0.0.2 spec/support/fakeweb_urls.rb
phaxion-0.0.1 spec/support/fakeweb_urls.rb