spec/spec.sane.rb in sane-0.22.0 vs spec/spec.sane.rb in sane-0.23.0

- old
+ new

@@ -1,10 +1,16 @@ $:.unshift File.expand_path('../lib') require 'rubygems' require File.dirname(__FILE__) + '/../lib/sane' -require 'spec/autorun' +begin + require 'spec/autorun' +rescue LoadError + require 'rspec' +end +require 'fileutils' + class Object alias :yes :should # a.yes == [3] def yes! self end @@ -79,11 +85,14 @@ # require 'backports' # ugh # assert "ab\r\nc".lines[0] == "ab\r\n" # end it "should have verbose looking float#inspect" do - assert( (1.1 - 0.9).inspect.include?('0.2000000')) # 0.20000000000000006661 or something close to it + (1.1 - 0.9).inspect.should include('0.2000000') # 0.20000000000000006661 or something close to it + 1.1.inspect.should == "1.1" + 1.0.inspect.should == "1.0" + end it "should return false if you call File.executable? non_existent_file" do assert !File.executable?('nonexistent') end @@ -162,7 +171,14 @@ it "should Thread.join_all_others" do a = Thread.new { sleep 1 } assert Benchmark.realtime{Thread.join_all_others} > 0.5 end + + it "should have an insert commas operator on numbers" do + 1_000_000.comma_format.should == '1,000,000' + 1_000_000.0.comma_format.should == '1,000,000.0' + 1_000_000.0.comma_format.should == '1,000,000.0' + end + end