Sha256: db3f6eaa07369749ce44fafc8358095964c5d15155c0927f6f1a649451a8592d

Contents?: true

Size: 1.27 KB

Versions: 29

Compression:

Stored size: 1.27 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/test_helper")

class TestUnitIntegrationTest < Test::Unit::TestCase
  include RR::Adapters::TestUnit # Testing against double inclusion issues
  
  def setup
    super
    @subject = Object.new
  end

  def teardown
    super
  end

  def test_using_a_mock
    mock(@subject).foobar(1, 2) {:baz}
    assert_equal :baz, @subject.foobar(1, 2)
  end
  
  def test_using_a_stub
    stub(@subject).foobar {:baz}
    assert_equal :baz, @subject.foobar("any", "thing")
  end

  def test_using_a_mock_proxy
    def @subject.foobar
      :baz
    end

    mock.proxy(@subject).foobar
    assert_equal :baz, @subject.foobar
  end

  def test_using_a_stub_proxy
    def @subject.foobar
      :baz
    end

    stub.proxy(@subject).foobar
    assert_equal :baz, @subject.foobar
  end

  def test_times_called_verification
    mock(@subject).foobar(1, 2) {:baz}
    assert_raise RR::Errors::TimesCalledError do
      teardown
    end
  end

  def test_using_assert_received
    stub(@subject).foobar(1, 2)
    @subject.foobar(1, 2)
    assert_received(@subject) {|subject| subject.foobar(1, 2)} 

    assert_raise(RR::Errors::SpyVerificationErrors::InvocationCountError) do
      assert_received(@subject) {|subject| subject.foobar(1, 2, 3)}
    end
  end
end

Version data entries

29 entries across 25 versions & 5 rubygems

Version Path
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/test_unit/test_unit_integration_test.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/test_unit/test_unit_integration_test.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/test_unit/test_unit_integration_test.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/test_unit/test_unit_integration_test.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/test_unit/test_unit_integration_test.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/test_unit/test_unit_integration_test.rb
bitclust-core-0.5.1 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/spec/rr/test_unit/test_unit_integration_test.rb
mcmire-rr-1.0.5.rc1 spec/rr/test_unit/test_unit_integration_test.rb
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rr-1.0.2/spec/rr/test_unit/test_unit_integration_test.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rr-1.0.2/spec/rr/test_unit/test_unit_integration_test.rb
rr-1.0.4 spec/rr/test_unit/test_unit_integration_test.rb
rr-1.0.3 spec/rr/test_unit/test_unit_integration_test.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rr-1.0.2/spec/rr/test_unit/test_unit_integration_test.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/rr-1.0.2/spec/rr/test_unit/test_unit_integration_test.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/rr-1.0.2/spec/rr/test_unit/test_unit_integration_test.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/rr-1.0.2/spec/rr/test_unit/test_unit_integration_test.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/rr-1.0.2/spec/rr/test_unit/test_unit_integration_test.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/rr-1.0.2/spec/rr/test_unit/test_unit_integration_test.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/rr-1.0.2/spec/rr/test_unit/test_unit_integration_test.rb
rr-1.0.2 spec/rr/test_unit/test_unit_integration_test.rb