Sha256: 5ee006d2a1d3af5cdb0711f4f7cf0342e7a7bdcbf62629629c06da07af6b4f29

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

require 'webmock/rspec'
require 'rspec/webservice_matchers'

#
# TODO: set up mocks or VCR for the rest of these.
# SEE:  http://www.slideshare.net/kjbuckley/testing-http-calls-with-webmock-and-vcr
#

WebMock.stub_request :any, 'http://www.website.com/a/page.txt'
WebMock.stub_request :any, 'http://www.website.com/'

WebMock.allow_net_connect!


describe 'status_code' do
  it 'can check 200 for successful resource requests' do
    'http://www.website.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 503 for the Service Unavailable status' do
    'http://www.weblaws.org/texas/laws/tex._spec._dist._local_laws_code_section_1011.202_tax_to_pay_general_obligation_bonds'.should be_status 503
  end
end


describe 'be_up' do
  it 'follows redirects when necessary' do
    'weblaws.org'.should be_up
  end

  it 'can also handle a simple 200' do
    'http://www.rfc-editor.org/rfc/rfc2616.txt'.should be_up
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rspec-webservice_matchers-1.3.1 spec/rspec/webservice_matchers/protcol_spec.rb
rspec-webservice_matchers-1.3.0 spec/rspec/webservice_matchers/protcol_spec.rb
rspec-webservice_matchers-1.2.2 spec/rspec/webservice_matchers/protcol_spec.rb