Sha256: 6241811fe545bd01a2d6c15c7606d6cc1904fd60e05a5308307b14c9f2a73adb

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

$:.concat ['./lib']
require 'benchmark'

#
# Model

class Room
  attr_reader :name
  def initialize(name)
    @name = name
  end
end

#
# Riot

require 'riot'
Riot.silently! # Do this before any contexts are defined

context "a room" do
  setup { @room = Room.new("bed") }

  asserts("name") { @room.name }.equals("bed")
end # a room
 
#
# Test::Unit

require 'test/unit'
Test::Unit.run = false

require 'test/unit/ui/console/testrunner'

class RoomTest < Test::Unit::TestCase
  def setup
    @room = Room.new("bed")
  end

  def test_room_should_be_named_bed
    assert_equal "bed", @room.name
  end
end

#
# Shoulda

require 'rubygems'
require 'shoulda'

class ShouldaRoomTest < Test::Unit::TestCase
  def setup
    @room = Room.new("bed")
  end

  should("be named 'bed'") { assert_equal "bed", @room.name }
end

#
# Benchmarking

n = 100 * 100

Benchmark.bmbm do |x|
  x.report("Riot") do
    n.times { Riot.report }
  end

  x.report("Test::Unit") do
    n.times { Test::Unit::UI::Console::TestRunner.new(RoomTest, Test::Unit::UI::SILENT) }
  end

  x.report("Shoulda") do
    n.times { Test::Unit::UI::Console::TestRunner.new(ShouldaRoomTest, Test::Unit::UI::SILENT) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
riot-0.9.3 test/benchmark/simple_context_and_assertions.rb
riot-0.9.2 test/benchmark/simple_context_and_assertions.rb
riot-0.9.1 test/benchmark/simple_context_and_assertions.rb
riot-0.9.0 test/benchmark/simple_context_and_assertions.rb