Sha256: 7c1439996db5cd73059d8da497a7ed8732d1fd9d5a41f4372c757643a71d6610

Contents?: true

Size: 624 Bytes

Versions: 5

Compression:

Stored size: 624 Bytes

Contents

# frozen_string_literal: true
require 'rspec/webservice_matchers/util'

module RSpec
  module WebserviceMatchers
    module BeStatus
      # Pass when a URL returns the expected status code
      # Codes are defined in http://www.rfc-editor.org/rfc/rfc2616.txt
      RSpec::Matchers.define :be_status do |expected_code|
        actual_code = nil
        
        match do |url_or_domain_name|
          actual_code = Util.status(url_or_domain_name)
          actual_code == expected_code.to_i
        end
        
        failure_message do
          "Received status #{actual_code}"
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rspec-webservice_matchers-4.9.0 lib/rspec/webservice_matchers/be_status.rb
rspec-webservice_matchers-4.8.1 lib/rspec/webservice_matchers/be_status.rb
rspec-webservice_matchers-4.8.0 lib/rspec/webservice_matchers/be_status.rb
rspec-webservice_matchers-4.7.0 lib/rspec/webservice_matchers/be_status.rb
rspec-webservice_matchers-4.6.0 lib/rspec/webservice_matchers/be_status.rb