Sha256: 10b76aae1a9bf940669e66f4efc1c1903e2c52235a0f1249d9acf50ab805d88a

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

require 'test/unit'
require 'test/unit/given/strict'

class TestStrictGiven < Test::Unit::TestCase
  include Test::Unit::Given::Strict

  def test_wrong_order_then_first
    assert_raises RuntimeError do
      Then {
        @x = 4
      }
    end
  end

  def test_basics
    Given {
      @x = nil
    }
    When {
      @x = 4
    }
    Then {
      assert_equal 4,@x
    }
  end

  def test_wrong_order
    assert_raises RuntimeError do
      When {
        @x = 4
      }
    end
  end

  def test_can_reuse_blocks
    invocations = 0
    x_is_nil = Given {
      @x = nil
      invocations += 1
    }
    x_is_assigned_to_four = When {
      @x = 4
      invocations += 1
    }
    x_should_be_four = Then {
      assert_equal 4,@x
      invocations += 1
    }
    Given x_is_nil
    When x_is_assigned_to_four
    Then x_should_be_four
    assert_equal 6,invocations
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
test_unit-given-0.0.1 test/test_strict_given.rb