alexrothenberg / ammeter

A gem that allows for you to write specs for your Rails 3 generators
MIT License
89 stars 28 forks source link

Installing ammeter affects helpers that are available in Rails views #53

Open crawfoal opened 8 years ago

crawfoal commented 8 years ago

After adding ammeter to my gem file and running bundle install, I get an error like this:

4) FlashHelper#render_flash doesn't include blank messages
     Failure/Error: = fa_icon 'close'

     ActionView::Template::Error:
       undefined method `fa_icon' for #<#<Class:0x007ffabbdbbd08>:0x007ffac2cd9d48>

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.

alexrothenberg commented 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

niklas commented 8 years ago

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)

crawfoal commented 8 years ago

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:

crawfoal commented 8 years ago

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.

d4rky-pl commented 8 years ago

@crawfoal URL to the repository does not seem to be working

crawfoal commented 8 years ago

@d4rky-pl Whoops, I had it set as private on accident, it should work now.

alexrothenberg commented 8 years ago

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.

robinaugh commented 11 months ago

👋 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