Skip to content

Instantly share code, notes, and snippets.

@0xradical
Created May 8, 2015 20:35
Show Gist options
  • Select an option

  • Save 0xradical/9444093be25b08920c2b to your computer and use it in GitHub Desktop.

Select an option

Save 0xradical/9444093be25b08920c2b to your computer and use it in GitHub Desktop.
let_spec.rb
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