Sha256: 3c65e20eafb196e3efa428126b60f651c92bb626195ac8f6e03667155009a86f

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'rubygems'
require 'test/unit'
require 'shoulda'
require 'fakeweb'

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'madmimi'

class Test::Unit::TestCase
end

def fixture_file(filename)
  return '' if filename == ''
  file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
  File.read(file_path)
end

def madmimi_url(url, https = false)
  if https
    url =~ /^https/ ? url : "https://api.madmimi.com#{url}"
  else
    url =~ /^http/ ? url : "http://api.madmimi.com#{url}"
  end
end

def stub_get(url, options = {})
  https = options.delete(:https)
  
  filename = options.delete(:filename)
  options = { :body => fixture_file(filename) } if filename
  
  FakeWeb.register_uri(:get, madmimi_url(url, https), options)
end

def stub_post(url, options)
  https = options.delete(:https)
  
  filename = options.delete(:filename)
  options = { :body => fixture_file(filename) } if filename
  
  FakeWeb.register_uri(:post, madmimi_url(url, https), options)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
madmimi-1.0.16 test/helper.rb
madmimi-1.0.15 test/helper.rb