Sha256: ce56528dd1adcee27bd4726abcaa7197aea2febd8fd8b0d05327fc75d9539333

Contents?: true

Size: 972 Bytes

Versions: 24

Compression:

Stored size: 972 Bytes

Contents

require File.expand_path('../helper', __FILE__)

class ResponseTest < Test::Unit::TestCase
  
  def test_initialization
    object = stub(:body => {
      'response' => {
        'uid'     => 'md5_hash_uid',
        'status'  => 'ok',
        'message' => 'api reply message'
      },
      'data' => {
        'key' => 'value'
      }
    }.to_json)
    
    response = PostageApp::Response.new(object)
    assert_equal 'md5_hash_uid',        response.uid
    assert_equal 'ok',                  response.status
    assert_equal 'api reply message',   response.message
    assert_equal ({'key' => 'value'}),  response.data
    assert response.ok?
  end
  
  def test_status_check
    response = PostageApp::Response.new(nil)
    assert_equal 'fail', response.status
    assert response.fail?
    assert !response.ok?
    assert !response.really?
    
    begin
      response.bad_method 
      assert false
    rescue NoMethodError 
      assert true
    end
  end
  
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
postageapp-1.0.23 test/response_test.rb
postageapp-1.0.22 test/response_test.rb
postageapp-1.0.21 test/response_test.rb
postageapp-1.0.20 test/response_test.rb
postageapp-1.0.19 test/response_test.rb
postageapp-1.0.18 test/response_test.rb
postageapp-1.0.17 test/response_test.rb
postageapp-1.0.16 test/response_test.rb
postageapp-1.0.15 test/response_test.rb
postageapp-1.0.14 test/response_test.rb
postageapp-1.0.13 test/response_test.rb
postageapp-1.0.12 test/response_test.rb
postageapp-1.0.11 test/response_test.rb
postageapp-1.0.10 test/response_test.rb
postageapp-1.0.9 test/response_test.rb
postageapp-1.0.8 test/response_test.rb
postageapp-1.0.7 test/response_test.rb
postageapp-1.0.6 test/response_test.rb
postageapp-1.0.5 test/response_test.rb
postageapp-1.0.4 test/response_test.rb