rspec-core 2.6.4 → 2.7.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/README.md +1 -1
  2. data/{bin → exe}/autospec +0 -0
  3. data/{bin → exe}/rspec +0 -0
  4. data/features/Upgrade.md +11 -0
  5. data/features/command_line/exit_status.feature +20 -3
  6. data/features/command_line/format_option.feature +8 -0
  7. data/features/command_line/line_number_appended_to_path.feature +35 -1
  8. data/features/command_line/line_number_option.feature +16 -3
  9. data/features/command_line/pattern_option.feature +31 -0
  10. data/features/command_line/rake_task.feature +1 -1
  11. data/features/command_line/ruby.feature +22 -0
  12. data/features/configuration/default_path.feature +38 -0
  13. data/features/example_groups/{shared_example_group.feature → shared_examples.feature} +49 -26
  14. data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
  15. data/features/filtering/inclusion_filters.feature +4 -5
  16. data/features/formatters/text_formatter.feature +16 -13
  17. data/features/helper_methods/let.feature +4 -4
  18. data/features/hooks/around_hooks.feature +1 -1
  19. data/features/hooks/before_and_after_hooks.feature +3 -3
  20. data/features/hooks/filtering.feature +13 -6
  21. data/features/metadata/user_defined.feature +12 -10
  22. data/features/pending/pending_examples.feature +21 -8
  23. data/features/step_definitions/additional_cli_steps.rb +1 -1
  24. data/features/subject/attribute_of_subject.feature +2 -2
  25. data/features/support/env.rb +1 -2
  26. data/lib/rspec/core.rb +1 -23
  27. data/lib/rspec/core/configuration.rb +64 -16
  28. data/lib/rspec/core/configuration_options.rb +11 -4
  29. data/lib/rspec/core/example.rb +10 -7
  30. data/lib/rspec/core/example_group.rb +34 -18
  31. data/lib/rspec/core/formatters/base_text_formatter.rb +10 -2
  32. data/lib/rspec/core/formatters/html_formatter.rb +3 -1
  33. data/lib/rspec/core/formatters/snippet_extractor.rb +9 -3
  34. data/lib/rspec/core/formatters/text_mate_formatter.rb +20 -6
  35. data/lib/rspec/core/hooks.rb +2 -2
  36. data/lib/rspec/core/let.rb +5 -5
  37. data/lib/rspec/core/metadata.rb +136 -94
  38. data/lib/rspec/core/option_parser.rb +10 -5
  39. data/lib/rspec/core/pending.rb +2 -1
  40. data/lib/rspec/core/rake_task.rb +26 -15
  41. data/lib/rspec/core/reporter.rb +2 -3
  42. data/lib/rspec/core/runner.rb +1 -1
  43. data/lib/rspec/core/shared_example_group.rb +4 -4
  44. data/lib/rspec/core/subject.rb +7 -7
  45. data/lib/rspec/core/version.rb +1 -1
  46. data/lib/rspec/core/world.rb +4 -8
  47. data/spec/autotest/discover_spec.rb +2 -2
  48. data/spec/autotest/failed_results_re_spec.rb +29 -21
  49. data/spec/autotest/rspec_spec.rb +3 -3
  50. data/spec/rspec/core/command_line_spec.rb +1 -6
  51. data/spec/rspec/core/configuration_options_spec.rb +65 -13
  52. data/spec/rspec/core/configuration_spec.rb +148 -37
  53. data/spec/rspec/core/deprecations_spec.rb +2 -2
  54. data/spec/rspec/core/drb_command_line_spec.rb +6 -6
  55. data/spec/rspec/core/example_group_spec.rb +197 -61
  56. data/spec/rspec/core/example_spec.rb +33 -16
  57. data/spec/rspec/core/formatters/base_formatter_spec.rb +3 -3
  58. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +149 -1
  59. data/spec/rspec/core/formatters/helpers_spec.rb +8 -8
  60. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +85 -17
  61. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +12 -11
  62. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +12 -11
  63. data/spec/rspec/core/formatters/{html_formatted-1.9.1.html → html_formatted-1.9.3.html} +12 -11
  64. data/spec/rspec/core/formatters/html_formatter_spec.rb +5 -5
  65. data/spec/rspec/core/formatters/progress_formatter_spec.rb +2 -2
  66. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +2 -2
  67. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +86 -18
  68. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +13 -12
  69. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -28
  70. data/spec/rspec/core/formatters/{text_mate_formatted-1.9.1.html → text_mate_formatted-1.9.3.html} +29 -28
  71. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +2 -2
  72. data/spec/rspec/core/hooks_filtering_spec.rb +18 -18
  73. data/spec/rspec/core/let_spec.rb +19 -6
  74. data/spec/rspec/core/metadata_spec.rb +146 -61
  75. data/spec/rspec/core/pending_example_spec.rb +4 -4
  76. data/spec/rspec/core/rake_task_spec.rb +71 -50
  77. data/spec/rspec/core/reporter_spec.rb +2 -2
  78. data/spec/rspec/core/ruby_project_spec.rb +2 -2
  79. data/spec/rspec/core/runner_spec.rb +4 -1
  80. data/spec/rspec/core/shared_example_group_spec.rb +15 -119
  81. data/spec/rspec/core/subject_spec.rb +13 -13
  82. data/spec/rspec/core/world_spec.rb +31 -22
  83. data/spec/rspec/core_spec.rb +1 -29
  84. data/spec/spec_helper.rb +51 -49
  85. data/spec/support/shared_example_groups.rb +3 -3
  86. data/spec/support/spec_files.rb +8 -8
  87. metadata +79 -93
  88. data/.document +0 -5
  89. data/.gitignore +0 -12
  90. data/.rspec +0 -0
  91. data/.travis.yml +0 -9
  92. data/Changelog.md +0 -305
  93. data/Gemfile +0 -49
  94. data/Guardfile +0 -5
  95. data/License.txt +0 -23
  96. data/Rakefile +0 -93
  97. data/cucumber.yml +0 -2
  98. data/features/.nav +0 -57
  99. data/rspec-core.gemspec +0 -24
  100. data/script/FullBuildRakeFile +0 -63
  101. data/script/console +0 -8
  102. data/script/cucumber +0 -1
  103. data/script/full_build +0 -1
  104. data/script/spec +0 -1
  105. data/spec.txt +0 -1126
  106. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +0 -398
  107. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +0 -398
