Sha256: e751acc4eb9ff2d932fc87d628c1831e1e0d8f066103f482c0386905e49dd8af

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

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

class ResultTest < Test::Unit::TestCase
  context "a Result instance" do
    setup do
      @controller = mock()
      @changes = { "attr" => ["old", "new"] }

      @filter = TrackChanges::Result.new(:model, @controller, @changes)
    end

    should "define given symbol as method" do
      @controller.expects(:instance_variable_get).with() {|v| v == "@model"}.returns(:ivar_result)
      assert_equal :ivar_result, @filter.model
    end

    should "send method_missing calls to controller" do
      @controller.expects(:bogus_method).returns(:got_it)
      assert_equal :got_it, @filter.bogus_method
    end

    should "get @current_user from controller" do
      @controller.expects(:instance_variable_get).with() {|v| v == "@current_user"}.returns(:ivar_result)
      assert_equal :ivar_result, @filter.current_user
    end

    should "return changes" do
      assert_equal @changes, @filter.changes
    end

    should "return controller" do
      assert_equal @controller, @filter.controller
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
smajn-track_changes-0.3.0 test/result_test.rb
track_changes-0.5.0 test/result_test.rb
track_changes-0.4.1 test/result_test.rb
track_changes-0.4.0 test/result_test.rb
track_changes-0.3.2 test/result_test.rb
track_changes-0.3.0 test/result_test.rb