在 Rspec 错误数量的参数中测试机架中间件(2 代表 0)

Testing Rack Middleware in Rspec wrong number of arguments (2 for 0)

我正在尝试测试我在 Rails 应用程序中编写的一些中间件,当我尝试 运行 我的测试堆栈时出现以下错误:

Failure/Error: let(:middleware) { AngerFist.new(app "UA-xxxxxxx-x", "http://test.domain") }
    ArgumentError:
      wrong number of arguments (2 for 0)

这是我的中间件:

class AngerFist
  include Rack::Utils

  def initialize(app, tracker_id, domain)
    @app = app
    @gabba = Gabba::Gabba.new(tracker_id, domain)
  end

  def call(env)
    status, headers, response = @app.call(env)

    headers = HeaderHash.new(headers)

    if headers.key?('Content-Type') && headers['Content-Type'].include?('application/json')
      @gabba.page_view(env['PATH_INFO'], env['PATH_INFO'])
    end

    [status, headers, response]
  end

end

这是我的测试:

require 'spec_helper'
require 'rack'
require 'gabba'
require 'angerfist'

describe AngerFist do
  let(:app) { proc{[200,{},['Hello, world.']]} }
  let(:middleware) { AngerFist.new(app "UA-xxxxxxx-x", "http://test.domain") }
  let(:request) { Rack::MockRequest.new(middleware) }

  it "tracks a page view for JSON" do
    expect_any_instance_of(Gabba::Gabba).to receive(:page_view)
    request.get('addresses/address.json')
  end

end

我哪里错了?

应用后缺少逗号? AngerFist.new(app, "UA-xxxxxxx-x", "http://test.domain")