@@ -73,8 +73,8 @@ module RSpec::Core
73
73
  options[:libs] << dir
74
74
  end
75
75
 
76
- parser.on('-l', '--line_number LINE', 'Specify the line number of a single example to run') do |o|
77
- options[:line_number] = o
76
+ parser.on('-l', '--line_number LINE', 'Specify the line number of an example to run. May be specified multiple times.') do |o|
77
+ (options[:line_numbers] ||= []) << o
78
78
  end
79
79
 
80
80
  parser.on('-O', '--options PATH', 'Specify the path to an options file') do |path|
@@ -85,7 +85,7 @@ module RSpec::Core
85
85
  options[:profile_examples] = o
86
86
  end
87
87
 
88
- parser.on('-P', '--pattern PATTERN', 'Load files those matching this pattern. Default is "spec/**/*_spec.rb"') do |o|
88
+ parser.on('-P', '--pattern PATTERN', 'Load files matching this pattern. Default is "spec/**/*_spec.rb"') do |o|
89
89
  options[:pattern] = o
90
90
  end
91
91
 
@@ -99,8 +99,8 @@ module RSpec::Core
99
99
  exit
100
100
  end
101
101
 
102
- parser.on('-X', '--drb', 'Run examples via DRb') do |o|
103
- options[:drb] = true
102
+ parser.on('-X', '--[no-]drb', 'Run examples via DRb') do |o|
103
+ options[:drb] = o
104
104
  end
105
105
 
106
106
  parser.on('--configure COMMAND', 'Generate configuration files') do |cmd|
