I think the dummy application in which my gem tests are intended to run is not configured properly, because when I call url_for on the Gadget instance (the stub model from the dummy application) inside the gem helper, I get
undefined method `gadgets_path' for #<#<Class:0x007fe274bc1228>:0x007fe273d45eb0>
Background: I branched out a gem and made significant changes. ( Here's the plug .) Now I'm trying to run rspec tests so that I can check for my updates in the future.
Tests are configured as a Rails engine with a dummy application in the spec directory. This application has one model ( Gadget ) with the corresponding controller and resource declared in the file spec/dummy/environment/routes.rb :
Dummy::Application.routes.draw do resources :gadgets end
The spec/spec_helper.rb as follows:
ENV["RAILS_ENV"] ||= "test" require File.expand_path("../dummy/config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' RSpec.configure do |config| config.mock_framework = :rspec config.fixture_path = "#{::Rails.root}/spec/fixtures" config.use_transactional_fixtures = true config.infer_base_class_for_anonymous_controllers = false config.order = "random" config.include Rails.application.routes.url_helpers end
(In fact, you can see the full test setup in the github repo project . I actually opened the question for this week or so, but only now I'm going to solve it.)
One test that is not pending creates an instance of Gadget and then calls the helper with it as an argument. When the helper tries url_for(@gadget) , it causes the above error.
What is wrong here?
ETA Dec 04: Updated with current spec_helper.rb .
source share