Sha256: 62dee94c78855086b82a2dc863ac416dfdd908c927589842adcf79a6de9b383b

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

require 'helper'
require 'null_client'
require 'peddler/vcr_matcher'

class TestPeddlerVCRMatcher < MiniTest::Test
  include Recorder

  def setup
    VCR.insert_cassette(test_name, record: :none)
  end

  def test_matches_recorded_post_without_body
    client.run
  end

  def test_wont_match_unrecorded_post_without_body
    client.operation.add(foo: 'bar')
    assert_raises(VCR::Errors::UnhandledHTTPRequestError) do
      client.run
    end
  end

  def test_matches_recorded_post_with_body
    client.body = 'content'
    client.run
  end

  def test_wont_match_unrecorded_post_with_different_query_and_same_body
    client.operation.add(foo: 'bar')
    client.body = 'content'
    assert_raises(VCR::Errors::UnhandledHTTPRequestError) do
      client.run
    end
  end

  def test_wont_match_unrecorded_post_with_same_query_and_different_body
    client.body = 'other content'
    assert_raises(VCR::Errors::UnhandledHTTPRequestError) do
      client.run
    end
  end

  def client
    @client ||= begin
      client = Class.new(Null::Client).new
      client.configure_with_mock_data!
      client.operation('Action')
      client
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
peddler-1.6.3 test/unit/peddler/test_vcr_matcher.rb
peddler-1.6.2 test/unit/peddler/test_vcr_matcher.rb
peddler-1.6.1 test/unit/peddler/test_vcr_matcher.rb
peddler-1.6.0 test/unit/peddler/test_vcr_matcher.rb
peddler-1.5.0 test/unit/peddler/test_vcr_matcher.rb
peddler-1.4.1 test/unit/peddler/test_vcr_matcher.rb
peddler-1.4.0 test/unit/peddler/test_vcr_matcher.rb