Sha256: 2dcd6ba961f190d0470d577cf6eb010631e5b1d807c518e178c31c1a576508b8

Contents?: true

Size: 1.91 KB

Versions: 17

Compression:

Stored size: 1.91 KB

Contents

require File.expand_path('../../test_helper', __FILE__)

require 'mocha/return_values'

class ReturnValuesTest < Mocha::TestCase

  include Mocha

  def test_should_return_nil
    values = ReturnValues.new
    assert_nil values.next
  end

  def test_should_keep_returning_nil
    values = ReturnValues.new
    values.next
    assert_nil values.next
    assert_nil values.next
  end

  def test_should_return_evaluated_single_return_value
    values = ReturnValues.new(SingleReturnValue.new('value'))
    assert_equal 'value', values.next
  end

  def test_should_keep_returning_evaluated_single_return_value
    values = ReturnValues.new(SingleReturnValue.new('value'))
    values.next
    assert_equal 'value', values.next
    assert_equal 'value', values.next
  end

  def test_should_return_consecutive_evaluated_single_return_values
    values = ReturnValues.new(SingleReturnValue.new('value_1'), SingleReturnValue.new('value_2'))
    assert_equal 'value_1', values.next
    assert_equal 'value_2', values.next
  end

  def test_should_keep_returning_last_of_consecutive_evaluated_single_return_values
    values = ReturnValues.new(SingleReturnValue.new('value_1'), SingleReturnValue.new('value_2'))
    values.next
    values.next
    assert_equal 'value_2', values.next
    assert_equal 'value_2', values.next
  end

  def test_should_build_single_return_values_for_each_values
    values = ReturnValues.build('value_1', 'value_2', 'value_3').values
    assert_equal 'value_1', values[0].evaluate
    assert_equal 'value_2', values[1].evaluate
    assert_equal 'value_3', values[2].evaluate
  end

  def test_should_combine_two_sets_of_return_values
    values_1 = ReturnValues.build('value_1')
    values_2 = ReturnValues.build('value_2a', 'value_2b')
    values = (values_1 + values_2).values
    assert_equal 'value_1', values[0].evaluate
    assert_equal 'value_2a', values[1].evaluate
    assert_equal 'value_2b', values[2].evaluate
  end

end

Version data entries

17 entries across 14 versions & 4 rubygems

Version Path
mocha-1.6.0 test/unit/return_values_test.rb
mocha-1.5.0 test/unit/return_values_test.rb
mocha-1.4.0 test/unit/return_values_test.rb
mocha-1.3.0 test/unit/return_values_test.rb
mocha-1.2.1 test/unit/return_values_test.rb
mocha-1.2.0 test/unit/return_values_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/test/unit/return_values_test.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/test/unit/return_values_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/test/unit/return_values_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/test/unit/return_values_test.rb
mocha-1.1.0 test/unit/return_values_test.rb
mocha-1.0.0 test/unit/return_values_test.rb
mocha-1.0.0.alpha test/unit/return_values_test.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/test/unit/return_values_test.rb
challah-1.0.0 vendor/bundle/gems/mocha-0.14.0/test/unit/return_values_test.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/test/unit/return_values_test.rb
mocha-0.14.0 test/unit/return_values_test.rb