ruby - sinatra - 使用 test unit

访问量: 444

这样就行:, 运行方式: bundle exec ruby test/app_test.rb

ENV['APP_ENV'] = 'test'

require './app.rb'
require 'test/unit'
require 'rack/test'

class AppTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app 
    Sinatra::Application
  end 

  #def test_should_get_name_vitalik_eth
  test "should get /name/vitalik.eth" do
    header "HOST", "api.ddxx.so"
    response = get '/name/vitalik.eth'

    body = JSON.parse(response.body)
    assert_equal "ok", body['result']
    assert_equal "vitalik.eth", body['data']['name']
    assert_equal "0xee6c4522aab0003e8d14cd40a6af439055fd2577951148c14b6cea9a53475835", body['data']['nameHash']
  end 

end

订阅/RSS Feed

Subscribe