Sha256: df60e1999a6fe15952e0f2cf51b2c42c0e059ca1bddce07b41b643b9d96e355f
Contents?: true
Size: 1.36 KB
Versions: 3
Compression:
Stored size: 1.36 KB
Contents
require "spec_helper" describe HTTP do describe '#body' do async 'returns the response body as a string' do HTTP.get('spec/fixtures/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('spec/fixtures/simple.txt') http.callback do |response| run_async { response.should be_ok } end end end describe '#callback' do async 'can add a failure callback after the request is sent' do http = HTTP.get('spec/fixtures/bad_url.txt') http.errback do |response| run_async { response.should_not be_ok } end end end describe '#json' do async 'returns the json converted into native ruby objects' do HTTP.get('spec/fixtures/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('spec/fixtures/simple.txt') do |response| run_async { response.should be_ok } end end async 'returns false when the request failed' do HTTP.get('spec/fixtures/non_existant.txt') do |response| run_async { response.should_not be_ok } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
opal-jquery-0.2.0 | spec/http_spec.rb |
opal-jquery-0.1.2 | spec/http_spec.rb |
opal-jquery-0.1.1 | spec/http_spec.rb |