It's a simple (and maybe common) question but I can't find a clear answer.
I'm testing my rails engine from the dummy application with Rspec and Capybara. In my feature spec I need to use a ApplicationController
method named get_component()
with a specific argument. How can I do it?
My feature test is:
require "rails_helper"
describe "My test", type: :feature do
it "gets a component if slug is provided" do
# ...
component = ApplicationController.get_component( slug )
# ...
end
end
Which returns
NoMethodError:
undefined method `get_component' for #<ApplicationController:0x007ff7207234f8>
I don't want to mock/stub that method, I want it to run for real.
Also, the application ApplicationController
should inherit the engine one, shouldn't it? So it's right to call ApplicationController, isn't it?
ApplicationRecord
which belongs to the app doesn't seem to inherit the method belonging toApplicationRecord
of the engine. Or maybe I'm doing something wrong, am I? – a.barbieri