Permalink
Browse files

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

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

0 comments on commit 09f9433

Please sign in to comment.