Sha256: 0a8f4ecddd2511ade2b6a9f63ff0f9e5e8c93a577fb8363a12381aae74277142

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

describe HTTP do
  describe '#body' do
    async 'returns the response body as a string' do
      HTTP.get('data/simple.txt') do |response|
        run_async { response.body.should == "hey" }
      end
    end
  end

  describe '#callback' do
    async 'can add a success callback after the request is sent' do
      http = HTTP.get('data/simple.txt')
      http.callback do |response|
        run_async { response.ok?.should be_true }
      end
    end
  end

  describe '#callback' do
    async 'can add a failure callback after the request is sent' do
      http = HTTP.get('data/bad_url.txt')
      http.errback do |response|
        run_async { response.ok?.should be_false }
      end
    end
  end

  describe '#json' do
    async 'returns the json converted into native ruby objects' do
      HTTP.get('data/user.json') do |response|
        run_async { response.json.should == { 'name' => 'Adam', 'age' => 26 } }
      end
    end
  end

  describe '#ok?' do
    async 'returns true when the request was a sucess' do
      HTTP.get('data/simple.txt') do |response|
        run_async { response.ok?.should be_true }
      end
    end

    async 'returns false when the request failed' do
      HTTP.get('data/non_existant.txt') do |response|
        run_async { response.ok?.should be_false }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-jquery-0.0.1 spec/http_spec.rb