Sha256: e674c2d7d76472b24cc3e9edb7d05e07ad5085644069e61f96708e35c553c40b

Contents?: true

Size: 617 Bytes

Versions: 6

Compression:

Stored size: 617 Bytes

Contents

# frozen_string_literal: true
require 'web_test/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 = WebTest::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

6 entries across 6 versions & 1 rubygems

Version Path
rspec-webservice_matchers-4.13 lib/rspec/webservice_matchers/be_status.rb
rspec-webservice_matchers-4.12.2 lib/rspec/webservice_matchers/be_status.rb
rspec-webservice_matchers-4.12.1 lib/rspec/webservice_matchers/be_status.rb
rspec-webservice_matchers-4.12.0 lib/rspec/webservice_matchers/be_status.rb
rspec-webservice_matchers-4.11.0 lib/rspec/webservice_matchers/be_status.rb
rspec-webservice_matchers-4.10.0 lib/rspec/webservice_matchers/be_status.rb