pat / combustion

Simple, elegant testing for Rails Engines
MIT License
707 stars 51 forks source link

Don't know how to fix rake tasks in engine #112

Closed shageman closed 2 years ago

shageman commented 3 years ago

I am trying to switch an engine from spec/dummy to combustion. I get stuck after going through the install process and deleting spec/dummy because my rake tasks stop working.

It looks like whichever way I create my engine I get this kind of Rakefile, which seems to indicate that because of the definition of APP_RAKEFILE I can't delete the dummy app.

begin
  require 'bundler/setup'
rescue LoadError
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end

require 'rdoc/task'

RDoc::Task.new(:rdoc) do |rdoc|
  rdoc.rdoc_dir = 'rdoc'
  rdoc.title    = 'YourNewComponent'
  rdoc.options << '--line-numbers'
  rdoc.rdoc_files.include('README.md')
  rdoc.rdoc_files.include('lib/**/*.rb')
end

APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
load 'rails/tasks/engine.rake'

load 'rails/tasks/statistics.rake'

require 'bundler/gem_tasks'

I can't find a fix in the docs or the source. Any ideas?

pat commented 3 years ago

Hi Stephan - can you clarify which tasks aren't working? e.g. are they core Rails tasks, or tasks you've defined yourself? And are you running these tasks for the engine (as part of developing it), for the minimal internal testing app, or within an app that's using the engine?

Also: the Rakefile - is this generated by Rails for the engine? I must admit, generally I'm creating my engines by hand (rather than via a generator), which is why Combustion hasn't needed to generate a Rakefile for the internal testing app. That said, it doesn't mean it shouldn't - certainly I can see it would be helpful!

pat commented 3 years ago

Also: I wonder if just copying spec/dummy/Rakefile to spec/internal/Rakefile will help? Though it could be that Rails' rake tasks expect something closer to a fully fledged app than the minimal scaffolding Combustion provides.

pat commented 2 years ago

This issue's been dormant for over a year 😅 so I'm closing it. That said, very happy to continue the discussion if it remains a problem.