Created
September 3, 2010 19:17
-
-
Save ngauthier/564396 to your computer and use it in GitHub Desktop.
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 '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