Permalink
Browse files

Convert to minispec

  • Loading branch information...
1 parent 89fadd5 commit da416c1de2e61db6ad1dd325d9455c0fea9ff65f @copiousfreetime committed Mar 13, 2013
View
@@ -8,7 +8,7 @@ This.homepage = "http://github.com/copiousfreetime/#{ This.name }"
This.ruby_gemspec do |spec|
spec.add_development_dependency( 'rake' , '~> 10.0.3')
- spec.add_development_dependency( 'rspec' , '~> 2.13.0' )
+ spec.add_development_dependency( 'minitest' , '~> 4.6.2' )
spec.add_development_dependency( 'rdoc' , '~> 4.0' )
spec.add_development_dependency( 'json' , '~> 1.7.7' )
spec.add_development_dependency( 'rake-compiler', '~> 0.8.3' )
View
@@ -5,10 +5,10 @@
d = Hitimes.measure do
sleep 0.2
end
- d.should be_within(0.02).of(0.2)
+ d.must_be_close_to(0.2, 0.002)
end
it "raises an error if measure is called with no block" do
- lambda{ Hitimes.measure }.should raise_error( Hitimes::Error, /\ANo block given to Interval.measure\Z/ )
+ lambda{ Hitimes.measure }.must_raise( Hitimes::Error )
end
end
View
@@ -3,88 +3,88 @@
describe Hitimes::Interval do
it "raises an error if duration is called on a non-started interval" do
i = Hitimes::Interval.new
- lambda{ i.duration }.should raise_error( Hitimes::Error, /\AAttempt to report a duration on an interval that has not started\Z/ )
+ lambda{ i.duration }.must_raise( Hitimes::Error, /\AAttempt to report a duration on an interval that has not started\Z/ )
end
it "raises an error if stop is called on a non-started interval" do
i = Hitimes::Interval.new
- lambda { i.stop }.should raise_error( Hitimes::Error, /\AAttempt to stop an interval that has not started\Z/ )
+ lambda { i.stop }.must_raise( Hitimes::Error, /\AAttempt to stop an interval that has not started\Z/ )
end
it "knows if it has been started" do
i = Hitimes::Interval.new
- i.should_not be_started
+ i.started?.must_equal false
i.start
- i.should be_started
+ i.started?.must_equal true
end
it "knows if it has been stopped" do
i = Hitimes::Interval.new
i.start
- i.should_not be_stopped
+ i.stopped?.must_equal false
i.stop
- i.should be_stopped
+ i.stopped?.must_equal true
end
it "knows if it is currently running" do
i = Hitimes::Interval.new
- i.should_not be_running
+ i.running?.must_equal false
i.start
- i.should be_running
+ i.running?.must_equal true
i.stop
- i.should_not be_running
+ i.running?.must_equal false
end
it "can time a block of code" do
d = Hitimes::Interval.measure do
sleep 0.2
end
- d.should be_within(0.02).of(0.2)
+ d.must_be_close_to(0.2, 0.002)
end
it "raises an error if measure is called with no block" do
- lambda{ Hitimes::Interval.measure }.should raise_error( Hitimes::Error, /\ANo block given to Interval.measure\Z/ )
+ lambda{ Hitimes::Interval.measure }.must_raise( Hitimes::Error, /\ANo block given to Interval.measure\Z/ )
end
it "creates an interval via #now" do
i = Hitimes::Interval.now
- i.should be_started
- i.should_not be_stopped
+ i.started?.must_equal true
+ i.stopped?.must_equal false
end
it "calling duration multiple times returns successivly grater durations" do
i = Hitimes::Interval.new
i.start
y = i.duration
z = i.duration
- z.should > y
+ z.must_be :>, y
end
it "calling start multiple times on has no effect after the first call" do
i = Hitimes::Interval.new
- i.start.should be == true
+ i.start.must_equal true
x = i.start_instant
- i.start_instant.should be > 0
- i.start.should be == false
- x.should == i.start_instant
+ i.start_instant.must_be :>, 0
+ i.start.must_equal false
+ x.must_equal i.start_instant
end
it "returns the duration on the first call to stop" do
i = Hitimes::Interval.now
d = i.stop
- d.should be_instance_of( Float )
+ d.must_be_instance_of( Float )
end
it "calling stop multiple times on has no effect after the first call" do
i = Hitimes::Interval.new
- i.start.should be == true
+ i.start.must_equal true
i.stop
x = i.stop_instant
- i.stop_instant.should be > 0
- i.stop.should be == false
- x.should == i.stop_instant
+ i.stop_instant.must_be :>, 0
+ i.stop.must_equal false
+ x.must_equal i.stop_instant
end
@@ -93,26 +93,26 @@
i.start
x = i.stop
y = i.duration
- i.stop.should be == false
+ i.stop.must_equal false
z = i.duration
- x.should be == y
- x.should be == z
+ x.must_equal y
+ x.must_equal z
- y.should be == z
+ y.must_equal z
end
it "can return how much time has elapsed from the start without stopping the interval" do
i = Hitimes::Interval.new
i.start
x = i.duration_so_far
- i.should be_running
+ i.running?.must_equal true
y = i.duration_so_far
i.stop
- x.should be < y
- x.should be < i.duration
- y.should be < i.duration
+ x.must_be :<, y
+ x.must_be :<, i.duration
+ y.must_be :<, i.duration
end
describe "#split" do
@@ -121,14 +121,14 @@
i = Hitimes::Interval.new
i.start
i2 = i.split
- i.object_id.should_not == i2.object_id
+ i.object_id.wont_equal i2.object_id
end
it "with the stop instant equivialent to the previous Interval's start instant" do
i = Hitimes::Interval.new
i.start
i2 = i.split
- i.stop_instant.should == i2.start_instant
+ i.stop_instant.must_equal i2.start_instant
end
end
View
@@ -6,22 +6,22 @@
end
it 'has a name' do
- @metric.name.should be == "testing"
+ @metric.name.must_equal "testing"
end
it "has associated data from initialization" do
m = Hitimes::Metric.new( "more-data", 'foo' => 'bar', 'this' => 'that' )
- m.additional_data['foo'].should be == 'bar'
- m.additional_data['this'].should be == 'that'
+ m.additional_data['foo'].must_equal 'bar'
+ m.additional_data['this'].must_equal 'that'
m = Hitimes::Metric.new( "more-data", { 'foo' => 'bar', 'this' => 'that' } )
- m.additional_data['foo'].should be == 'bar'
- m.additional_data['this'].should be == 'that'
+ m.additional_data['foo'].must_equal 'bar'
+ m.additional_data['this'].must_equal 'that'
end
it "initially has no sampling times" do
- @metric.sampling_start_time.should be == nil
- @metric.sampling_stop_time.should be == nil
+ @metric.sampling_start_time.must_be_nil
+ @metric.sampling_stop_time.must_be_nil
end
end
View
@@ -19,18 +19,18 @@ def run_with_scissors( stats, threads, iters )
if (not defined? RUBY_ENGINE) or (RUBY_ENGINE == "ruby") then
it "Hitimes::Stats is threadsafe" do
stats = run_with_scissors( ::Hitimes::Stats.new, @threads, @iters )
- stats.count.should== @final_value
+ stats.count.must_equal @final_value
end
else
it "Hitimes::Stats is not threadsafe" do
stats = run_with_scissors( ::Hitimes::Stats.new, @threads, @iters )
- stats.count.should_not == @final_value
+ stats.count.wont_equal @final_value
end
end
it "has a threadsafe update" do
stats = run_with_scissors( ::Hitimes::MutexedStats.new, @threads, @iters )
- stats.count.should == @final_value
+ stats.count.must_equal @final_value
end
end
View
@@ -2,10 +2,10 @@
describe Hitimes::Paths do
it "can access the root dir of the project" do
- Hitimes::Paths.root_dir.should == File.expand_path( File.join( File.dirname( __FILE__ ), ".." ) ) + ::File::SEPARATOR
+ Hitimes::Paths.root_dir.must_equal File.expand_path( File.join( File.dirname( __FILE__ ), ".." ) ) + ::File::SEPARATOR
end
it "can access the lib path of the project" do
- Hitimes::Paths.lib_path.should == File.expand_path( File.join( File.dirname( __FILE__ ), "..", "lib" ) ) + ::File::SEPARATOR
+ Hitimes::Paths.lib_path.must_equal File.expand_path( File.join( File.dirname( __FILE__ ), "..", "lib" ) ) + ::File::SEPARATOR
end
end
View
@@ -4,6 +4,8 @@
SimpleCov.start if ENV['COVERAGE']
end
-require 'rspec/autorun'
+gem 'minitest'
require 'hitimes'
+require 'minitest/autorun'
+require 'minitest/pride'
View
@@ -10,89 +10,89 @@
end
it "is initialized with 0 values" do
- @stats.count.should be == 0
- @stats.min.should be == 0.0
- @stats.max.should be == 0.0
- @stats.sum.should be == 0.0
- @stats.rate.should be == 0.0
+ @stats.count.must_equal 0
+ @stats.min.must_equal 0.0
+ @stats.max.must_equal 0.0
+ @stats.sum.must_equal 0.0
+ @stats.rate.must_equal 0.0
end
it "calculates the mean correctly" do
- @full_stats.mean.should be == 2.0
+ @full_stats.mean.must_equal 2.0
end
it "calculates the rate correctly" do
- @full_stats.rate.should be == 0.5
+ @full_stats.rate.must_equal 0.5
end
it "tracks the maximum value" do
- @full_stats.max.should be == 3.0
+ @full_stats.max.must_equal 3.0
end
it "tracks the minimum value" do
- @full_stats.min.should be == 1.0
+ @full_stats.min.must_equal 1.0
end
it "tracks the count" do
- @full_stats.count.should be == 3
+ @full_stats.count.must_equal 3
end
it "tracks the sum" do
- @full_stats.sum.should be == 6.0
+ @full_stats.sum.must_equal 6.0
end
it "calculates the standard deviation" do
- @full_stats.stddev.should be == 1.0
+ @full_stats.stddev.must_equal 1.0
end
it "calculates the sum of squares " do
- @full_stats.sumsq.should be == 14.0
+ @full_stats.sumsq.must_equal 14.0
end
describe "#to_hash " do
it "converts to a Hash" do
h = @full_stats.to_hash
- h.size.should be == ::Hitimes::Stats::STATS.size
- h.keys.sort.should be == ::Hitimes::Stats::STATS
+ h.size.must_equal ::Hitimes::Stats::STATS.size
+ h.keys.sort.must_equal ::Hitimes::Stats::STATS
end
it "converts to a limited Hash if given arguments" do
h = @full_stats.to_hash( "min", "max", "mean" )
- h.size.should be == 3
- h.keys.sort.should be == %w[ max mean min ]
+ h.size.must_equal 3
+ h.keys.sort.must_equal %w[ max mean min ]
h = @full_stats.to_hash( %w[ count rate ] )
- h.size.should be == 2
- h.keys.sort.should be == %w[ count rate ]
+ h.size.must_equal 2
+ h.keys.sort.must_equal %w[ count rate ]
end
it "raises NoMethodError if an invalid stat is used" do
- lambda { @full_stats.to_hash( "wibble" ) }.should raise_error( NoMethodError )
+ lambda { @full_stats.to_hash( "wibble" ) }.must_raise( NoMethodError )
end
end
describe "#to_json" do
it "converts to a json string" do
j = @full_stats.to_json
h = JSON.parse( j )
- h.size.should be == ::Hitimes::Stats::STATS.size
- h.keys.sort.should be == ::Hitimes::Stats::STATS
+ h.size.must_equal ::Hitimes::Stats::STATS.size
+ h.keys.sort.must_equal ::Hitimes::Stats::STATS
end
it "converts to a limited Hash if given arguments" do
j = @full_stats.to_json( "min", "max", "mean" )
h = JSON.parse( j )
- h.size.should be == 3
- h.keys.sort.should be == %w[ max mean min ]
+ h.size.must_equal 3
+ h.keys.sort.must_equal %w[ max mean min ]
j = @full_stats.to_json( %w[ count rate ] )
h = JSON.parse( j )
- h.size.should be == 2
- h.keys.sort.should be == %w[ count rate ]
+ h.size.must_equal 2
+ h.keys.sort.must_equal %w[ count rate ]
end
it "raises NoMethodError if an invalid stat is used" do
- lambda { @full_stats.to_json( "wibble" ) }.should raise_error( NoMethodError )
+ lambda { @full_stats.to_json( "wibble" ) }.must_raise( NoMethodError )
end
end
end
Oops, something went wrong.

0 comments on commit da416c1

Please sign in to comment.