Sha256: 64bd77754803864fffc92514c9d9ca690c654dacb0d79d51b663522c2ed99412

Contents?: true

Size: 1006 Bytes

Versions: 16

Compression:

Stored size: 1006 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"
    RC::Simple.wait
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rest-core-3.6.0 test/test_simple.rb
rest-core-3.5.92 test/test_simple.rb
rest-core-3.5.91 test/test_simple.rb
rest-core-3.5.9 test/test_simple.rb
rest-core-3.5.8 test/test_simple.rb
rest-core-3.5.7 test/test_simple.rb
rest-core-3.5.6 test/test_simple.rb
rest-core-3.5.5 test/test_simple.rb
rest-core-3.5.4 test/test_simple.rb
rest-core-3.5.3 test/test_simple.rb
rest-core-3.5.2 test/test_simple.rb
rest-core-3.5.1 test/test_simple.rb
rest-core-3.5.0 test/test_simple.rb
rest-core-3.4.1 test/test_simple.rb
rest-core-3.4.0 test/test_simple.rb
rest-core-3.3.3 test/test_simple.rb