Sha256: 8137486d5f4b7cac550f73c13a57b8ae940d513be08367a4aac6c84b6ff6cfd5

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require '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

1 entries across 1 versions & 1 rubygems

Version Path
fakeweb-matcher-1.2.3 spec/lib/fake_web_matcher/matchers_spec.rb