Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add multiple attr_accessor_with_history test to part5

  • Loading branch information...
commit f8b91f8cab703323e936ca6f1b18f73c83ecbcea 1 parent 57742d2
Meck authored

Showing 1 changed file with 35 additions and 2 deletions. Show diff stats Hide diff stats

  1. +35 2 test/hw1_part5_test.rb
37 test/hw1_part5_test.rb
@@ -5,9 +5,14 @@ class Foo
5 5 attr_accessor_with_history :bar
6 6 end
7 7
  8 +class Bar
  9 + attr_accessor_with_history :foo
  10 + attr_accessor_with_history :bar
  11 +end
  12 +
8 13 class TestAdvancedOOP < Test::Unit::TestCase
9 14
10   - def test_attr_accessor_with_history
  15 + def test_single_attr_accessor_with_history
11 16 f = Foo.new
12 17 assert_not_nil f
13 18
@@ -18,7 +23,7 @@ def test_attr_accessor_with_history
18 23 assert_equal [nil, 3, :wowzo, 'boo!'], f.bar_history
19 24 end
20 25
21   - def test_attr_accessor_with_history_different_instances
  26 + def test_single_attr_accessor_with_history_different_instances
22 27 f = Foo.new
23 28 f.bar = 1
24 29 f.bar = 2
@@ -28,4 +33,32 @@ def test_attr_accessor_with_history_different_instances
28 33 assert_equal [nil, 4], f.bar_history
29 34 end
30 35
  36 + def test_multiple_attr_accessor_with_history
  37 + b = Bar.new
  38 + b.bar = 3
  39 + b.bar = :wowzo
  40 + b.bar = 'boo!'
  41 + b.foo = 4
  42 + b.foo = :woozy
  43 + b.foo = 'boom!'
  44 +
  45 + assert_equal [nil, 3, :wowzo, 'boo!'], b.bar_history
  46 + assert_equal [nil, 4, :woozy, 'boom!'], b.foo_history
  47 + end
  48 +
  49 + def test_multiple_attr_accessor_with_history_different_instances
  50 + b = Bar.new
  51 + b.bar = 1
  52 + b.bar = 2
  53 + b.foo = 3
  54 + b.foo = 4
  55 +
  56 + b = Bar.new
  57 + b.bar = 4
  58 + b.foo = 5
  59 +
  60 + assert_equal [nil, 4], b.bar_history
  61 + assert_equal [nil, 5], b.foo_history
  62 + end
  63 +
31 64 end

0 comments on commit f8b91f8

Please sign in to comment.
Something went wrong with that request. Please try again.