@@ -132,6 +132,11 @@ module RSpec::Core
132
132
  parser.on('--tty', 'Used internally by rspec when sending commands to other processes') do |o|
133
133
  options[:tty] = true
134
134
  end
135
+
136
+ parser.on('--default_path PATH', 'Set the default path where RSpec looks for examples.',
137
+ 'Can be a path to a file or a directory') do |path|
138
+ options[:default_path] = path
139
+ end
135
140
  end
136
141
  end
137
142
  end
@@ -24,7 +24,8 @@ module RSpec
24
24
  example.example_group_instance.instance_eval { verify_mocks_for_rspec }
25
25
  end
26
26
  example.metadata[:pending] = false
27
- rescue Exception
27
+ rescue Exception => e
28
+ example.execution_result[:exception] = e
28
29
  ensure
29
30
  teardown_mocks_for_rspec
30
31
  end
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require 'rspec/core'
4
2
  require 'rspec/core/deprecation'
5
3
  require 'rake'
@@ -8,6 +6,7 @@ require 'rake/tasklib'
8
6
  module RSpec
9
7
  module Core
10
8
  class RakeTask < ::Rake::TaskLib
9
+ include ::Rake::DSL if defined?(::Rake::DSL)
11
10
 
12
11
  # Name of task.
13
12
  #
@@ -21,19 +20,29 @@ module RSpec
21
20
  # 'spec/**/*_spec.rb'
22
21
  attr_accessor :pattern
23
22
 
23
+ # Deprecated and has no effect. The rake task now checks
24
+ # ENV['BUNDLE_GEMFILE'] instead.
25
+ #
24
26
  # By default, if there is a Gemfile, the generated command will include
25
27
  # 'bundle exec'. Set this to true to ignore the presence of a Gemfile, and
26
28
  # not add 'bundle exec' to the command.
27
29
  #
28
30
  # default:
29
31
  # false
30
- attr_accessor :skip_bundler
32
+ def skip_bundler=(*)
33
+ RSpec.deprecate("RSpec::Core::RakeTask#skip_bundler=", 'ENV["BUNDLE_GEMFILE"]')
34
+ end
31
35
 
32
- # Name of Gemfile to use
36
+ # Deprecated and has no effect. The rake task now checks
37
+ # ENV['BUNDLE_GEMFILE'] instead.
38
+ #
39
+ # Name of Gemfile to use.
33
40
  #
34
41
  # default:
35
42
  # Gemfile
36
- attr_accessor :gemfile
43
+ def gemfile=(*)
44
+ RSpec.deprecate("RSpec::Core::RakeTask#gemfile=", 'ENV["BUNDLE_GEMFILE"]')
45
+ end
37
46
 
38
47
  # Deprecated. Use ruby_opts="-w" instead.
39
48
  #
@@ -115,15 +124,14 @@ module RSpec
115
124
  def initialize(*args)
116
125
  @name = args.shift || :spec
117
126
  @pattern, @rcov_path, @rcov_opts, @ruby_opts, @rspec_opts = nil, nil, nil, nil, nil
118
- @warning, @rcov, @skip_bundler = false, false, false
127
+ @warning, @rcov = false, false
119
128
  @verbose, @fail_on_error = true, true
120
- @gemfile = 'Gemfile'
121
129
 
122
130
  yield self if block_given?
123
131
 
124
132
  @rcov_path ||= 'rcov'
125
133
  @rspec_path ||= 'rspec'
126
- @pattern ||= './spec/**/*_spec.rb'
134
+ @pattern ||= './spec{,/*/**}/*_spec.rb'
127
135
 
128
136
  desc("Run RSpec code examples") unless ::Rake.application.last_comment
129
137
 
@@ -133,11 +141,12 @@ module RSpec
133
141
  puts "No examples matching #{pattern} could be found"
134
142
  else
135
143
  begin
136
- ruby(spec_command)
144
+ puts spec_command if verbose
145
+ success = system(spec_command)
137
146
  rescue
138
147
  puts failure_message if failure_message
139
- raise("ruby #{spec_command} failed") if fail_on_error
140
148
  end
