为什么在方法存在时RSpec给出NoMethodError?

时间:2018-08-28 14:57:48

标签: ruby rspec

我在下面收到错误消息

$ bundle exec rspec calculatorcli_spec.rb

 Failure/Error: c = CalculatorCLI.parse

 NoMethodError:
   undefined method `parse' for CalculatorCLI:Class

来自下面的简单计算器类

image of the code

1 个答案:

答案 0 :(得分:0)

CalculatorCLI是一个类,并且您缺少其初始化

CalculatorCLI.parse更改为CalculatorCLI.new.parse or change def解析to def self.parse in CalculatorCLI`定义