Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Feature files are not loaded with rake spec #79

Closed
gravis opened this Issue Sep 12, 2012 · 21 comments

Comments

Projects
None yet

gravis commented Sep 12, 2012

In the README, it's said :

"It will automatically be run if you run all your specs with rake spec or rspec spec."

That's not the case for me, .feature files are not loaded in the suite when I use rake, or rake spec

thanks

gravis commented Sep 12, 2012

I've fixed this with a lib/tasks/rspec.rake file:

if defined? RSpec # otherwise fails on non-live environments  
  task(:spec).clear  
  desc "Run all specs/features in spec directory"  
  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/**/*{_spec.rb,.feature}'
    end
  end
end

I understand everyone will want to be free about where the specs / features paths are, but maybe we can add this to the Readme? It would make the turnip setup easier for beginners.

Thanks

Owner

jnicklas commented Sep 13, 2012

Strange, this has always worked just fine for me.

gravis commented Sep 13, 2012

I don't see any portion of code that could tell rspec to include .feature files, could it be a global config you have somewhere? I wonder if others have this problem too.

Contributor

PragTob commented Sep 13, 2012

At least it was broken some time ago, see this thread from the mailing list.

Maybe the issue with rspec was fixed in the meantime or it's time for a nice upstream improvement. Don't have time right now to look further into it, sorry :-)

edit: for reference this is the line where it is added to the pattern, which seems to work for just running rspec but not for the rake task.

Contributor

PragTob commented Sep 16, 2012

I took some time to look at it right now and described my findings in this rspec issue: rspec/rspec-core#682 let's see what they say and I'll hopefully be able to cook up a merge request in order to fix this :-)

Cheers,
Tobi

I am also having this problem, with turnip 1.1.0 and rspec 2.13.0, and it makes me sad.

Same here... it's sad that this issue is open for so long... 👎

Contributor

PragTob commented Jul 7, 2013

Well rspec doesn't want to really support that, if you take a look at the issue linked above ( rspec/rspec-core#682 ) they closed that issue and said it shouldn't work... so not exactly the best news for turnip. Sadly.

Actually they're going to remove pattern from RSpec.configure at all, so turnip will not work with newer rspec... I guess solution for that problem will fix this current issue also.

Now I fase same problem...
How can I execute all feature test?

Same here.
Rails 4 + RSpec 2.14.1 + Turnip 1.1.0 => running rspec will not check any feature files.
But, when I use spin + rspec and use spin rspec - it handles all the files.

pjg commented Jul 11, 2013

With RSpec 2.14. even if I run rspec spec -r turnip/rspec it will not load feature files from turnip :(

JonRowe commented Jul 23, 2013

This was fixed in rspec. See rspec/rspec-core#993 rspec/rspec-core#994

I checked this is fixed. thx.

JonRowe commented Jul 23, 2013

(cause the issue's still open ;) )

Owner

jnicklas commented Jul 23, 2013

Nice! Thanks @JonRowe!

@jnicklas jnicklas closed this Jul 23, 2013

For me still rake spec doesn't work. I've got:

  • rspec-core 2.14.4
  • turnip 1.1.0
  • separate turnip_helper.rb
  • and -r turnip/rspec in .rspec

Does it work for anybody?

shime commented Aug 3, 2013

@jandudulski Same here. Still happening with:

  • turnip 1.1.0
  • rspec 2.14.1
  • rspec-rails 2.14.0

Hacking it out with the suggestion from @gravis sorts it out. Having -r turnip/rspec or not doesn't matter.

JonRowe commented Aug 3, 2013

You need rspec-core 2.14.4 and the --pattern option must be set before the spec files are loaded. (Which is why --require is loaded before the specfiles)

takaokouji added a commit to smalruby/smalruby-editor that referenced this issue Nov 25, 2013

rakeでRSpecとTurnipの両方を動作できるように修正
rspecでTurnipのfeatureを実行するには'-r turnip/rspec'を.rspecに追加すれ
ばOKなのですが、rakeで実行できるようにするにはtaskを追加する必要がある。

see jnicklas/turnip#79

@gravis your solution helped me on running turnip specs on travis (using default rake task) thank you!

👍 on @gravis solution for making plain old rake work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment