Sha256: 82496aa2b4ccce5c3e15dc67008421bfd585aa6747b3814c104a882459d09bec

Contents?: true

Size: 1.93 KB

Versions: 94

Compression:

Stored size: 1.93 KB

Contents

require File.join(File.dirname(__FILE__), "..", "test_helper")

require 'mocha/return_values'

class ReturnValuesTest < Test::Unit::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

94 entries across 94 versions & 11 rubygems

Version Path
floehopper-mocha-0.9.3.20081220175348 test/unit/return_values_test.rb
floehopper-mocha-0.9.3.20081230175553 test/unit/return_values_test.rb
floehopper-mocha-0.9.4.20090128164727 test/unit/return_values_test.rb
floehopper-mocha-0.9.5.20090201123802 test/unit/return_values_test.rb
floehopper-mocha-0.9.6.20090629164857 test/unit/return_values_test.rb
floehopper-mocha-0.9.6.20090629165308 test/unit/return_values_test.rb
floehopper-mocha-0.9.6.20090701111305 test/unit/return_values_test.rb
floehopper-mocha-0.9.7.20090701124354 test/unit/return_values_test.rb
gsterndale-warrant-0.2.0 test/rails_root/vendor/gems/mocha-0.9.4/test/unit/return_values_test.rb
gsterndale-warrant-0.3.0 test/rails_root/vendor/gems/mocha-0.9.4/test/unit/return_values_test.rb
hashrocket-clearance-0.4.0 test/rails_root/vendor/gems/mocha-0.9.1/test/unit/return_values_test.rb
hashrocket-clearance-0.4.1 test/rails_root/vendor/gems/mocha-0.9.1/test/unit/return_values_test.rb
hashrocket-clearance-0.4.2 test/rails_root/vendor/gems/mocha-0.9.1/test/unit/return_values_test.rb
hashrocket-clearance-0.4.3 test/rails_root/vendor/gems/mocha-0.9.1/test/unit/return_values_test.rb
jferris-mocha-0.9.5.0.1240002286 test/unit/return_values_test.rb
jferris-mocha-0.9.5.0.1240351621 test/unit/return_values_test.rb
jferris-mocha-0.9.5.0.1241126838 test/unit/return_values_test.rb
jferris-mocha-0.9.7.0.1247796736 test/unit/return_values_test.rb
jferris-mocha-0.9.7.20090701124354 test/unit/return_values_test.rb
jferris-mocha-0.9.7.20090911190113 test/unit/return_values_test.rb