Sha256: 21f5c1c71021776faa3885f4984ab9e1ae3f5ba95be5a56448b6dbee5b89dc83

Contents?: true

Size: 914 Bytes

Versions: 18

Compression:

Stored size: 914 Bytes

Contents

RSpec.shared_examples "Service Context", type: :service do
  let!(:http_stubs) { Faraday::Adapter::Test::Stubs.new }

  before do
    I18n.enforce_available_locales = true
  end

  after do
    http_stubs.verify_stubbed_calls
  end

  def service(klass, data, payload)
    service = klass.new(data, payload)
    service.http adapter: [:test, http_stubs]
    service
  end

  def service_receive(*args)
    service(*args).receive
  end

  def service_post(*args)
    service(
      CC::Service,
      { data: "my data" },
      event(:quality, to: "D", from: "C"),
    ).service_post(*args)
  end

  def service_post_with_redirects(*args)
    service(
      CC::Service,
      { data: "my data" },
      event(:quality, to: "D", from: "C"),
    ).service_post_with_redirects(*args)
  end

  def stub_http(url, response = nil, &block)
    block ||= ->(*_args) { response }
    http_stubs.post(url, &block)
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
codeclimate-services-1.11.4 spec/support/service_context.rb
codeclimate-services-1.11.3 spec/support/service_context.rb
codeclimate-services-1.11.2 spec/support/service_context.rb
codeclimate-services-1.11.1 spec/support/service_context.rb
codeclimate-services-1.11.0 spec/support/service_context.rb
codeclimate-services-1.10.1 spec/support/service_context.rb
codeclimate-services-1.10.0 spec/support/service_context.rb
codeclimate-services-1.9.8 spec/support/service_context.rb
codeclimate-services-1.9.7 spec/support/service_context.rb
codeclimate-services-1.9.6 spec/support/service_context.rb
codeclimate-services-1.9.5 spec/support/service_context.rb
codeclimate-services-1.9.4 spec/support/service_context.rb
codeclimate-services-1.9.3 spec/support/service_context.rb
codeclimate-services-1.9.2 spec/support/service_context.rb
codeclimate-services-1.9.1 spec/support/service_context.rb
codeclimate-services-1.9.0 spec/support/service_context.rb
codeclimate-services-1.8.0 spec/support/service_context.rb
codeclimate-services-1.7.0 spec/support/service_context.rb