Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created February 23, 2015 05:59
Show Gist options
  • Save ukstudio/21e4e2e607df83f94726 to your computer and use it in GitHub Desktop.
Save ukstudio/21e4e2e607df83f94726 to your computer and use it in GitHub Desktop.
hogehgoe
RSpec.configure do |config|
config.mock_with :rspec
end
class PriceCalc
def initialize(order)
@order = order
end
def price_with_tax
@order.total_price * 1.08
end
end
describe 'Hoge' do
let(:order_mock) { double('order') }
before do
allow(order_mock).to receive(:total_price) { 1000 }
expect(order_mock).to receive(:total_price).once
end
subject { PriceCalc.new(order_mock).price_with_tax }
it { is_expected.to eq 1080 }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment