【问题标题】:Rspec wrong number of arguments (1 for 0)Rspec 错误的参数数量(1 代表 0)
【发布时间】:2014-02-11 17:44:09
【问题描述】:

我正在关注来自复数视觉.com 的 Rspec 教程。本教程提供了以下可用于截屏视频的代码:

module Wordpress
  module Comments
    class Client
      def intitialize(url)

      end
    end
  end
end

describe Wordpress::Comments::Client do
  it "stores a URL" do
    client = Wordpress::Comments::Client.new("http://mashable.com/comments/feed")
  end
end     

但是当我运行它时,我收到以下错误:

Failure/Error: client = Wordpress::Comments::Client.new("http://mashable.com/comments/feed")
 ArgumentError:
   wrong number of arguments (1 for 0)

【问题讨论】:

    标签: ruby-on-rails ruby rspec


    【解决方案1】:

    看起来像是一个错字:initialize,没有初始化

    【讨论】:

    • 拼写错误是最糟糕的,而且很难找到。我感觉到你的痛苦:)
    【解决方案2】:

    拼写错误:

    module Wordpress
      module Comments
        class Client
          def initialize(url)
            ...         
          end
        end
      end
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-12
      • 1970-01-01
      • 1970-01-01
      • 2011-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多