Skip to content

Instantly share code, notes, and snippets.

@peterhellberg peterhellberg/.rvmc
Created Jan 9, 2012

Embed
What would you like to do?
ArgumentError after include Goliath::TestHelper
rvm --create use 1.9.3@goliath-wrong-number-of-arguments
source :rubygems
gem "goliath", :git => "https://github.com/postrank-labs/goliath.git"
gem "em-http-request", :git => "https://github.com/igrigorik/em-http-request.git"
gem "minitest"
require 'bundler'
Bundler.require
class MyAPI < Goliath::API
use Goliath::Rack::Heartbeat
end
require 'goliath/test_helper'
require 'minitest/pride'
require 'minitest/autorun'
require 'minitest/spec'
describe MyAPI do
include Goliath::TestHelper
options = { :log_stdout => false }
it "responds to heartbeat" do
with_api(MyAPI, options) do
get_request({:path => '/status'}) do |api|
api.response.must_equal 'OK'
end
end
end
end
@peterhellberg

This comment has been minimized.

Copy link
Owner Author

peterhellberg commented Jan 9, 2012

Output when running the spec

ruby wrong_number_of_arguments.rb 
Run options: --seed 24895

# Running tests:

.E

Fabulous tests in 0.010305s, 194.0805 tests/s, 97.0403 assertions/s.

  1) Error:
test_request(MyAPI):
ArgumentError: wrong number of arguments (0 for 1)
    /Users/peter/.rvm/gems/ruby-1.9.3-p0@goliath-wrong-number-of-arguments/bundler/gems/goliath-b3b4de1f05ec/lib/goliath/test_helper.rb:158:in `test_request'

2 tests, 1 assertions, 0 failures, 1 errors, 0 skips
@peterhellberg

This comment has been minimized.

Copy link
Owner Author

peterhellberg commented Jan 9, 2012

MiniTest and with_api

It seems like we can do something like this to disable logging per default (Seems to work just fine with MiniTest)

module Goliath
  module TestHelper
    def with_api(api, options = { :log_stdout => false }, &blk)
      server(api, options.delete(:port) || 9900, options, &blk)
    end
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.