149
+ raise("ruby #{spec_command} failed") if fail_on_error unless success
141
150
  end
142
151
  end
143
152
  end
@@ -155,13 +164,15 @@ module RSpec
155
164
 
156
165
  def spec_command
157
166
  @spec_command ||= begin
158
- cmd_parts = [ruby_opts]
167
+ cmd_parts = []
168
+ cmd_parts << "bundle exec" if bundler?
169
+ cmd_parts << RUBY
170
+ cmd_parts << ruby_opts
159
171
  cmd_parts << "-w" if warning?
160
172
  cmd_parts << "-S"
161
- cmd_parts << "bundle exec" if gemfile? unless skip_bundler
162
173
  cmd_parts << runner
163
174
  if rcov
164
- cmd_parts << ["-Ispec#{File::PATH_SEPARATOR}lib", rcov_opts]
175
+ cmd_parts << ["-Ispec:lib", rcov_opts]
165
176
  else
166
177
  cmd_parts << rspec_opts
167
178
  end
@@ -187,8 +198,8 @@ module RSpec
187
198
  lambda {|s| s == ""}
188
199
  end
189
200
 
190
- def gemfile?
191
- File.exist?(gemfile)
201
+ def bundler?
202
+ ENV["BUNDLE_GEMFILE"] if ENV["BUNDLE_GEMFILE"] unless ENV["BUNDLE_GEMFILE"] == ""
192
203
  end
193
204
 
194
205
  end
@@ -3,7 +3,7 @@ module RSpec::Core
3
3
  def initialize(*formatters)
4
4
  @formatters = formatters
5
5
  @example_count = @failure_count = @pending_count = 0
6
- @duration = @start = nil
6
+ @duration = nil
7
7
  end
8
8
 
9
9
  def report(count)
@@ -30,7 +30,6 @@ module RSpec::Core
30
30
  alias_method :abort, :finish
31
31
 
32
32
  def start(expected_example_count)
33
- @start = Time.now
34
33
  notify :start, expected_example_count
35
34
  end
36
35
 
@@ -66,7 +65,7 @@ module RSpec::Core
66
65
  end
67
66
 
68
67
  def stop
69
- @duration = Time.now - @start if @start
68
+ @duration = Time.now - $rspec_start_time
70
69
  notify :stop
71
70
  end
72
71
 
@@ -7,8 +7,8 @@ module RSpec
7
7
  # Register an at_exit hook that runs the suite.
8
8
  def self.autorun
9
9
  return if autorun_disabled? || installed_at_exit? || running_in_drb?
10
+ at_exit { exit run(ARGV, $stderr, $stdout).to_i }
10
11
  @installed_at_exit = true
11
- at_exit { exit(run(ARGV, $stderr, $stdout).to_i) }
12
12
  end
13
13
  AT_EXIT_HOOK_BACKTRACE_LINE = "#{__FILE__}:#{__LINE__ - 2}:in `autorun'"
14
14
 
@@ -3,10 +3,10 @@ module RSpec
3
3
  module SharedExampleGroup
4
4
 
5
5
  def shared_context(*args, &block)
6
- if String === args.first || Symbol === args.first
7
- name = args.shift
8
- ensure_shared_example_group_name_not_taken(name)
9
- RSpec.world.shared_example_groups[name] = block
6
+ if [String, Symbol, Module].any? {|cls| cls === args.first }
7
+ object = args.shift
8
+ ensure_shared_example_group_name_not_taken(object)
9
+ RSpec.world.shared_example_groups[object] = block
10
10
  end
11
11
 
12
12
  unless args.empty?
@@ -75,14 +75,14 @@ module RSpec
75
75
  #
76
76
  # # This ...
77
77
  # describe Array do
78
- # its(:size) { should == 0 }
78
+ # its(:size) { should eq(0) }
79
79
  # end
80
80
  #
81
81
  # # ... generates the same runtime structure as this:
82
82
  # describe Array do
83
83
  # describe "size" do
