After installing rspec/ZenTest and running autospec, it runs my specs the first time as expected. After making a change to one of my specs and upon running the second time I get the following results:
/usr/bin/ruby1.8 /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/bin/spec --autospec /home/schambers/Projects/notebook/spec/models/user_spec.rb -O spec/spec.opts
/usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/formatter/progress_bar_formatter.rb:17:in `flush': Broken pipe (Errno::EPIPE)
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/formatter/progress_bar_formatter.rb:17:in `example_passed'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/reporter.rb:136:in `example_passed'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/reporter.rb:136:in `each'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/reporter.rb:136:in `example_passed'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/reporter.rb:31:in `example_finished'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/example/example_methods.rb:55:in `execute'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:214:in `run_examples'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:212:in `each'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:212:in `run_examples'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:103:in `run'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:23:in `run'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:22:in `each'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:22:in `run'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:152:in `run_examples'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run'
from /usr/lib/ruby/gems/1.8/gems/rspec-1.3.0/bin/spec:5
Has anyone run into this or know what the heck is going on here?
Thanks
Progress Bar is trying to print stuff to TTY so that it can show you your pretty spec progress output while it's running your tests. I am guessing forking the process using autospec inherits STDOUT file descriptor, but can't write to it, so it throws the pipe error.
Try removing progress bar from RSpec helper. Alternatively, try re-initializing progress bar plugin after fork.
Related
I have two styles of spec in a single folder, one of which uses a full-fat rails environment, with rspec, the other is a light-weight helper which requires gems individually.
Recently I've had some problems running these together in Rubymine.
Right-clicking on a single file of either style runs fine. Right clicking the folder and selecting "Run > All specs in folder" has been returning this error for each spec:
NameError: undefined local variable or method `mocha_setup' for #<RSpec::Core::ExampleGroup::Nested_1:0x0000000ca26d70>
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-expectations-2.14.5/lib/rspec/matchers/method_missing.rb:9:in `method_missing'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/mocking/with_mocha.rb:40:in `setup_mocks_for_rspec'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/example.rb:299:in `run_before_each'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/example.rb:113:in `block in run'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/example.rb:254:in `with_around_each_hooks'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/example.rb:111:in `run'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/example_group.rb:390:in `block in run_examples'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/example_group.rb:386:in `map'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/example_group.rb:386:in `run_examples'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/example_group.rb:371:in `run'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/command_line.rb:28:in `map'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/command_line.rb:28:in `block in run'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/reporter.rb:58:in `report'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/command_line.rb:25:in `run'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/runner.rb:80:in `run'
/home/ajfaraday/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.14.5/lib/rspec/core/runner.rb:17:in `block in autorun'
This had run together perfectly well until very recently.
I can run all of the specs from the command line without any issues:
rspec --pattern spec/models/auto_ordering/*_spec.rb
This seems to be something specific about running this folder within Rubymine. I've tried invalidating my caches and restarting the IDE. I've tried deleting the configuration for running that folder.
Does anyone know what might be causing this?
Update: I've since discovered that this seems to happen sporadically when calling it through the command line, also.
I eventually solved this issue:
It was nothing to do with Rubymine, it was a load-order issue.
Rubymine was running files in strict alphabetical order, the CLI was running them in an arbitrary order
When the full rails environment was loading first, it was working fine.
When my lean environment was loading first, it was missing this piece of config:
RSpec.configure do |config|
config.mock_framework = :mocha
end
I added this to my light-weight spec helper and I can now run these files in any order.
I installed rspec and also did rspec --init. (I've gone through directions from here http://rspec.codeschool.com/levels/1 multiple times).
However, every time I try to run a spec from my command line, it won't load (please see below). Please help if you know what may be going wrong.
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- zombie (LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:inrequire'
from /Users/Qureshi/spec/lib/zombie_spec.rb:2:in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/lib/rspec/core/configuration.rb:1226:inload'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/lib/rspec/core/configuration.rb:1226:in block in load_spec_files'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/lib/rspec/core/configuration.rb:1224:ineach'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/lib/rspec/core/configuration.rb:1224:in load_spec_files'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/lib/rspec/core/runner.rb:97:insetup'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/lib/rspec/core/runner.rb:85:in run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/lib/rspec/core/runner.rb:70:inrun'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/lib/rspec/core/runner.rb:38:in invoke'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/exe/rspec:4:in'
from /usr/bin/rspec:23:in load'
from /usr/bin/rspec:23:in'
Try putting the following at the top of your spec_helper.rb:
require_relative '../lib/zombie'
Be sure your terminal's current folder is Users/Qureshi then run the command rspec spec
If it does not work, your file (or entire folder) is access blocked, or does not exist in /Users/Qureshi/spec/lib/
I recently started the "Intro to Rails" screencast on nettuts. So I am not very familiar with Rails obviously and only know a little about Ruby. Everything else in the code will run correctly however when I run guard-rspec it displays this:
/Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/minitest/unit.rb:1013:in `block in process_args': invalid option: -f (OptionParser::InvalidOption)
from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/minitest/unit.rb:992:in `new'
from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/minitest/unit.rb:992:in `process_args'
from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/minitest/unit.rb:1042:in `_run'
from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/minitest/unit.rb:1035:in `run'
from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/test/unit.rb:21:in `run'
from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/test/unit.rb:774:in `run'
from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/test/unit.rb:366:in `block (2 levels) in autorun'
from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/test/unit.rb:27:in `run_once'
from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/test/unit.rb:365:in `block in autorun'
I am not very sure what this error means and how do I get rid of it?
Seems to be caused by the turn gem (I suspect you have it). Remove it from your Gemfile, run bundle again, and then try your tests with guard once more. This worked for me.
Was having a similar issue getting Test::Unit errors when running Guard:
/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/test/unit.rb:49:in `process_args': invalid option: -f (OptionParser::InvalidOption)
According to https://github.com/guard/guard/issues/170 this was caused by having the shoulda gem included in my Gemfile. Changing this to should-matchers fixed the issue for me without having to lose the loveliness of shoulda.
Studying the Nettuts 'Intro to Rails' Gemfile it seems to contain the 'turn' gem which is minitest-based. So removing this from your Gemfile should help, as #kladd suggests.
I'm following Hartl's guide to Ruby on Rails, and I'm currently trying to set up "guard" and "spork" for automating "rspec" testing. When I try to run
bundle exec rspec spec/requests/static_pages_spec.rb
I get the following errors:
/home/throne/.rvm/gems/ruby-1.9.3-p392#rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:434:in `require': cannot load such file -- b (LoadError)
from /home/throne/.rvm/gems/ruby-1.9.3-p392#rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:434:in `block in requires='
from /home/throne/.rvm/gems/ruby-1.9.3-p392#rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:434:in `map'
from /home/throne/.rvm/gems/ruby-1.9.3-p392#rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:434:in `requires='
from /home/throne/.rvm/gems/ruby-1.9.3-p392#rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/configuration_options.rb:20:in `block in configure'
from /home/throne/.rvm/gems/ruby-1.9.3-p392#rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/configuration_options.rb:19:in `each'
from /home/throne/.rvm/gems/ruby-1.9.3-p392#rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/configuration_options.rb:19:in `configure'
from /home/throne/.rvm/gems/ruby-1.9.3-p392#rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:21:in `run'
from /home/throne/.rvm/gems/ruby-1.9.3-p392#rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
from /home/throne/.rvm/gems/ruby-1.9.3-p392#rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'
I looked at other solutions for people who had similar kinds of problems (things like reinstalling gems, using absolute paths and fixing do / end statements in the target file), but none of them seemed to even change the issue. Thanks for any help!
Rewrite your Gemfile. Change 'selenium-webdriver' to '~> 2.35.1', reinstall bundle and everything has to be OK!
I had same error when tried to run test with single dash in params (need to run with --rdb).
This page came up when I was researching the same problem using the same tutorial. After some added investigation, I discovered that I was typing only a single dash on the --drb option. With a single dash rspec enables debugging and tries to require the file 'b'. Very different from connecting to a DRb server :-
I am trying to be a better tester. Having so much problems with the set up that I wonder if it's worth it.
Can somebody please help?
I am running Rails 3.1, rspec, guard capybara and spork on a windows box. I use the guard-spork gem. This what I get when I run bundle exec guard
Look at the line "Finished in 421.87 seconds". Thats one test!
I see I get an error with guard-spork complaining about no fork support (Windows problem), but later this line "./magazine_slave.rb:22:in `run'", should indicate that magazine_slave runs (Windows runs spork with magazine instead of fork).
Any Ideas?
Guard is now watching at 'c:/Users/Andreas/My Documents/Aptana Studio 3 workspace/maktaba'
'awk' is not recognized as an internal or external command,
operable program or batch file.
'awk' is not recognized as an internal or external command,
operable program or batch file.
Starting Spork for Test::Unit & RSpec
ERROR: Guard::Spork failed to achieve its <start>, exception was:
NotImplementedError: fork() function is unimplemented on this machine
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-spork-0.3.1/lib/guard/spork/runner.rb:40:in `fork'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-spork-0.3.1/lib/guard/spork/runner.rb:40:in `spawn_child'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-spork-0.3.1/lib/guard/spork/runner.rb:23:in `launch_sporks'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-spork-0.3.1/lib/guard/spork.rb:17:in `start'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:322:in `send'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:322:in `run_supervised_task'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:320:in `catch'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:320:in `run_supervised_task'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:153:in `start'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:254:in `run_on_guards'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:253:in `each'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:253:in `run_on_guards'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:252:in `catch'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:252:in `run_on_guards'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:251:in `each'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:251:in `run_on_guards'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:152:in `start'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard/cli.rb:68:in `start'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor/task.rb:22:in `send'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/bin/guard:6
c:/Ruby/Ruby187/lib/ruby/gems/1.8/bin/guard:19:in `load'
c:/Ruby/Ruby187/lib/ruby/gems/1.8/bin/guard:19
Guard::Spork has just been fired
Guard::RSpec is running, with RSpec 2!
Running all specs
F
Failures:
1) UserCruds Creates a new user
Failure/Error: click_button "Submit"
ActionView::Template::Error:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.map
# ./app/views/users/_form.html.erb:38:in `_app_views_users__form_html_erb___24339687_119563452'
# ./app/views/users/_form.html.erb:3:in `_app_views_users__form_html_erb___24339687_119563452'
# ./app/views/users/new.html.erb:3:in `_app_views_users_new_html_erb___963176717_119608284'
# ./app/controllers/users_controller.rb:52
# ./app/controllers/users_controller.rb:47:in `create'
# (eval):2:in `send'
# (eval):2:in `click_button'
# ./spec/requests/user_cruds_spec.rb:16
# ./magazine_slave.rb:22:in `run'
# magazine_slave_provider.rb:17
Finished in 421.87 seconds
1 example, 1 failure
Because rspec loads the rails environment, it's slow. The more gems you have the slower it gets
Thats why spork is a great tool. It loads the rails environment and guard can look for the changes without reloading the rails environment. But there is a bug in the guard-spork gem. It does not work with windows because it depends on fork. Even tough spork do not use fork on windows guard-spork does. Fork is not supported on non-UNIX systems.
I researched the problem and ended up with a different aproach. I facture out the logic to the lib folder and do not include the spec_helper file in the specs. Then rails does not get loaded, only the spesific test logic. This is fast and force me to write more readable code.
Check out this video on a talk by Cory Haines, for more on the subject.