Rails ヘルパーをテストする RSpec 仕様を作成しています。問題は、私がテストしているヘルパー メソッドが別のヘルパーで定義されたメソッドに依存していることです。私にはコードのにおいがするかもしれませんが、レガシー コードのテストを追加していて、リファクタリングできる段階ではありません。この Rails ヘルパーをテストするにはどうすればよいですか?
module FancyHelper
def fancy_method
html = "hello"
html << another_fancy_method
html
end
end
module OtherHelper
def another_fancy_method
"world"
end
end
require "spec_helper"
describe FancyHelper do
describe "#fancy_method" do
it "does what it's supposed to" do
helper.fancy_method.should match("hello")
# NoMethodError: undefined method `another_fancy_method'
end
end
end