Sha256: e0b07ed8ac83547a9fe46a06aa8963cf6993ab2300df12510b11f509c77be625

Contents?: true

Size: 1.83 KB

Versions: 5

Compression:

Stored size: 1.83 KB

Contents

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

describe 'be_status' do
  it 'can check 200 for successful resource requests' do
    expect('http://a-page.com/a/page.txt').to be_status 200
  end

  it 'handles domain names as well as URLs' do
    expect('www.website.com').to be_status 200
  end

  it 'accepts status code in text form too' do
    expect('www.website.com').to be_status '200'
  end

  it 'can check for the 503 - Service Unavailable status' do
    expect('http://outoforder.com/').to be_status 503
  end

  it 'can check for 404' do
    expect('http://notfound.com/no.txt').to be_status 404
  end

  it 'gives the actual code received in case of failure' do
    expect {
      expect('http://notfound.com/no.txt').to be_status 200
    }.to fail_matching(/404/)
  end

  it 'succeeds even if the site times out on the first try' do
    expect('http://www.timeout-once.com').to be_status 200
  end

  it 'works on hosts which do not support HEAD' do
    expect('http://appengine.com').to be_status 200
  end
end

describe 'be_up' do
  it 'follows redirects when necessary' do
    expect('perm-redirector.com').to be_up
    expect('temp-redirector.org').to be_up
  end

  it 'can also handle a simple 200' do
    expect('http://www.website.com/').to be_up
  end

  it 'is available via a public API' do
    status = RSpec::WebserviceMatchers::Util.up?('http://www.website.com/')
    expect(status).to be true
  end

  it 'gives relevant error output' do
    expect {
      expect('http://notfound.com/no.txt').to be_up
    }.to fail_matching(/^received status 404$/i)
  end

  it 'succeeds even if the site times out on the first try' do
    expect('http://www.timeout-once.com').to be_up
  end

  it 'works on cars.com' do
    expect('http://cars.com').to be_up
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rspec-webservice_matchers-4.9.0 spec/rspec/webservice_matchers/protcol_spec.rb
rspec-webservice_matchers-4.8.1 spec/rspec/webservice_matchers/protcol_spec.rb
rspec-webservice_matchers-4.8.0 spec/rspec/webservice_matchers/protcol_spec.rb
rspec-webservice_matchers-4.7.0 spec/rspec/webservice_matchers/protcol_spec.rb
rspec-webservice_matchers-4.6.0 spec/rspec/webservice_matchers/protcol_spec.rb