Sha256: 271f5ae222e9572e55c3ac6ebd7d3c8c61201587f7bea4b65b40cf5db10e5413

Contents?: true

Size: 874 Bytes

Versions: 9

Compression:

Stored size: 874 Bytes

Contents

require File.dirname(__FILE__) + '/../test_helper'

require 'http_mock'

class ObserverTest < Test::Unit::TestCase
  fixtures :contents, :blogs, :articles_tags, :tags,
           :resources, :categories, :articles_categories

  def reset_observer
    @informant = nil
    @symbol    = nil
  end

  def setup
    reset_observer
  end

  def update(informant, symbol)
    @informant = informant
    @symbol = symbol
  end

  def test_simple_observation
    art = Article.find(contents(:article1).id)
    assert art.add_observer(self)
    art.changed
    art.notify_observers(art, :test)

    assert_equal art.id, @informant.id
    assert_equal :test, @symbol
  end

  def test_content_observation
    contents(:article1).add_observer(self)
    contents(:article1).body = 'A new body'

    assert_equal contents(:article1), @informant
    assert_equal :body, @symbol
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
typo-3.99.0 test/unit/observer_test.rb
typo-3.99.3 test/unit/observer_test.rb
typo-3.99.1 test/unit/observer_test.rb
typo-3.99.2 test/unit/observer_test.rb
typo-4.0.1 test/unit/observer_test.rb
typo-4.0.0 test/unit/observer_test.rb
typo-4.0.2 test/unit/observer_test.rb
typo-3.99.4 test/unit/observer_test.rb
typo-4.0.3 test/unit/observer_test.rb