Sha256: 9d48f15aca9d24f496855aecd917aa6b33ac227cd8b555b862746153ff7ad9eb

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'test_helper'
require 'stubs/service_under_test_stubs'

module Webhookr
  module Services
    class ServiceUnderTest::AdapterTest < ActiveSupport::TestCase

      def setup
        @event_type = "test_event"
        @data_msg = "Hello world!"
        @valid_response = "event=#{@event_type}&data[msg]=#{@data_msg}"
        @invalid_response = "blort"
     end

      test "should not raise an exception for a valid payload" do
        assert_nothing_raised { 
          Webhookr::ServiceUnderTest::Adapter.process(@valid_response)
        }
      end

      test "should raise an exception for a invalid payload" do
        assert_raise(Webhookr::InvalidPayloadError) { 
          Webhookr::ServiceUnderTest::Adapter.process(@invalid_response)
        }
      end

      test "should repond with the correct event" do
        responses = Webhookr::ServiceUnderTest::Adapter.process(@valid_response)
        assert_equal(@event_type, responses.first.event_type)
      end

      test "should respond with valid data" do
        responses = Webhookr::ServiceUnderTest::Adapter.process(@valid_response)
        assert_equal(@data_msg, responses.first.data.msg)
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webhookr-0.2.0 test/unit/webhookr/Services/ServiceUnderTest/adapter_test.rb
webhookr-0.1.0 test/unit/webhookr/Services/ServiceUnderTest/adapter_test.rb
webhookr-0.0.2 test/unit/webhookr/Services/ServiceUnderTest/adapter_test.rb