vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb in spree-0.5.1 vs vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb in spree-0.6.0
- old
+ new
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper.rb'
-require 'fileutils'
+require File.dirname(__FILE__) + '/resources/custom_example_group_runner'
describe "OptionParser" do
before(:each) do
@out = StringIO.new
@err = StringIO.new
@@ -11,10 +11,16 @@
def parse(args)
@parser.parse(args)
@parser.options
end
+ it "should leave the submitted argv alone" do
+ args = ["--pattern", "foo"]
+ @parser.order!(args)
+ args.should == ["--pattern", "foo"]
+ end
+
it "should accept files to include" do
options = parse(["--pattern", "foo"])
options.filename_pattern.should == "foo"
end
@@ -49,17 +55,23 @@
it "should not use colour by default" do
options = parse([])
options.colour.should == false
end
- it "should print help to stdout if no args" do
- pending 'A regression since 1.0.8' do
- options = parse([])
- @out.rewind
- @out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m)
- end
+ it "should print help to stdout if no args and spec_comand?" do
+ Spec::Runner::OptionParser.stub!(:spec_command?).and_return(true)
+ options = parse([])
+ @out.rewind
+ @out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m)
end
+
+ it "should not print help to stdout if no args and NOT spec_command?" do
+ Spec::Runner::OptionParser.stub!(:spec_command?).and_return(false)
+ options = parse([])
+ @out.rewind
+ @out.read.should == ""
+ end
it "should print help to stdout" do
options = parse(["--help"])
@out.rewind
@out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m)
@@ -74,11 +86,11 @@
end
it "should print version to stdout" do
options = parse(["--version"])
@out.rewind
- @out.read.should match(/RSpec-\d+\.\d+\.\d+.*\(build \d+\) - BDD for Ruby\nhttp:\/\/rspec.rubyforge.org\/\n/n)
+ @out.read.should match(/rspec \d+\.\d+\.\d+/n)
end
it "should require file when require specified" do
lambda do
parse(["--require", "whatever"])
@@ -229,22 +241,22 @@
@err.string.should match(/Couldn't find differ class Custom::MissingFormatter/n)
end
describe "when attempting a focussed spec" do
attr_reader :file, :dir
- before do
- @original_rspec_options = $rspec_options
+ before(:each) do
+ @original_rspec_options = Spec::Runner.options
@file = "#{File.dirname(__FILE__)}/spec_parser/spec_parser_fixture.rb"
@dir = File.dirname(file)
end
- after do
- $rspec_options = @original_rspec_options
+ after(:each) do
+ Spec::Runner.use @original_rspec_options
end
def parse(args)
options = super
- $rspec_options = options
+ Spec::Runner.use options
options.filename_pattern = "*_fixture.rb"
options
end
it "should support --line to identify spec" do