Reputation: 83
When I run the test “ rspec spec/cart_spec.rb ”In the console, I'll get a warning
require 'rspec'
require_relative '../app/item'
require_relative '../app/virtual_item'
require_relative '../app/antique_item'
require_relative '../app/item_container'
require_relative '../app/cart'
describe Cart do
it 'add items into the cart' do
cart = Cart.new('')
item1 = Item.new('kettle', price: 200)
item2 = Item.new('car', price: 200)
cart.add_items(item1, item2)
cart.items.should include(item1, item2)
end
end
In the console, I'll get a warning
E:\work\storeapp\spec>rspec spec/cart_spec.rb
c:/tools/rubies/ruby-2.1.5-p273/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1226:in `load': cannot load such file -- E:/work/storeapp/spec/spec/cart_s
pec.rb (LoadError)
from c:/tools/rubies/ruby-2.1.5-p273/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1226:in `block in load_spec_files'
from c:/tools/rubies/ruby-2.1.5-p273/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1224:in `each'
from c:/tools/rubies/ruby-2.1.5-p273/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1224:in `load_spec_files'
from c:/tools/rubies/ruby-2.1.5-p273/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:97:in `setup'
from c:/tools/rubies/ruby-2.1.5-p273/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:85:in `run'
from c:/tools/rubies/ruby-2.1.5-p273/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:70:in `run'
from c:/tools/rubies/ruby-2.1.5-p273/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:38:in `invoke'
from c:/tools/rubies/ruby-2.1.5-p273/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/exe/rspec:4:in `<top (required)>'
from c:/tools/rubies/ruby-2.1.5-p273/bin/rspec:23:in `load'
from c:/tools/rubies/ruby-2.1.5-p273/bin/rspec:23:in `<main>'
![enter image description here][1]
where is my mistake?
Upvotes: 0
Views: 157
Reputation: 27779
The error says that it can't find the spec file and indeed you're pointing to
spec/cart_spec.rb
... while in the spec
directory. To find it from there you need to remove spec/
:
rspec cart_spec.rb
My usual practice is to run specs from the app root. From there, your original command should work. Or you can just use an absolute path instead of a relative path.
Upvotes: 1