Skip to content

Instantly share code, notes, and snippets.

@peterhellberg
Created January 9, 2012 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterhellberg/1585299 to your computer and use it in GitHub Desktop.
Save peterhellberg/1585299 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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
Copy link
Author

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