84
- # it "should == 0" do
85
- # subject.size.should == 0
84
+ # it "should eq(0)" do
85
+ # subject.size.should eq(0)
86
86
  # end
87
87
  # end
88
88
  # end
@@ -98,7 +98,7 @@ module RSpec
98
98
  # end
99
99
  # end
100
100
  #
101
- # its("phone_numbers.first") { should == "555-1212" }
101
+ # its("phone_numbers.first") { should eq("555-1212") }
102
102
  # end
103
103
  #
104
104
  # When the subject is a +Hash+, you can refer to the Hash keys by
@@ -110,12 +110,12 @@ module RSpec
110
110
  # 'admin' => :all_permissions }
111
111
  # end
112
112
  #
113
- # its([:max_users]) { should == 3 }
114
- # its(['admin']) { should == :all_permissions }
113
+ # its([:max_users]) { should eq(3) }
114
+ # its(['admin']) { should eq(:all_permissions) }
115
115
  #
116
116
  # # You can still access to its regular methods this way:
117
117
  # its(:keys) { should include(:max_users) }
118
- # its(:count) { should == 2 }
118
+ # its(:count) { should eq(2) }
119
119
  # end
120
120
  def its(attribute, &block)
121
121
  describe(attribute) do
@@ -1,7 +1,7 @@
1
1
  module RSpec # :nodoc:
2
2
  module Core # :nodoc:
3
3
  module Version # :nodoc:
4
- STRING = '2.6.4'
4
+ STRING = '2.7.0.rc1'
5
5
  end
6
6
  end
7
7
  end
@@ -70,14 +70,14 @@ module RSpec
70
70
  example_groups.collect {|g| g.descendants}.flatten.inject(0) { |sum, g| sum += g.filtered_examples.size }
71
71
  end
72
72
 
73
- def apply_inclusion_filters(examples, conditions={})
74
- examples.select(&apply?(:any?, conditions))
73
+ def apply_inclusion_filters(examples, filters)
74
+ filters.empty? ? examples : examples.select {|e| e.metadata.any_apply?(filters)}
75
75
  end
76
76
 
77
77
  alias_method :find, :apply_inclusion_filters
78
78
 
79
- def apply_exclusion_filters(examples, conditions={})
80
- examples.reject(&apply?(:any?, conditions))
79
+ def apply_exclusion_filters(examples, filters)
80
+ filters.empty? ? examples : examples.reject {|e| e.metadata.any_apply?(filters)}
81
81
  end
82
82
 
83
83
  def preceding_declaration_line(filter_line)
@@ -139,10 +139,6 @@ module RSpec
139
139
 
140
140
  private
141
141
 
142
- def apply?(predicate, filter)
143
- lambda {|example| filter.empty? || example.metadata.apply?(predicate, filter)}
144
- end
145
-
146
142
  def declaration_line_numbers
147
143
  @line_numbers ||= example_groups.inject([]) do |lines, g|
148
144
  lines + g.declaration_line_numbers
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "autotest/discover.rb" do
4
- context "with /.rspec present" do
4
+ context "with ./.rspec present" do
5
5
  it "adds 'rspec2' to the list of discoveries" do
6
6
  File.stub(:exist?).with("./.rspec") { true }
7
7
  Autotest.should_receive(:add_discovery)
@@ -9,7 +9,7 @@ describe "autotest/discover.rb" do
9
9
  end
10
10
  end
11
11
 
12
- context "with /.rspec absent" do
12
+ context "with ./.rspec absent" do
13
13
  it "does not add 'rspec2' to the list of discoveries" do
14
14
  File.stub(:exist?) { false }
15
15
  Autotest.should_not_receive(:add_discovery)
