I am trying to run rspec
only for Ruby (not Rails), for a simple Ruby file. I'm following Tut+ TDD Testing with Ruby.
I have a competition
directory with a lib
folder and spec
folder.
├── lib
│ ├── competition.rb
│ └── team.rb
└── spec
└── competition_spec.rb
When I run rspec
, I got this error. I could've sworn the rspec work before. I don't know what happened.
competition :> rspec spec
/Users/akh88/.rvm/gems/ruby-1.9.3-p547/gems/rspec-core-> 3.0.2/lib/rspec/core/formatters.rb:167:in `find_formatter': Formatter 'nested' unknown - maybe you meant 'documentation' or 'progress'?. (ArgumentError)
competition_spec.rb
require_relative "../lib/competiiton.rb"
require_relative "../lib/team.rb"
describe Competition do
let(:competition) {Competition.new}
let(:team) {Team.new}
context "having no questions" do
before { competition.questions = [] }
it "doesn't accept any teams" do
expect do
team.enter_competition(competition)
end.to raise_error Competition::Closed
end
end
end
My rvm
default Ruby version is 1.9.1 on Mac OSX 10.9.4.
The nested
formatter was used in RSpec 1. This was renamed documentation
in RSpec 2.
Maybe you have specified nested
on the command line or in a .rspec
file? Then you need to specify --format documentation
instead.
Have you set config.formatter = nested
somewhere, probably your spec_helper.rb
file? Remove it.
You could have updated the RSpec gem from v1 (the command to run tests changed from spec
to rspec
though so that's hard to miss). You can check versions with gem list rspec
.
Alternatively, you could be missing the load of a custom formatter you happened to call nested
.
My .rspec file only had
--color
and I was still getting this error.
I explicitly set it to
--format documentation --color
And now it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With