Domanda

I'm trying to write tests for an engine gem I'm writing. I'm using Rspec and the tests seem to be running fine. But whenever a view uses a helper from another gem, such as "will_paginate" or "ransack", I get an "undefined method" error.

I've tried including the other gems in my gem's Gemfile (in addition to the engine.gemspec file) as well as the dummy app's Gemfile, but I get the same error. I've also tried including the gems in the spec/spec_helper.rb file.

So I've tried most of the things mentioned here:

Setup RSpec to test a gem (not Rails)

Usually, for Rspec tests for a regular Rails app, these helpers seem to be just included some how since I don't have this issue running tests for a regular Rails app.

I also have been needing to namespace my url helpers in the views with something like: engine.resources_path

I'm not sure if that's a symptom of some configuration I've messed up on.

Everything in the engine runs fine when mounted to another app and viewed on the browser.

Any ideas?

È stato utile?

Soluzione

Turns out a better approach is to stub out methods from gems since the gem should be testing their own methods anyways. Please let me know if I'm misunderstanding anything. Thanks!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top