0

I'm trying to use simplecov to get some spec coverage of my customisations to a Spree powered store.

Classes are usually stored in /app/models/spree/price_decorator.rb and in the file we crack open the class with a Spree::Price.class_eval block to include our custom logic.

However files aren't showing up in SimpleCov, I'm unsure if it's a technical limitation or is there a chance to have them in the final output.

SimpleCov is currently configured in a very simple way:

require 'simplecov'

SimpleCov.start 'rails' do
  add_group 'Workers', 'app/workers'
end

I tried to add_group with app/models/spree but it doesn't work.

Any suggestion?

John Smith
  • 1,726
  • 2
  • 18
  • 30

1 Answers1

1

I think this might work for you if you put it into your application.rb config file (obviously it goes inside your class Application < Rails::Application)

I use simplecov for my Spree application and my decorators show up fine. I think maybe it's just a matter of your decotorators not being loaded by the app's bootup.

 config.to_prepare do
      # Load application's model / class decorators
      Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
        Rails.configuration.cache_classes ? require(c) : load(c)
 end
Jason FB
  • 4,752
  • 3
  • 38
  • 69
  • yeah I have that snipped of code (spree default), but it's very weird I don't get decorators to show up, not sure where else to look. Thanks. – John Smith Apr 01 '15 at 13:15