Sha256: 4bbee5e5597ae9617d471fe75b3e9ab39a73e8c40cdf81f62e877ae5823ead9c

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

require_relative '../helper'

class ResponseTest < MiniTest::Test
  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

3 entries across 3 versions & 1 rubygems

Version Path
postageapp-1.4.2 test/unit/response_test.rb
postageapp-1.4.1 test/unit/response_test.rb
postageapp-1.4.0 test/unit/response_test.rb