Permalink
Browse files

add load paths and requires to cuke env

  • Loading branch information...
dchelimsky committed Jan 29, 2010
1 parent 9f7ec22 commit 108162b993273cc058385d5b2e4ecd93e76e3087
View
@@ -1,10 +1,2 @@
#!/usr/bin/env ruby
-$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
-$LOAD_PATH.unshift(File.expand_path('../../../rspec-expectations/lib', __FILE__))
-$LOAD_PATH.unshift(File.expand_path('../../../rspec-mocks/lib', __FILE__))
-require 'rspec/expectations'
-require 'rspec/mocks'
require 'rspec/autorun'
-
-# TODO - this feels odd here - move to runner?
-Rspec::Core::ExampleGroup.send(:include, Rspec::Matchers)
@@ -3,6 +3,8 @@ Feature: before and after blocks
Scenario: define around(:each) block in example group
Given a file named "around_each_in_example_group_spec.rb" with:
"""
+ require 'rspec/expectations'
+
class Thing
def self.cache
@cache ||= []
@@ -7,6 +7,8 @@ Feature: define matcher
Scenario: define a matcher with default messages
Given a file named "matcher_with_default_message_spec.rb" with:
"""
+ require 'rspec/expectations'
+
Rspec::Matchers.define :be_a_multiple_of do |expected|
match do |actual|
actual % expected == 0
@@ -47,6 +49,8 @@ Feature: define matcher
Scenario: overriding the failure_message_for_should
Given a file named "matcher_with_failure_message_spec.rb" with:
"""
+ require 'rspec/expectations'
+
Rspec::Matchers.define :be_a_multiple_of do |expected|
match do |actual|
actual % expected == 0
@@ -69,6 +73,8 @@ Feature: define matcher
Scenario: overriding the failure_message_for_should_not
Given a file named "matcher_with_failure_for_message_spec.rb" with:
"""
+ require 'rspec/expectations'
+
Rspec::Matchers.define :be_a_multiple_of do |expected|
match do |actual|
actual % expected == 0
@@ -91,6 +97,8 @@ Feature: define matcher
Scenario: overriding the description
Given a file named "matcher_overriding_description_spec.rb" with:
"""
+ require 'rspec/expectations'
+
Rspec::Matchers.define :be_a_multiple_of do |expected|
match do |actual|
actual % expected == 0
@@ -117,6 +125,8 @@ Feature: define matcher
Scenario: with no args
Given a file named "matcher_with_no_args_spec.rb" with:
"""
+ require 'rspec/expectations'
+
Rspec::Matchers.define :have_7_fingers do
match do |thing|
thing.fingers.length == 7
@@ -139,6 +149,8 @@ Feature: define matcher
Scenario: with multiple args
Given a file named "matcher_with_multiple_args_spec.rb" with:
"""
+ require 'rspec/expectations'
+
Rspec::Matchers.define :be_the_sum_of do |a,b,c,d|
match do |sum|
a + b + c + d == sum
@@ -157,16 +169,18 @@ Feature: define matcher
Scenario: with helper methods
Given a file named "matcher_with_internal_helper_spec.rb" with:
"""
+ require 'rspec/expectations'
+
Rspec::Matchers.define :have_same_elements_as do |sample|
match do |actual|
similar?(sample, actual)
end
-
+
def similar?(a, b)
a.sort == b.sort
end
end
-
+
describe "these two arrays" do
specify "should be similar" do
[1,2,3].should have_same_elements_as([2,3,1])
@@ -7,7 +7,6 @@ Feature: define matcher outside rspec
Scenario: define a matcher with default messages
Given a file named "test_multiples.rb" with:
"""
- $:.unshift File.join(File.dirname(__FILE__), "/../../lib")
require 'test/unit'
require 'rspec/expectations'
@@ -36,4 +35,4 @@ Feature: define matcher outside rspec
When I run "ruby test_multiples.rb"
Then the exit code should be 256
And the stdout should match "expected 9 to be a multiple of 4"
- And the stdout should match "2 tests, 0 assertions, 1 failures, 0 errors"
+ And the stdout should match "2 tests, 0 assertions, 0 failures, 1 errors"
@@ -6,6 +6,8 @@ Feature: Spec and test together
Scenario: stub in before
Given a file named "stub_and_mocks_spec.rb" with:
"""
+ require 'rspec/expectations'
+
Rspec::Core.configure do |config|
config.mock_framework = :rspec
end
@@ -5,6 +5,8 @@ Feature: explicit subject
Scenario: subject in top level group
Given a file named "top_level_subject_spec.rb" with:
"""
+ require 'rspec/expectations'
+
describe Array, "with some elements" do
subject { [1,2,3] }
it "should have the prescribed elements" do
@@ -18,6 +20,8 @@ Feature: explicit subject
Scenario: subject in a nested group
Given a file named "nested_subject_spec.rb" with:
"""
+ require 'rspec/expectations'
+
describe Array do
subject { [1,2,3] }
describe "with some elements" do
@@ -7,6 +7,8 @@ Feature: implicit subject
Scenario: subject in top level group
Given a file named "top_level_subject_spec.rb" with:
"""
+ require 'rspec/expectations'
+
describe Array, "when first created" do
it "should be empty" do
subject.should == []
@@ -19,6 +21,8 @@ Feature: implicit subject
Scenario: subject in a nested group
Given a file named "nested_subject_spec.rb" with:
"""
+ require 'rspec/expectations'
+
describe Array do
describe "when first created" do
it "should be empty" do
View
@@ -51,8 +51,21 @@ def rspec_libs
def ruby(args)
stderr_file = Tempfile.new('rspec')
stderr_file.close
+
Dir.chdir(working_dir) do
- @stdout = super("-rrubygems #{rspec_libs} #{args}", stderr_file.path)
+ File.open('load_paths.rb', 'w') do |f|
+ f.write <<-CONTENT
+$LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__))
+$LOAD_PATH.unshift(File.expand_path('../../../../rspec-expectations/lib', __FILE__))
+$LOAD_PATH.unshift(File.expand_path('../../../../rspec-mocks/lib', __FILE__))
+require 'rspec'
+require 'rspec/matchers'
+Rspec::Core::ExampleGroup.__send__(:include, Rspec::Matchers)
+CONTENT
+ end
+ cmd = "-rrubygems -rload_paths.rb #{rspec_libs} #{args}"
+ # p cmd
+ @stdout = super(cmd, stderr_file.path)
end
@stderr = IO.read(stderr_file.path)
@exit_code = $?.to_i

0 comments on commit 108162b

Please sign in to comment.