Sha256: 080999ee73f6d891fc9da16295e39ebb9383dd3236e4006d3e6f10f866c367f8

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'
require 'rspec/webservice_matchers'


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

  it 'handles domain names as well as URLs' do
    'www.website.com'.should be_status 200
  end

  it 'accepts status code in text form too' do
    'www.website.com'.should be_status '200'
  end

  it 'can check for the 503 - Service Unavailable status' do
    'http://outoforder.com/'.should 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
end


describe 'be_up' do
  it 'follows redirects when necessary' do
    'perm-redirector.com'.should be_up
    'temp-redirector.org'.should be_up
  end

  it 'can also handle a simple 200' do
    'http://www.website.com/'.should be_up
  end

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rspec-webservice_matchers-2.0 spec/rspec/webservice_matchers/protcol_spec.rb
rspec-webservice_matchers-1.4.6 spec/rspec/webservice_matchers/protcol_spec.rb
rspec-webservice_matchers-1.4.5 spec/rspec/webservice_matchers/protcol_spec.rb
rspec-webservice_matchers-1.4.4 spec/rspec/webservice_matchers/protcol_spec.rb
rspec-webservice_matchers-1.4.3 spec/rspec/webservice_matchers/protcol_spec.rb
rspec-webservice_matchers-1.4.2 spec/rspec/webservice_matchers/protcol_spec.rb