@@ -1,37 +1,45 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "failed_results_re for autotest" do
4
- let(:output) { StringIO.new }
5
- let(:formatter) { RSpec::Core::Formatters::BaseTextFormatter.new(output) }
6
- let(:example_output) do
7
- group = RSpec::Core::ExampleGroup.describe("group name")
8
- group.example("example name") { "this".should eq("that") }
9
- group.run(formatter)
10
- formatter.dump_failures
11
- output.string
4
+ def run_example
5
+ group = RSpec::Core::ExampleGroup.describe("group")
6
+ example = group.example("example") { yield }
7
+ io = StringIO.new
8
+ formatter = RSpec::Core::Formatters::BaseTextFormatter.new(io)
9
+ reporter = RSpec::Core::Reporter.new(formatter)
10
+
11
+ group.run(reporter)
12
+ reporter.report(1) {}
13
+ io.string
12
14
  end
13
15
 
14
- context "output does not have color enabled" do
15
- before do
16
- RSpec.configuration.stub(:color_enabled?) { false }
16
+ shared_examples "autotest failed_results_re" do
17
+ it "matches a failure" do
18
+ output = run_example { fail }
19
+ output.should match(Autotest::Rspec2.new.failed_results_re)
20
+ output.should include(__FILE__.sub(File.expand_path('.'),'.'))
17
21
  end
18
22
 
19
- it "matches a failure" do
20
- re = Autotest::Rspec2.new.failed_results_re
21
- example_output.should =~ re
22
- example_output.should include(__FILE__.sub(File.expand_path('.'),'.'))
23
+ it "does not match when there are no failures" do
24
+ output = run_example { } # pass
25
+ output.should_not match(Autotest::Rspec2.new.failed_results_re)
26
+ output.should_not include(__FILE__.sub(File.expand_path('.'),'.'))
23
27
  end
24
28
  end
25
29
 
26
- context "output has color enabled" do
30
+ context "with color enabled" do
27
31
  before do
28
- RSpec.configuration.stub(:color_enabled?) { true }
32
+ RSpec.configuration.stub(:color_enabled? => true)
29
33
  end
30
34
 
31
- it "matches a failure" do
32
- re = Autotest::Rspec2.new.failed_results_re
33
- example_output.should =~ re
34
- example_output.should include(__FILE__.sub(File.expand_path('.'),'.'))
35
+ include_examples "autotest failed_results_re"
36
+ end
37
+
38
+ context "with color disabled " do
39
+ before do
40
+ RSpec.configuration.stub(:color_enabled? => false)
35
41
  end
42
+
43
+ include_examples "autotest failed_results_re"
36
44
  end
37
45
  end
@@ -86,14 +86,14 @@ describe Autotest::Rspec2 do
86
86
  let(:spec_file) { "spec/autotest/some_spec.rb" }
87
87
 
88
88
  it "returns no failures if no failures were given in the output" do
89
- rspec_autotest.consolidate_failures([[]]).should == {}
89
+ rspec_autotest.consolidate_failures([[]]).should eq({})
90
90
  end
91
91
 
92
92
  it "returns a hash with the spec filename => spec name for each failure or error" do
93
93
  failures = [ [ "false should be false", spec_file ] ]
94
- rspec_autotest.consolidate_failures(failures).should == {
94
+ rspec_autotest.consolidate_failures(failures).should eq({
95
95
  spec_file => ["false should be false"]
96
- }
96
+ })
97
97
  end
98
98
 
99
99
  context "when subject file appears before the spec file in the backtrace" do
@@ -11,12 +11,6 @@ module RSpec::Core
11
11
  let(:out) { StringIO.new }
12
12
  let(:err) { StringIO.new }
13
13
 
14
- def config_options(argv=[])
15
- options = RSpec::Core::ConfigurationOptions.new(argv)
16
- options.parse_options
17
- options
18
- end
19
-
20
14
  def command_line(args)
21
15
  RSpec::Core::CommandLine.new(config_options(args))
22
16
  end
@@ -156,6 +150,7 @@ module RSpec::Core
156
150
 
157
151
  before do
158
152
  config.stub(:run_hook)
153
+ config.stub(:files_to_run) { [] }
159
154
  end
160
155
 
161
156
  it "doesn't override output_stream" do
@@ -42,6 +42,22 @@ describe RSpec::Core::ConfigurationOptions do
42
42
  opts.configure(config)
43
43
  end
44
44
 
