Skip to content

Instantly share code, notes, and snippets.

@ngauthier
Created September 3, 2010 19:17
Show Gist options
  • Select an option

  • Save ngauthier/564396 to your computer and use it in GitHub Desktop.

Select an option

Save ngauthier/564396 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'test/unit'
class Call
attr_accessor :company
def initialize(opts = {})
@company = opts[:company]
raise Call::NoCompanyException unless @company
end
private
def company
@company
Redis.fetch(company.id, :name)
end
class NoCompanyException < Exception
end
end
class CallTest < Test::Unit::TestCase
def test_call_has_a_company
c = Call.new(:company => "my company")
assert_equal "my company", c.company
c = Call.new()
Redis.stubs(:fetch).with(c.id).returns("my comapny")
c.company
end
def test_call_must_have_a_company
assert_raise Call::NoCompanyException do
c = Call.new()
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment