Sha256: 88cb500f2ecc1ed6b9192accdb4492e467397c17dd35a17121b1cea27369fb52
Contents?: true
Size: 1.78 KB
Versions: 2
Compression:
Stored size: 1.78 KB
Contents
require 'fakeweb' FakeWeb.allow_net_connect = false $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) 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 def stub_vimeo_embed_uri(geometry) geometry_hash = VimeoEmbedCache.geometry_hash(geometry) FakeWeb.register_uri( :get, "http://vimeo.com/api/oembed.xml?url=http%3A%2F%2Fvimeo.com%2F123456&#{geometry_hash.to_query}", :body => fixture_file("oembed/oembed.json"), :content_type => 'application/json' ) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
refinerycms-vimeo-videos-0.1.6 | spec/vimeo_helper.rb |
refinerycms-vimeo-videos-0.1.5 | spec/vimeo_helper.rb |