Sha256: 01a48d0132a97f2eeb31b93defcef6b08d84fff6975c64445a216599db1b37bb

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require 'test/unit'
require File.expand_path(File.dirname(__FILE__)) + '/../lib/behaviors'
require 'stringio'

loading_developer_test_class_stdout = StringIO.new
saved_stdout = $stdout.dup
$stdout = loading_developer_test_class_stdout

class DeveloperTest
  extend Behaviors
  attr_accessor :flunk_msg, :tested_code

  should "test their code" do
    @tested_code = true
  end
  should "go to meetings"
end

$stdout = saved_stdout
loading_developer_test_class_stdout.rewind
$loading_developer_test_class_output = loading_developer_test_class_stdout.read

class BehaviorsTest < Test::Unit::TestCase


  def setup
    @target = DeveloperTest.new
    assert_nil @target.tested_code, "block called too early"
  end

  #
  # TESTS
  #
  def test_should_called_with_a_block_defines_a_test
    assert @target.methods.include?("test_should_test their code"), "Missing test method"

    @target.send("test_should_test their code")

    assert @target.tested_code, "block not called"
  end

  def test_should_called_without_a_block_does_not_create_a_test_method
    assert !@target.methods.include?("test_should_go to meetings"), "Should not have method"
  end

  def test_should_called_without_a_block_will_give_unimplemented_output_when_class_loads
    unimplemented_output = "UNIMPLEMENTED CASE: Developer should go to meetings"
    assert_match /#{unimplemented_output}/, $loading_developer_test_class_output
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
minilab-1.1.0-x86-mswin32-60 vendor/behaviors/test/behaviors_test.rb
minilab-1.0.0-mswin32 vendor/behaviors/test/behaviors_test.rb
behaviors-1.0.0 test/behaviors_test.rb