Let's say I have a helper method in my Rails initializer, which makes it essentially available everywhere in my app
# config/initializers/foo.rb
def foo
"FOO"
end
And then I use it while rendering a view
<div class="container">
<%= t("some.translation", link: foo) %>
</div>
I want to stub that value in my feature specs (not view specs). That means I want have one of the following -
expect_any_instance_of(<some class instance>).to receive(:foo) { "BAR" }
expect(<some class>).to receive(:foo) { "BAR" }
What is the
<some_class>
or instance that I need to fill in here? What class acts as the recipient for view methods?In general, how do I find the recipient of any arbitrary method so I can stub it out in a similar fashion?