Reputation: 83
describe Item do
it 'calculates price according to a special formula' do
item = Item.new('kettle', price: 200)
item.price.should == 212
end
end
Deprecation Warnings:
Using should
from rspec-expectations' old :should
syntax without explicitly enabling the syntax is deprecated. Use the new :expect
syntax or explicitly enable :should
with
config.expect_with(:rspec) { |c| c.syntax = :should }
instead. Called from E:/work/storeapp/spec/item_spec.rb:9:in `block (2 levels) in '.
If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
config.raise_errors_for_deprecations!
, and it will turn the
deprecation warnings into errors, giving you the full backtrace.
1 deprecation warning total
Finished in 0.00505 seconds (files took 0.17058 seconds to load) 1 example, 0 failures
How this warning can be avoided?
Upvotes: 0
Views: 576
Reputation: 44685
Write the test in a new style:
expect(item.price).to eq 212
BTW. it seems you might doing sth quite risk/confusing. Once you assign 200 to the attribute, it will be more than confusing to see another value returned by a getter with a same name. Have you considered leaving the original method alone and defining a new one instead (like price_with_vat)?
Upvotes: 3