Sha256: 49e1388c88b0d3bd024e69bb3b14f8e2b2a7b6e0e173bb6226573a12f9b38af5

Contents?: true

Size: 1.34 KB

Versions: 16

Compression:

Stored size: 1.34 KB

Contents

#!/usr/bin/env ruby

require 'test/test_setup'

class DummyModel
end

class ChildModel < DummyModel
end

######################################################################
class TestFlexModel < Test::Unit::TestCase
  include FlexMock::TestCase

  def test_initial_conditions
    model = flexmock(:model, DummyModel)
    assert_match(/^DummyModel_\d+/, model.flexmock_name)
    assert_equal model.id.to_s, model.to_params
    assert ! model.new_record?
    assert model.is_a?(DummyModel)
    # TODO: Make these work!!!
    assert_equal DummyModel, model.class
    assert model.instance_of?(DummyModel)
    assert model.kind_of?(DummyModel)
  end

  def test_classifying_mock_models
    model = flexmock(:model, ChildModel)

    assert model.kind_of?(ChildModel)
    assert model.instance_of?(ChildModel)

    assert model.kind_of?(DummyModel)
    assert ! model.instance_of?(DummyModel)
  end

  def test_mock_models_have_different_ids
    m1 = flexmock(:model, DummyModel)
    m2 = flexmock(:model, DummyModel)
    assert m2.id != m1.id
  end

  def test_mock_models_can_have_quick_defs
    model = flexmock(:model, DummyModel, :xyzzy => :ok)
    assert_equal :ok, model.xyzzy
  end

  def test_mock_models_can_have_blocks
    model = flexmock(:model, DummyModel) do |m|
      m.should_receive(:xyzzy => :okdokay)
    end
    assert_equal :okdokay, model.xyzzy
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
flexmock-1.3.3 test/flexmodel_test.rb
flexmock-1.3.2 test/flexmodel_test.rb
flexmock-1.3.1 test/flexmodel_test.rb
flexmock-1.3.0 test/flexmodel_test.rb
flexmock-1.2.0 test/flexmodel_test.rb
flexmock-1.1.0 test/flexmodel_test.rb
flexmock-1.0.4 test/flexmodel_test.rb
flexmock-1.0.3 test/flexmodel_test.rb
flexmock-1.0.2 test/flexmodel_test.rb
flexmock-1.0.1 test/flexmodel_test.rb
flexmock-1.0.0 test/flexmodel_test.rb
flexmock-1.0.0.beta.4 test/flexmodel_test.rb
flexmock-1.0.0.beta.3 test/flexmodel_test.rb
flexmock-1.0.0.beta.2 test/flexmodel_test.rb
flexmock-1.0.0.beta.1 test/flexmodel_test.rb
flexmock-0.9.0 test/flexmodel_test.rb