Sha256: fc2267a870a42c9fa8774d1591a98b1a22b4e10e382aa3230450d34ebd39e098

Contents?: true

Size: 986 Bytes

Versions: 3

Compression:

Stored size: 986 Bytes

Contents

require 'rest-core/test'

describe RC::Simple do
  path = 'http://example.com/'

  after do
    WebMock.reset!
  end

  would 'give RESPONSE_BODY' do
    stub_request(:get, path).to_return(:body => 'OK')
    RC::Simple.new.get(path).should.eq 'OK'
  end

  would 'give RESPONSE_HEADERS' do
    stub_request(:head, path).to_return(:headers => {'A' => 'B'})
    RC::Simple.new.head(path).should.eq 'A' => 'B'
  end

  would 'give RESPONSE_HEADERS' do
    stub_request(:get, path).to_return(:status => 199)
    RC::Simple.new.get(path, {},
      RC::RESPONSE_KEY => RC::RESPONSE_STATUS).should.eq 199
  end

  would 'give RESPONSE_SOCKET' do
    stub_request(:get, path).to_return(:body => 'OK')
    RC::Simple.new.get(path, {}, RC::HIJACK => true).read.should.eq 'OK'
  end

  would 'give REQUEST_URI' do
    stub_request(:get, "#{path}?a=b").to_return(:body => 'OK')
    RC::Simple.new.get(path, {:a => 'b'},
      RC::RESPONSE_KEY => RC::REQUEST_URI).should.eq "#{path}?a=b"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rest-core-3.3.2 test/test_simple.rb
rest-core-3.3.1 test/test_simple.rb
rest-core-3.3.0 test/test_simple.rb