我不斷收到Undefined method all_empty?
錯誤。我是否錯誤地開課?Rspec錯誤:未讀取我在數組中的擴展方法
core_extensions.rb
class Array
def all_empty?
self.all? { |element| element.to_s.empty? }
end
end
core_extensions_spec.rb:
require "spec_helper"
describe Array do
context "#all_empty?" do
it "returns true if all elements of the Array are empty" do
expect(["","",""].all_empty?).to be true
end
it "returns false if some of the Array elements are not empty" do
expect(["","1", Object.new, :a].all_empty?).to be false
end
it "returns true for an empty Array" do
expect([].all_empty?).to be true
end
end
end
「core_extension.rb」存在於哪裏?你把它包含在測試環境中嗎? –
您的擴展程序未加載(在測試環境中) –
您的生活意味着什麼?我怎麼知道我將它包含在測試環境中?你們是不是要求'path/core_extensions.rb'? –