Sha256: 8cc70cce012f2cfd991e1126a57f872ea8fe412b55711bd8009ae36deb7c8463
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
# http://sneaq.net/textmate-wtf $:.reject! { |e| e.include? 'TextMate' } require 'rubygems' require 'test/unit' require 'shoulda' require 'matchy' require 'mocha' require 'cgi' require File.expand_path('../../lib/etsy', __FILE__) class Test::Unit::TestCase def raw_fixture_data(filename) file = File.dirname(__FILE__) + "/fixtures/#{filename}" File.read(file) end def read_fixture(filename) JSON.parse(raw_fixture_data(filename))['results'] end def mock_request(endpoint, options, resource, file) objects = [] underscored_fixture_filename = "#{resource.gsub(/([^^])([A-Z])/, '\1_\2').downcase}/#{file}" response_data = raw_fixture_data(underscored_fixture_filename) Etsy::Request.stubs(:new).with(endpoint, options).returns(stub(:get => stub(:body => response_data, :code => '200'))) JSON.parse(response_data)['results'].each_with_index do |result, index| object = "#{resource.downcase}_#{index}" if options[:access_token] && options[:access_secret] Etsy.const_get(resource).stubs(:new).with(result, options[:access_token], options[:access_secret]).returns(object) else Etsy.const_get(resource).stubs(:new).with(result).returns(object) end objects << object end objects end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
tailored-etsy-0.2.2 | test/test_helper.rb |
etsy-0.2.1 | test/test_helper.rb |