Sha256: 8dd15b770aeb150df0d69fdc166f97cd2ea79434d6cf452237aa8a84096792d9
Contents?: true
Size: 1.73 KB
Versions: 7
Compression:
Stored size: 1.73 KB
Contents
require "spec_helper" require "fileutils" module Sucker describe "Stub" do before do @worker = Sucker.new( :locale => "us", :secret => "secret") end context ".stub" do before do Sucker.stub(@worker) end after do FileUtils.rm @worker.fixture, :force => true end it "defines Request#fixture" do @worker.should respond_to :fixture @worker.fixture.should include Sucker.fixtures_path end it "performs the request if fixture is not available" do curl = @worker.curl curl.stub(:get).and_return(nil) curl.stub!(:body_str).and_return("foo") @worker.get File.exists?(@worker.fixture).should be_true File.new(@worker.fixture, "r").read.should eql "foo" end it "mocks the request if fixture is available" do File.open(@worker.fixture, "w") { |f| f.write "bar" } @worker.get.body.should eql "bar" end end context "#fixture" do it "generates a path for the fixture" do @worker.fixture.should match /.*\/[0-9a-f]{32}\.xml$/ end it "generates unique fixtures across venues" do first_fixture = @worker.fixture @worker.locale = "fr" @worker.fixture.should_not eql first_fixture end it "generates the same fixture regardless of signature" do first_fixture = @worker.fixture @worker.stub!(:timestamp).and_return({ "Timestamp" => "foo" }) @worker.fixture.should eql first_fixture end it "generates the same fixture regardless of key" do first_fixture = @worker.fixture @worker.key = "foo" @worker.fixture.should eql first_fixture end end end end
Version data entries
7 entries across 7 versions & 1 rubygems