Sha256: e95a16029988fb5c58c76062aa56b1e58c8efb18ccdafe99602742dcfe3cdff0

Contents?: true

Size: 495 Bytes

Versions: 1

Compression:

Stored size: 495 Bytes

Contents

require 'webmock'
require 'rspec'

module WebMock
  module RSpec
    module Helper

      def webmock(method, mocks = {})
        mocks.each do |regex, filename|
          status = filename[/\.(\d+)\./, 1] || 200
          body = File.read Rails.root.join('spec', 'support', 'stubs', filename)
          WebMock.stub_request(method, regex).to_return status: status.to_i, body: body
        end
      end

    end
  end
end

RSpec.configure do |config|
  config.include WebMock::RSpec::Helper
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webmock-rspec-helper-0.0.1 lib/webmock-rspec-helper.rb