Sha256: 53db9fee5a142433ad07b60883f0e64e2e5a01161ce59c22e0d2858dccf2978b

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

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

class TestPeddlerVCRMatcher < MiniTest::Test
  include Recorder
  ::Peddler::VCRMatcher.ignore_seller!

  def setup
    VCR.insert_cassette(test_name)
  end

  def test_matching_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_matching_recorded_post_with_body
    client.body = 'content'
    client.run
  end

  def test_that_it_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_that_it_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

2 entries across 2 versions & 1 rubygems

Version Path
peddler-2.1.1 test/unit/peddler/test_vcr_matcher.rb
peddler-2.1.0 test/unit/peddler/test_vcr_matcher.rb