Sha256: 95a6d18f8e77ca5f4d8d017a370434fee1bbda6a719401ae0745bd3964617137

Contents?: true

Size: 1010 Bytes

Versions: 7

Compression:

Stored size: 1010 Bytes

Contents

ENV['RACK_ENV'] = 'test'

require 'minitest/autorun'

class TestEndpointRecorder < MiniTest::Test

  def setup
    @mock = MiniTest::Mock.new
    @recorder = PinchHitter::Service::EndpointRecorder.new @mock
  end

  def test_is_facade_for_handler
    @mock.expect(:<<, nil, ['blah'])
    @recorder.store 'blah'
    @mock.verify
  end

  def test_is_facade_reset
    @mock.expect(:reset, nil)
    @recorder.reset
    @mock.verify
  end

  def test_stores_request_if_present
    @mock.expect(:respond_to, '', [String])
    @recorder.respond_to({ body: 'request' })
    assert_equal [{body: 'request'}], @recorder.requests
  end

  def test_passes_body_to_handler_if_present
    @mock.expect(:respond_to, '', ['request'])
    @recorder.respond_to({ body: 'request' })
    @mock.verify
  end

  def reset_clears_stored_requests
    @mock.expect(:respond_to, '', [String])
    @mock.expect(:reset, nil)
    @recorder.respond_to({ body: 'request' })
    @recorder.reset
    assert_empty @recorder.requests
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pinch_hitter-0.5.5 test/test_endpoint_recorder.rb
pinch_hitter-0.5.4 test/test_endpoint_recorder.rb
pinch_hitter-0.5.3 test/test_endpoint_recorder.rb
pinch_hitter-0.5.2 test/test_endpoint_recorder.rb
pinch_hitter-0.5.1 test/test_endpoint_recorder.rb
pinch_hitter-0.5 test/test_endpoint_recorder.rb
pinch_hitter-0.4 test/test_endpoint_recorder.rb