Recommanded Free YOUTUBE Lecture: <% selectedImage[1] %>

RSpec Expectations

RSpec::Expectations는 테스트 케이스의 결과를 평가하기 위해서 사용한다.
account.balance.should eq(Money.new(37.42, :USD))

설치

# gem install rspec
# gem install rspec-expectations

사용법

describe Order do
  it "sums the prices of the items in its line items" do
    order = Order.new
    order.add_entry(LineItem.new(:item => Item.new(
      :price => Money.new(1.11, :USD)
    )))
    order.add_entry(LineItem.new(:item => Item.new(
      :price => Money.new(2.22, :USD),
      :quantity => 2
    )))
    expect(order.total).to eq(Money.new(5.55, :USD))
  end
end