Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

optionally run tests with rspec, ruh-roh

  • Loading branch information...
commit 2a7ac62c413192416ddf92b19b1d7591ca28fb1b 1 parent 3723a7b
@cldwalker authored
View
2  .rspec
@@ -0,0 +1,2 @@
+--default_path test
+--pattern test/**_test.rb
View
2  test/option_parser_test.rb
@@ -26,7 +26,7 @@ def parse(*args)
it "cannot set values indifferently" do
@hash['foo'] = 'barred'
@hash['foo'].should == 'barred'
- @hash[:foo].should != 'barred'
+ @hash[:foo].should_not == 'barred'
@hash[:foo].should == 'bar'
end
end
View
2  test/scientist_test.rb
@@ -139,7 +139,7 @@ def all_commands
it "with splat args does not raise error for too few or many args" do
[[], [''], [1,2,3], ['1 2 3']].each do |args|
- should.not.raise { command_with_splat_args *args }
+ should_not_raise { command_with_splat_args *args }
end
end
View
44 test/test_helper.rb
@@ -1,10 +1,15 @@
-require 'bacon'
-require 'bacon/bits'
require 'mocha'
-require 'mocha-on-bacon'
require 'boson'
require 'fileutils'
require 'boson/runner'
+
+ENV['RSPEC'] = '1' if $0[/rspec/]
+unless ENV['RSPEC']
+ require 'bacon'
+ require 'bacon/bits'
+ require 'mocha-on-bacon'
+end
+
Object.send :remove_const, :OptionParser
Boson.constants.each {|e| Object.const_set(e, Boson.const_get(e)) unless Object.const_defined?(e) }
ENV['BOSONRC'] = File.dirname(__FILE__) + '/.bosonrc'
@@ -115,8 +120,37 @@ def create_library(libraries, attributes={})
}
end
+ if ENV['RSPEC']
+ def should_not_raise(&block)
+ block.should_not raise_error
+ end
+ else
+ # Since rspec doesn't allow should != or should.not
+ Object.send(:define_method, :should_not) {|*args, &block|
+ should.not(*args, &block)
+ }
+ def should_not_raise(&block)
+ should.not.raise &block
+ end
+ end
end
-class Bacon::Context
- include TestHelpers
+if ENV['RSPEC']
+ module RspecBits
+ def before_all(&block)
+ before(:all, &block)
+ end
+
+ def after_all(&block)
+ after(:all, &block)
+ end
+ end
+
+ RSpec.configure {|c|
+ c.mock_with :mocha
+ c.extend RspecBits
+ c.include TestHelpers
+ }
+else
+ Bacon::Context.send :include, TestHelpers
end
Please sign in to comment.
Something went wrong with that request. Please try again.