Sha256: 74314bb816a855b56b37589ffee57fb2a5dfd7ca2f9971dfa0f3613f30a9cfa0

Contents?: true

Size: 631 Bytes

Versions: 2

Compression:

Stored size: 631 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,     inclusion: [true, false]
      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

2 entries across 2 versions & 1 rubygems

Version Path
rspec-webservice_matchers-4.11.0 lib/web_test/be_up.rb
rspec-webservice_matchers-4.10.0 lib/web_test/be_up.rb