Skip to content
This repository
Browse code

Add -rrubygems to the generated autotest command if defined?(:Gem)

  • Loading branch information...
commit 09f9433878b1b3a1e693ac5edd341fe499eb28ef 1 parent 8000a34
David Chelimsky dchelimsky authored
16 features/subject/explicit_subject.feature
@@ -33,3 +33,19 @@ Feature: explicit subject
33 33 """
34 34 When I run "rspec nested_subject_spec.rb"
35 35 Then I should see "1 example, 0 failures"
  36 +
  37 +@wip
  38 + Scenario: access subject from before block
  39 + Given a file named "top_level_subject_spec.rb" with:
  40 + """
  41 + describe Array, "with some elements" do
  42 + subject { [] }
  43 + before { subject += [1,2,3] }
  44 + it "should have the prescribed elements" do
  45 + subject.should == [1,2,3]
  46 + end
  47 + end
  48 + """
  49 + When I run "spec top_level_subject_spec.rb"
  50 + Then I should see "1 example, 0 failures"
  51 +
6 lib/autotest/rspec2.rb
@@ -38,7 +38,11 @@ def consolidate_failures(failed)
38 38
39 39 def make_test_cmd(files_to_test)
40 40 files_to_test.empty? ? '' :
41   - "#{ruby} #{SPEC_PROGRAM} #{normalize(files_to_test).keys.flatten.join(' ')}"
  41 + "#{ruby} #{require_rubygems}#{SPEC_PROGRAM} #{normalize(files_to_test).keys.flatten.join(' ')}"
  42 + end
  43 +
  44 + def require_rubygems
  45 + defined?(:Gem) ? "-rrubygems " : ""
42 46 end
43 47
44 48 def normalize(files_to_test)
2  rspec-core.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9 9
10 10 s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11 11 s.authors = ["Chad Humphries", "David Chelimsky"]
12   - s.date = %q{2010-03-26}
  12 + s.date = %q{2010-03-31}
13 13 s.description = %q{Rspec runner and example group classes}
14 14 s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
15 15 s.executables = ["rspec", "spec"]
2  spec/autotest/rspec_spec.rb
@@ -20,7 +20,7 @@
20 20
21 21 it "should make the appropriate test command" do
22 22 actual = @rspec_autotest.make_test_cmd(@files_to_test)
23   - expected = /#{@ruby} #{@spec_cmd} (.*)/
  23 + expected = /#{@ruby}.*#{@spec_cmd} (.*)/
24 24
25 25 actual.should match(expected)
26 26

0 comments on commit 09f9433

Please sign in to comment.
Something went wrong with that request. Please try again.