difference in rspec behavior when no arguments provided

15 views
Skip to first unread message

Artie

unread,
Dec 20, 2016, 5:55:06 PM12/20/16
to rspec
Hello!

Maybe somebody with more experience can see what's up with the different invocations of rspec? 

I set up a new Rails app environment and noticed that when I run `rspec` alone on the command like I get a complaint from rails active_support:

   active_support/dependencies.rb cannot load such a file -- watir (LoadError)

for which, in the traceback, line 3 of watir_smoketest_spec.rb is specified as the culprit:
    require 'watir'

Yet, when I turn rspec with a argument: 
   `rspec spec/features/watir_smoketest_spec.rb`

Watir is found and browser windows start popping up, executing the code stored in 'spec/features/watir_smoketest_spec.rb'; which is the example Google search from the Watir home page.

Why is there such a striking difference in behavior? What can I learn from this?  

What article/doc should I be reading? :)

Thank you for reading and wanting to help.

--az

Myron Marston

unread,
Dec 20, 2016, 6:06:16 PM12/20/16
to rs...@googlegroups.com

The only difference between rspec and rspec path/to/file is that rspec loads all files matching the default pattern (spec/**/*_spec.rb) where as rspec path/to/file loads only the specified file. I suspect that when you run rspec path/to/file you might not be using bundler to manage and isolate your load path, whereas raw rspec is probably booting rails and loading using bundler. If watir is installed as a system gem but is not in your bundle then this behavior would make sense.

HTH,
Myron


--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+unsubscribe@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/1260462d-af2f-4fc9-9ef3-ef6579fac77f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Artie

unread,
Dec 20, 2016, 6:31:08 PM12/20/16
to rspec
That is exactly correct. This is great. :)
The behavior went away after I simply added an entry for the Watir gem to Gemfile and ran bundler. 
Thank you, Myron, for the bright light you cast! I owe you a dinner and beverage! 
A little more Rails knowledge seems to go a long way and makes everything better.

BTW, is the IRC channel, #rspec, alive on freenode, or elsewhere?

thx!
az
Reply all
Reply to author
Forward
0 new messages