Created
May 8, 2015 20:35
-
-
Save 0xradical/9444093be25b08920c2b to your computer and use it in GitHub Desktop.
let_spec.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rspec' | |
| class BankAccount | |
| attr_reader :balance | |
| def initialize(initial_value = nil) | |
| @balance = initial_value || 0 | |
| end | |
| def deposit(amount) | |
| @balance += amount | |
| end | |
| end | |
| RSpec.describe BankAccount do | |
| context 'when account is new' do | |
| let(:account) { BankAccount.new(0) } | |
| before { account.deposit(10) } | |
| specify 'first example' do | |
| expect(account.balance).to eq(10) | |
| end | |
| specify 'second example' do | |
| expect(account.balance).to eq(10) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment