jnicklas/turnip

rake spec:requests points to `spec/requests` - should it be replaced with spec:acceptance?

jmuheim opened this issue · 3 comments

I'm having a lot of fun with Turnip since I started using it a few days ago, and I'm trying to configure it correctly for my project. I noticed that listing the rake tasks using rake -T results in the following spec tasks:

    rake spec             # Run all specs in spec directory (excluding plugin specs) / Run RSpec cod...
    rake spec:controllers # Run the code examples in spec/controllers
    rake spec:models      # Run the code examples in spec/models
    rake spec:requests    # Run the code examples in spec/requests
    rake spec:routing     # Run the code examples in spec/routing
    rake stats            # Report code statistics (KLOCs, etc) from the application

As I don't have request specs anymore when using Turnip, I think the spec:requests task should be removed and replaced with a spec:acceptance task. What's the best way to do this? Could this be done within the Turnip gem itself?

I got an answer on StackOverflow regarding the obsolete spec:requests task: http://stackoverflow.com/questions/20872895/remove-rake-test-when-using-rspec

For the missing spec:acceptance task I found the following:
rspec/rspec-rails#538

Still, I think you should add the task to your gem.

This doesn't have anything to do with Turnip, these Rake tasks are added by rspec.

You're right.

If anybody's interested, here's a custom Rake task that does what I want:

# Treat .feature files as RSpec files when running `rake spec`.
# https://github.com/rspec/rspec-rails/issues/538
if defined? RSpec
  task(:spec).clear

  desc "Run all specs in spec directory (excluding plugin specs)"
  RSpec::Core::RakeTask.new(spec: 'db:test:prepare') do |t|
    t.pattern = './spec/**/*{_spec.rb,.feature}'
  end

  namespace :spec do
    desc "Run the code examples in spec/acceptance"
    RSpec::Core::RakeTask.new(acceptance: 'db:test:prepare') do |t|
      t.pattern = './spec/acceptance/**/*.feature'
    end
  end
end