Sha256: ba38061194767d3a37dc3c3cca51e8356acb60e9e691a58ae55142e3250cb753

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

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

4 entries across 4 versions & 1 rubygems

Version Path
peddler-1.6.7 test/unit/peddler/test_vcr_matcher.rb
peddler-1.6.6 test/unit/peddler/test_vcr_matcher.rb
peddler-1.6.5 test/unit/peddler/test_vcr_matcher.rb
peddler-1.6.4 test/unit/peddler/test_vcr_matcher.rb