Permalink
Browse files

Merge pull request #5 from michaeljbishop/update-for-new-rspec

Updated the test case, ensured test passage.
  • Loading branch information...
2 parents ca575fa + b2e7482 commit ae701243407aa81bdcaabffbe01a23fb84d7e3c6 @bhuga committed Oct 12, 2012
Showing with 17 additions and 17 deletions.
  1. +11 −11 Rakefile
  2. +1 −1 lib/future.rb
  3. +2 −2 lib/promise.rb
  4. +2 −2 spec/future.spec
  5. +1 −1 spec/shared.rb
View
@@ -1,30 +1,30 @@
-require 'spec'
-require 'spec/rake/spectask'
+require 'rspec'
+require 'rspec/core/rake_task'
desc 'Run specs'
task 'spec' do
- Spec::Rake::SpecTask.new("spec") do |t|
- t.spec_files = FileList["spec/**/*.spec","spec/*.rb"]
+ RSpec::Core::RakeTask.new("spec") do |t|
+ t.pattern = "spec/**/*.spec"
t.rcov = false
- t.spec_opts = ["-c"]
+ t.rspec_opts = ["-c"]
end
end
desc 'Run specs with backtrace'
task 'tracespec' do
- Spec::Rake::SpecTask.new("tracespec") do |t|
- t.spec_files = FileList["spec/**/*.spec", "spec/*.rb"]
+ RSpec::Core::RakeTask.new("tracespec") do |t|
+ t.pattern = "spec/**/*.spec"
t.rcov = false
- t.spec_opts = ["-bcfn"]
+ t.rspec_opts = ["-bcfn"]
end
end
desc 'Run coverage'
task 'coverage' do
- Spec::Rake::SpecTask.new("coverage") do |t|
- t.spec_files = FileList["spec/**/*.spec","spec/*.rb"]
+ RSpec::Core::RakeTask.new("coverage") do |t|
+ t.pattern = "spec/**/*.spec"
t.rcov = true
- t.spec_opts = ["-c"]
+ t.rspec_opts = ["-c"]
end
end
View
@@ -9,7 +9,7 @@
# y = x * 2 # => 6. blocks unless 5 seconds has passed.
#
class Future < defined?(BasicObject) ? BasicObject : Object
- instance_methods.each { |m| undef_method m unless m =~ /__/ } unless defined?(BasicObject)
+ instance_methods.each { |m| undef_method m unless m =~ /^(__.*|object_id)$/ }
##
# Creates a new future.
View
@@ -17,7 +17,7 @@
class Promise < defined?(BasicObject) ? BasicObject : ::Object
NOT_SET = ::Object.new.freeze
- instance_methods.each { |m| undef_method m unless m.to_s =~ /__/ }
+ instance_methods.each { |m| undef_method m unless m =~ /^(__.*|object_id)$/ }
##
# Creates a new promise.
@@ -29,7 +29,7 @@ class Promise < defined?(BasicObject) ? BasicObject : ::Object
# @see Kernel#promise
def initialize(&block)
if block.arity > 0
- raise ArgumentError, "Cannot store a promise that requires an argument"
+ ::Kernel.raise ::ArgumentError, "Cannot store a promise that requires an argument"
end
@block = block
@mutex = ::Mutex.new
View
@@ -26,8 +26,8 @@ describe Future do
y = x + 5
y.should == 10
finish = Time.now
- (middle - start).should be_close 0, 10**-2
- (finish - start).should be_close 3, 10**-2
+ (middle - start).should be_within(10**-2).of(0)
+ (finish - start).should be_within(10**-2).of(3)
end
end
View
@@ -1,4 +1,4 @@
-require 'spec'
+require 'rspec'
require 'promise'
shared_examples_for "A Promise" do

0 comments on commit ae70124

Please sign in to comment.