45
+ it "sends default_path before files_or_directories_to_run" do
46
+ opts = config_options_object(*%w[--default_path spec])
47
+ config = double("config").as_null_object
48
+ config.should_receive(:default_path=).ordered
49
+ config.should_receive(:files_or_directories_to_run=).ordered
50
+ opts.configure(config)
51
+ end
52
+
53
+ it "sends pattern before files_or_directories_to_run" do
54
+ opts = config_options_object(*%w[--pattern **/*.spec])
55
+ config = double("config").as_null_object
56
+ config.should_receive(:pattern=).ordered
57
+ config.should_receive(:files_or_directories_to_run=).ordered
58
+ opts.configure(config)
59
+ end
60
+
45
61
  it "merges the :exclusion_filter option with the default exclusion_filter" do
46
62
  opts = config_options_object(*%w[--tag ~slow])
47
63
  config = RSpec::Core::Configuration.new
@@ -62,6 +78,14 @@ describe RSpec::Core::ConfigurationOptions do
62
78
  it "sets :color_enabled => false" do
63
79
  parse_options('--no-color').should include(:color_enabled => false)
64
80
  end
81
+
82
+ it "overrides previous :color_enabled => true" do
83
+ parse_options('--color', '--no-color').should include(:color_enabled => false)
84
+ end
85
+
86
+ it "gets overriden by a subsequent :color_enabled => true" do
87
+ parse_options('--no-color', '--color').should include(:color_enabled => true)
88
+ end
65
89
  end
66
90
 
67
91
  describe "-I" do
@@ -103,8 +127,13 @@ describe RSpec::Core::ConfigurationOptions do
103
127
 
104
128
  describe '--line_number' do
105
129
  it "sets :line_number" do
106
- parse_options('-l','3').should include(:line_number => '3')
107
- parse_options('--line_number','3').should include(:line_number => '3')
130
+ parse_options('-l','3').should include(:line_numbers => ['3'])
131
+ parse_options('--line_number','3').should include(:line_numbers => ['3'])
132
+ end
133
+
134
+ it "can be specified multiple times" do
135
+ parse_options('-l','3', '-l', '6').should include(:line_numbers => ['3', '6'])
136
+ parse_options('--line_number','3', '--line_number', '6').should include(:line_numbers => ['3', '6'])
108
137
  end
109
138
  end
110
139
 
@@ -183,6 +212,21 @@ describe RSpec::Core::ConfigurationOptions do
183
212
 
184
213
  end
185
214
 
215
+ describe "--no-drb" do
216
+ it "disables drb" do
217
+ parse_options("--no-drb").should include(:drb => false)
218
+ end
219
+
220
+ it "overrides a previous drb => true" do
221
+ parse_options("--drb", "--no-drb").should include(:drb => false)
222
+ end
223
+
224
+ it "gets overriden by a subsquent drb => true" do
225
+ parse_options("--no-drb", "--drb").should include(:drb => true)
226
+ end
227
+ end
228
+
229
+
186
230
  describe "files_or_directories_to_run" do
187
231
  it "parses files from '-c file.rb dir/file.rb'" do
188
232
  parse_options("-c", "file.rb", "dir/file.rb").should include(:files_or_directories_to_run => ["file.rb", "dir/file.rb"])
@@ -203,9 +247,17 @@ describe RSpec::Core::ConfigurationOptions do
203
247
 
204
248
  it "parses dir and files from 'spec/file1_spec.rb, spec/file2_spec.rb'" do
205
249
  parse_options("dir", "spec/file1_spec.rb", "spec/file2_spec.rb").should include(:files_or_directories_to_run => ["dir", "spec/file1_spec.rb", "spec/file2_spec.rb"])
206
-
207
250
  end
251
+ end
208
252
 
253
+ describe "default_path" do
254
+ it "gets set before files_or_directories_to_run" do
255
+ config = double("config").as_null_object
256
+ config.should_receive(:default_path=).ordered
257
+ config.should_receive(:files_or_directories_to_run=).ordered
258
+ opts = config_options_object("--default_path", "foo")
259
+ opts.configure(config)
260
+ end
209
261
  end
210
262
 
211
263
  # TODO ensure all options are output
@@ -227,7 +279,7 @@ describe RSpec::Core::ConfigurationOptions do
227
279
  it "includes --example" do
228
280
  config_options_object(*%w[--example foo]).drb_argv.should include("--example", "foo")
229
281
  end
230
-
282
+
231
283
  it "unescapes characters which were escaped upon storing --example originally" do
232
284
  config_options_object("--example", "foo\\ bar").drb_argv.should include("--example", "foo bar")
233
285
  end
@@ -278,8 +330,8 @@ describe RSpec::Core::ConfigurationOptions do
278
330
 
279
331
  context "--drb specified in ARGV" do
280
332
  it "renders all the original arguments except --drb" do
281
- config_options_object(*%w[ --drb --color --format s --line_number 1 --example pattern --profile --backtrace -I path/a -I path/b --require path/c --require path/d]).
282
- drb_argv.should eq(%w[ --color --profile --backtrace --line_number 1 --example pattern --format s -I path/a -I path/b --require path/c --require path/d])
333
+ config_options_object(*%w[ --drb --color --format s --example pattern --line_number 1 --profile --backtrace -I path/a -I path/b --require path/c --require path/d]).
334
+ drb_argv.should eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s -I path/a -I path/b --require path/c --require path/d])
283
335
  end
284
336
  end
285
337
 
@@ -287,8 +339,8 @@ describe RSpec::Core::ConfigurationOptions do
287
339
  it "renders all the original arguments except --drb" do
288
340
  File.stub(:exist?) { true }
289
341
  IO.stub(:read) { "--drb --color" }
290
- config_options_object(*%w[ --tty --format s --line_number 1 --example pattern --profile --backtrace ]).
291
- drb_argv.should eq(%w[ --color --profile --backtrace --tty --line_number 1 --example pattern --format s])
342
+ config_options_object(*%w[ --tty --format s --example pattern --line_number 1 --profile --backtrace ]).
343
+ drb_argv.should eq(%w[ --color --profile --backtrace --tty --example pattern --line_number 1 --format s])
292
344
  end
293
345
  end
294
346
 
@@ -296,8 +348,8 @@ describe RSpec::Core::ConfigurationOptions do
296
348
  it "renders all the original arguments except --drb" do
297
349
  File.stub(:exist?) { true }
298
350
  IO.stub(:read) { "--drb --color" }
299
- config_options_object(*%w[ --drb --format s --line_number 1 --example pattern --profile --backtrace]).
300
- drb_argv.should eq(%w[ --color --profile --backtrace --line_number 1 --example pattern --format s])
351
+ config_options_object(*%w[ --drb --format s --example pattern --line_number 1 --profile --backtrace]).
352
+ drb_argv.should eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s])
301
353
  end
302
354
  end
303
355
 
@@ -305,8 +357,8 @@ describe RSpec::Core::ConfigurationOptions do
305
357
  it "renders all the original arguments except --drb and --options" do
306
358
  File.stub(:exist?) { true }
307
359
  IO.stub(:read) { "--drb --color" }
308
- config_options_object(*%w[ --drb --format s --line_number 1 --example pattern --profile --backtrace]).
309
- drb_argv.should eq(%w[ --color --profile --backtrace --line_number 1 --example pattern --format s ])
360
+ config_options_object(*%w[ --drb --format s --example pattern --line_number 1 --profile --backtrace]).
361
+ drb_argv.should eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s ])
310
362
  end
311
363
  end
312
364
  end
@@ -340,7 +392,7 @@ describe RSpec::Core::ConfigurationOptions do
340
392
  ENV["SPEC_OPTS"] = "--debug"
341
393
  options = parse_options("--drb")
342
394
  options[:color_enabled].should be_true
343
- options[:line_number].should eq("37")
395
+ options[:line_numbers].should eq(["37"])
344
396
  options[:debug].should be_true
345
397
  options[:drb].should be_true
346
398
  end