Sha256: 9ef15ae0c8638b5f9398ce26c31dad34ae1897fe0f5ecb014bbd581ea26f128d
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
require 'rubygems' require 'test/unit' gem 'shoulda', ">= 2.10.2" gem 'fakeweb', ">= 1.2.6" gem 'multi_json', ">= 1.0.4" gem 'mocha', ">= 0.9.8" require 'shoulda' require 'fakeweb' require 'multi_json' require 'mocha' require 'ruby-prof' FakeWeb.allow_net_connect = false $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'vimeo' class Test::Unit::TestCase def setup FakeWeb.clean_registry end end def fixture_file(filename) return '' if filename == '' file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename) File.read(file_path) end def vimeo_base_url(url = "/") "http://vimeo.com#{url}" end def vimeo_url(url = "") vimeo_base_url("/api/v2#{url}") end def advanced_vimeo_url(url = "") vimeo_base_url("/api/rest/v2#{url}") end def stub_get(url, filename, status=nil) # FIXME: We have to specify content type, otherwise HTTParty will not parse the # body correctly. Is there any way we can get around this? Or is this a limitation # of using FakeWeb? options = { :body => fixture_file(filename), :content_type => 'application/json' } options.merge!({:status => status}) unless status.nil? FakeWeb.register_uri(:get, vimeo_url(url), options) end def stub_post(url, filename) FakeWeb.register_uri(:post, advanced_vimeo_url, :body => fixture_file(filename), :content_type => 'application/json') end def stub_custom_get(url, filename) FakeWeb.register_uri(:get, vimeo_base_url(url), :body => fixture_file(filename), :content_type => 'application/json') end def stub_custom_post(url, filename) FakeWeb.register_uri(:post, vimeo_base_url(url), :body => fixture_file(filename), :content_type => 'application/json') end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
slainer68_vimeo-1.4.4 | test/test_helper.rb |
slainer68_vimeo-1.4.3 | test/test_helper.rb |