Open crawfoal opened 8 years ago
@crawfoal I'm not sure what could be the problem. When you take ammeter out of the Gemfile does this test pass (I assume others will probably fail)? If so then this is probably a font-awesome issue and if not there may be some strange interaction where ammeter is causing the problem.
If you think it is an ammeter issue can you point me at the failing test so I can try to reproduce it
We have exactly that problem. When adding ammeter
to the Gemfile, Rails helpers are not available in view specs anymore, helper specs only have the current helper loaded.
Here is a minimal example. https://github.com/niklas/rspec-rails-3.4-helpers-notfound-views-example
(also see rspec/rspec-rails#1626)
I'm seeing slightly different behavior (the only helper method I have seen missing is one from font-awesome-rails, my own methods, and Rail's built in methods are fine from what I've seen). I've also run into this issue again and have more details, so I created a repo (metanoia-view-helper-issues) that shows the problems I'm having. The README outlines the issues, but I'll copy them here for convenience:
include FontAwesome::Rails::IconHelper
in the
ApplicationHelper
(the current state):
spec/views/athletes/climb_logs/index.html.haml_spec.rb
,
you should get an error for undefined method fa_icon
.include FontAwesome::Rails::IconHelper
in ApplicationHelper
, then you will see
5 errors, all due to fa_icon
not being defined. Notice that the helper
method I have defined (render_flash
) is still defined, and so are all of
the Rail's helpers.include FontAwesome::Rails::IconHelper
commented out, and
take out ammeter (you'll need to comment out require 'ammeter/init'
in
spec/generator_helper.rb
), there shouldn't be any errors due to
fa_icon
not being defined (but obviously there will be other errors due
to ammeter not being there - these should all be for the
SeedMigrationGenerator
group).include FontAwesome::Rails::IconHelper
commented out, and have
ammeter installed, and run the server in development mode, everything works
fine - you don't get any errors when you view pages that use the fa_icon
method.As a temporary solution, I've done this:
RSpec.configure do |config|
config.before(:each, type: :view) do
view.extend FontAwesome::Rails::IconHelper
end
config.before(:each, type: :helper) do
helper.extend FontAwesome::Rails::IconHelper
end
end
I've seen that font-awesome-rails has a lot of issue regarding method missing errors for fa_icon
, so I'll submit an issue to them to so we can get their input.
@crawfoal URL to the repository does not seem to be working
@d4rky-pl Whoops, I had it set as private on accident, it should work now.
Thanks for the example. I'll try to take a look at it when I can and see if I can figure out what ammeter is doing to break things.
👋 This appears to still be an issue on v1.1.6, but we worked around it by passing require: false
in our Gemfile (as suggested in https://github.com/rspec/rspec-rails/issues/1644#issuecomment-234129767), i.e.:
gem 'ammeter', '~> 1.1', '>= 1.1.6', require: false
After adding ammeter to my gem file and running bundle install, I get an error like this:
on some of my feature specs. I only see this for the method
fa_icon
which comes from the gem font-awesome-rails, so let me know if you think I should submit an issue to them instead.I only included ammeter in my test group. When I run my app in development mode, I don't get the errors that I see when I run my specs.