Sha256: 3b1444f48b6dfc074f1bc87ad67325fec3e97209c29352819c8bcce0680024a1

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require 'spec/spec_helper'

describe FakeWebMatcher::Matchers do
  describe '#have_requested' do
    before :each do
      class Matchbox
        include FakeWebMatcher::Matchers
      end
      
      @matcher = Matchbox.new.have_requested(:put, 'http://url.com')
    end
    
    it "should return an instance of RequestMatcher" do
      @matcher.should be_a(FakeWebMatcher::RequestMatcher)
    end
    
    it "should set the url and method using the matcher arguments" do
      @matcher.url.to_s.should  == 'http://url.com'
      @matcher.method.should    == :put
    end
  end
  
  it "should pass if the request has been made" do
    FakeWeb.register_uri(:get, 'http://example.com/', :body => 'foo')
    open('http://example.com/')
    
    FakeWeb.should have_requested(:get, 'http://example.com')
  end
  
  it "should pass if the request has not been made" do
    FakeWeb.register_uri(:get, 'http://example.com/', :body => 'foo')
    
    FakeWeb.should_not have_requested(:get, 'http://example.com')
  end

  it "should not care about the order of the query parameters" do
    FakeWeb.register_uri(:get, URI.parse('http://example.com/page?foo=bar&baz=qux'), :body => 'foo')
    open('http://example.com/page?baz=qux&foo=bar')

    FakeWeb.should have_requested(:get, 'http://example.com/page?foo=bar&baz=qux')
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
fakeweb-matcher-1.2.2 spec/lib/fake_web_matcher/matchers_spec.rb
fakeweb-matcher-1.2.1 spec/lib/fake_web_matcher/matchers_spec.rb
fakeweb-matcher-1.2.0 spec/lib/fake_web_matcher/matchers_spec.rb
dnclabs-fakeweb-matcher-1.1.0 spec/lib/fake_web_matcher/matchers_spec.rb