Sha256: 4fd597362c4a6a29874acf74f88ba5222b3a054b4ec868170ba90c50bb67c5d2

Contents?: true

Size: 1.15 KB

Versions: 20

Compression:

Stored size: 1.15 KB

Contents

$:.unshift(File.dirname(__FILE__) + "/../../lib/")
require 'benchmark'

#
# Model

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

#
# Test::Unit

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

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

#
# Riot

require 'riot'

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

  asserts("name") { topic.name }.equals("bed")
end # a room

#
# Benchmarking

n = 100 * 100

Benchmark.bmbm do |x|
  x.report("Riot") do
    Riot.silently!
    Riot.alone!
    n.times { Riot.run }
  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

20 entries across 20 versions & 1 rubygems

Version Path
riot-0.12.7 test/benchmark/simple_context_and_assertions.rb
riot-0.12.6 test/benchmark/simple_context_and_assertions.rb
riot-0.12.5 test/benchmark/simple_context_and_assertions.rb
riot-0.12.4 test/benchmark/simple_context_and_assertions.rb
riot-0.12.3 test/benchmark/simple_context_and_assertions.rb
riot-0.12.2 test/benchmark/simple_context_and_assertions.rb
riot-0.12.1 test/benchmark/simple_context_and_assertions.rb
riot-0.12.0 test/benchmark/simple_context_and_assertions.rb
riot-0.12.0.pre test/benchmark/simple_context_and_assertions.rb
riot-0.11.4 test/benchmark/simple_context_and_assertions.rb
riot-0.11.4.pre test/benchmark/simple_context_and_assertions.rb
riot-0.11.3 test/benchmark/simple_context_and_assertions.rb
riot-0.11.2 test/benchmark/simple_context_and_assertions.rb
riot-0.11.1 test/benchmark/simple_context_and_assertions.rb
riot-0.11.0 test/benchmark/simple_context_and_assertions.rb
riot-0.10.13 test/benchmark/simple_context_and_assertions.rb
riot-0.10.13.pre test/benchmark/simple_context_and_assertions.rb
riot-0.10.12 test/benchmark/simple_context_and_assertions.rb
riot-0.10.12.pre test/benchmark/simple_context_and_assertions.rb
riot-0.10.11 test/benchmark/simple_context_and_assertions.rb