Sha256: 42a8a256dba9c254593fbcb41e7e519da56355b2e903afd8f0ef6818d889e069

Contents?: true

Size: 620 Bytes

Versions: 4

Compression:

Stored size: 620 Bytes

Contents

# frozen_string_literal: true
require 'validated_object'
require 'web_test/util'

module WebTest
  module BeUp
    class TestResult < ValidatedObject::Base
      attr_accessor :success, :status_code
      alias success? success

      validates :success,     type: Boolean
      validates :status_code, inclusion: 100..510
    end


    def self.test(url:nil, domain:nil)
      raise 'Must specify a url or domain' if url.nil? && domain.nil?

      TestResult.new do |r|
        r.status_code = WebTest::Util.status(url || domain, follow: true)
        r.success     = (r.status_code == 200)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-webservice_matchers-4.13 lib/web_test/be_up.rb
rspec-webservice_matchers-4.12.2 lib/web_test/be_up.rb
rspec-webservice_matchers-4.12.1 lib/web_test/be_up.rb
rspec-webservice_matchers-4.12.0 lib/web_test/be_up.rb