it 'add items into the container' do
item1 = Item.new('kettle', price: 200)
item2 = Item.new('kettle', price: 300)
@box.add_item(item1)
@box.add_item(item2)
@box.items.should have(2).items
end
这支球队可能会犯错吗? " @ box.items.should有(2).items" 。 在控制台中,我会收到警告
**E:\work\storeapp\spec>rspec item_container_spec.rb
F
Failures:
1) ItemContainer add items into the container
Failure/Error: @box.items.should have(2).items
NoMethodError:
undefined method `have' for #<RSpec::ExampleGroups::ItemContainer:0x2419908>
# ./item_container_spec.rb:27:in `block (2 levels) in <top (required)>'
Finished in 0 seconds (files took 0.23234 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./item_container_spec.rb:22 # ItemContainer add items into the container**
我的错误在哪里?
答案 0 :(得分:1)
我打赌你已经安装了rspec 3.0。
have
系列匹配器已在RSpec 2.99中弃用,并且自RSpec 3.0起已移至单独的rspec-collection_matchers gem。
看看here。