rspec-core 2.0.0.beta.22 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. data/.gitignore +1 -0
  2. data/.rspec +0 -1
  3. data/.travis.yml +7 -0
  4. data/Gemfile +46 -20
  5. data/Guardfile +5 -0
  6. data/License.txt +2 -1
  7. data/{README.markdown → README.md} +23 -5
  8. data/Rakefile +58 -31
  9. data/bin/autospec +13 -0
  10. data/bin/rspec +24 -2
  11. data/cucumber.yml +1 -1
  12. data/features/.nav +57 -0
  13. data/features/Autotest.md +38 -0
  14. data/features/Changelog.md +269 -0
  15. data/features/README.md +17 -0
  16. data/features/Upgrade.md +320 -0
  17. data/features/command_line/README.md +28 -0
  18. data/features/command_line/configure.feature +18 -15
  19. data/features/command_line/example_name_option.feature +37 -23
  20. data/features/command_line/exit_status.feature +16 -31
  21. data/features/command_line/format_option.feature +73 -0
  22. data/features/command_line/line_number_appended_to_path.feature +25 -27
  23. data/features/command_line/line_number_option.feature +11 -10
  24. data/features/command_line/rake_task.feature +68 -0
  25. data/features/command_line/tag.feature +90 -0
  26. data/features/configuration/alias_example_to.feature +48 -0
  27. data/features/configuration/custom_settings.feature +8 -10
  28. data/features/configuration/fail_fast.feature +77 -0
  29. data/features/configuration/read_options_from_file.feature +42 -26
  30. data/features/example_groups/basic_structure.feature +55 -0
  31. data/features/example_groups/shared_context.feature +74 -0
  32. data/features/example_groups/shared_example_group.feature +56 -41
  33. data/features/expectation_framework_integration/configure_expectation_framework.feature +73 -0
  34. data/features/filtering/exclusion_filters.feature +69 -9
  35. data/features/filtering/if_and_unless.feature +168 -0
  36. data/features/filtering/inclusion_filters.feature +58 -26
  37. data/features/filtering/run_all_when_everything_filtered.feature +46 -0
  38. data/features/formatters/custom_formatter.feature +17 -13
  39. data/features/formatters/text_formatter.feature +43 -0
  40. data/features/helper_methods/arbitrary_methods.feature +40 -0
  41. data/features/helper_methods/let.feature +50 -0
  42. data/features/helper_methods/modules.feature +149 -0
  43. data/features/hooks/around_hooks.feature +99 -69
  44. data/features/hooks/before_and_after_hooks.feature +74 -40
  45. data/features/hooks/filtering.feature +227 -0
  46. data/features/metadata/current_example.feature +17 -0
  47. data/features/metadata/described_class.feature +17 -0
  48. data/features/metadata/user_defined.feature +111 -0
  49. data/features/mock_framework_integration/use_any_framework.feature +106 -0
  50. data/features/mock_framework_integration/use_flexmock.feature +84 -11
  51. data/features/mock_framework_integration/use_mocha.feature +85 -11
  52. data/features/mock_framework_integration/use_rr.feature +86 -11
  53. data/features/mock_framework_integration/use_rspec.feature +85 -11
  54. data/features/pending/pending_examples.feature +143 -5
  55. data/features/spec_files/arbitrary_file_suffix.feature +2 -2
  56. data/features/step_definitions/additional_cli_steps.rb +30 -0
  57. data/features/subject/attribute_of_subject.feature +93 -15
  58. data/features/subject/explicit_subject.feature +28 -17
  59. data/features/subject/implicit_receiver.feature +29 -0
  60. data/features/subject/implicit_subject.feature +9 -10
  61. data/features/support/env.rb +6 -1
  62. data/lib/autotest/discover.rb +1 -0
  63. data/lib/autotest/rspec2.rb +15 -11
  64. data/lib/rspec/autorun.rb +2 -0
  65. data/lib/rspec/core/backward_compatibility.rb +33 -4
  66. data/lib/rspec/core/command_line.rb +4 -28
  67. data/lib/rspec/core/command_line_configuration.rb +16 -16
  68. data/lib/rspec/core/configuration.rb +279 -89
  69. data/lib/rspec/core/configuration_options.rb +46 -35
  70. data/lib/rspec/core/deprecation.rb +1 -1
  71. data/lib/rspec/core/drb_command_line.rb +5 -11
  72. data/lib/rspec/core/example.rb +63 -39
  73. data/lib/rspec/core/example_group.rb +109 -59
  74. data/lib/rspec/core/expecting/with_rspec.rb +11 -0
  75. data/lib/rspec/core/expecting/with_stdlib.rb +9 -0
  76. data/lib/rspec/core/extensions/kernel.rb +1 -1
  77. data/lib/rspec/core/extensions/object.rb +1 -3
  78. data/lib/rspec/core/formatters/base_formatter.rb +22 -11
  79. data/lib/rspec/core/formatters/base_text_formatter.rb +46 -30
  80. data/lib/rspec/core/formatters/documentation_formatter.rb +4 -2
  81. data/lib/rspec/core/formatters/helpers.rb +0 -4
  82. data/lib/rspec/core/formatters/html_formatter.rb +146 -41
  83. data/lib/rspec/core/formatters/progress_formatter.rb +1 -0
  84. data/lib/rspec/core/formatters/snippet_extractor.rb +1 -1
  85. data/lib/rspec/core/formatters/text_mate_formatter.rb +3 -1
  86. data/lib/rspec/core/hooks.rb +55 -17
  87. data/lib/rspec/core/metadata.rb +75 -64
  88. data/lib/rspec/core/metadata_hash_builder.rb +93 -0
  89. data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
  90. data/lib/rspec/core/mocking/with_mocha.rb +2 -0
  91. data/lib/rspec/core/mocking/with_rr.rb +2 -0
  92. data/lib/rspec/core/mocking/with_rspec.rb +3 -1
  93. data/lib/rspec/core/option_parser.rb +48 -5
  94. data/lib/rspec/core/pending.rb +22 -4
  95. data/lib/rspec/core/rake_task.rb +64 -28
  96. data/lib/rspec/core/reporter.rb +3 -2
  97. data/lib/rspec/core/ruby_project.rb +2 -2
  98. data/lib/rspec/core/runner.rb +50 -6
  99. data/lib/rspec/core/shared_context.rb +16 -0
  100. data/lib/rspec/core/shared_example_group.rb +19 -4
  101. data/lib/rspec/core/subject.rb +92 -65
  102. data/lib/rspec/core/version.rb +1 -1
  103. data/lib/rspec/core/world.rb +83 -25
  104. data/lib/rspec/core.rb +40 -24
  105. data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
  106. data/rspec-core.gemspec +4 -25
  107. data/script/FullBuildRakeFile +63 -0
  108. data/script/cucumber +1 -0
  109. data/script/full_build +1 -0
  110. data/script/spec +1 -0
  111. data/spec/autotest/discover_spec.rb +19 -0
  112. data/spec/autotest/failed_results_re_spec.rb +25 -9
  113. data/spec/autotest/rspec_spec.rb +32 -41
  114. data/spec/rspec/core/command_line_spec.rb +62 -7
  115. data/spec/rspec/core/configuration_options_spec.rb +184 -148
  116. data/spec/rspec/core/configuration_spec.rb +406 -108
  117. data/spec/rspec/core/deprecations_spec.rb +38 -1
  118. data/spec/rspec/core/drb_command_line_spec.rb +21 -56
  119. data/spec/rspec/core/example_group_spec.rb +366 -127
  120. data/spec/rspec/core/example_spec.rb +125 -45
  121. data/spec/rspec/core/formatters/base_formatter_spec.rb +61 -1
  122. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +39 -5
  123. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +7 -6
  124. data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
  125. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +199 -81
  126. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +199 -83
  127. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +199 -81
  128. data/spec/rspec/core/formatters/html_formatted-1.9.1.html +206 -81
  129. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +206 -61
  130. data/spec/rspec/core/formatters/html_formatter_spec.rb +17 -9
  131. data/spec/rspec/core/formatters/progress_formatter_spec.rb +1 -1
  132. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +199 -81
  133. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +199 -81
  134. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +199 -81
  135. data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +206 -81
  136. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +206 -81
  137. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +22 -7
  138. data/spec/rspec/core/hooks_filtering_spec.rb +128 -5
  139. data/spec/rspec/core/hooks_spec.rb +90 -4
  140. data/spec/rspec/core/metadata_spec.rb +176 -163
  141. data/spec/rspec/core/option_parser_spec.rb +73 -6
  142. data/spec/rspec/core/pending_example_spec.rb +137 -35
  143. data/spec/rspec/core/rake_task_spec.rb +62 -29
  144. data/spec/rspec/core/reporter_spec.rb +20 -4
  145. data/spec/rspec/core/resources/formatter_specs.rb +25 -1
  146. data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
  147. data/spec/rspec/core/runner_spec.rb +60 -10
  148. data/spec/rspec/core/shared_context_spec.rb +30 -0
  149. data/spec/rspec/core/shared_example_group_spec.rb +59 -23
  150. data/spec/rspec/core/subject_spec.rb +136 -0
  151. data/spec/rspec/core/world_spec.rb +211 -68
  152. data/spec/rspec/core_spec.rb +28 -0
  153. data/spec/spec_helper.rb +41 -23
  154. data/spec/support/matchers.rb +44 -13
  155. data/spec/support/shared_example_groups.rb +41 -0
  156. data/spec/support/spec_files.rb +44 -0
  157. data/spec.txt +1126 -0
  158. metadata +99 -168
  159. data/.treasure_map.rb +0 -23
  160. data/History.md +0 -30
  161. data/Upgrade.markdown +0 -150
  162. data/autotest/discover.rb +0 -2
  163. data/features/README.markdown +0 -12
  164. data/features/example_groups/describe_aliases.feature +0 -25
  165. data/features/example_groups/nested_groups.feature +0 -44
  166. data/features/hooks/described_class.feature +0 -14
  167. data/features/hooks/halt.feature +0 -26
  168. data/lib/rspec/core/around_proxy.rb +0 -14
  169. data/lib/rspec/core/formatters.rb +0 -8
  170. data/spec/ruby_forker.rb +0 -13
  171. data/specs.watchr +0 -59
data/rspec-core.gemspec CHANGED
@@ -7,39 +7,18 @@ Gem::Specification.new do |s|
7
7
  s.version = RSpec::Core::Version::STRING
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Chad Humphries", "David Chelimsky"]
10
- s.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
11
- s.homepage = "http://github.com/rspec/rspec-core"
10
+ s.email = "rspec-users@rubyforge.org;"
11
+ s.homepage = "http://github.com/rspec"
12
12
  s.summary = "rspec-core-#{RSpec::Core::Version::STRING}"
13
- s.description = "RSpec runner and example groups"
13
+ s.description = "BDD for Ruby. RSpec runner and example groups."
14
14
 
15
- s.rubygems_version = "1.3.7"
16
15
  s.rubyforge_project = "rspec"
17
- s.default_executable = "rspec"
18
16
 
19
17
  s.files = `git ls-files`.split("\n")
20
18
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
21
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
- s.extra_rdoc_files = [ "README.markdown" ]
20
+ s.extra_rdoc_files = [ "README.md" ]
23
21
  s.rdoc_options = ["--charset=UTF-8"]
24
22
  s.require_path = "lib"
25
-
26
- s.post_install_message = %Q{**************************************************
27
-
28
- Thank you for installing #{s.summary}
29
-
30
- Please be sure to look at Upgrade.markdown to see what might have changed
31
- since the last release.
32
-
33
- **************************************************
34
- }
35
-
36
- s.add_development_dependency "rspec-expectations", ">= #{RSpec::Core::Version::STRING}"
37
- s.add_development_dependency "rspec-mocks", ">= #{RSpec::Core::Version::STRING}"
38
- s.add_development_dependency "cucumber", ">= 0.5.3"
39
- s.add_development_dependency "autotest", ">= 4.2.9"
40
- s.add_development_dependency "syntax", ">= 1.0.0"
41
- s.add_development_dependency "flexmock"
42
- s.add_development_dependency "mocha"
43
- s.add_development_dependency "rr"
44
23
  end
45
24
 
@@ -0,0 +1,63 @@
1
+ # this is in a separate rakefile because our main one depends on the bundled gems
2
+ # already being installed. This must be able to run w/o bundled gems installed.
3
+
4
+ def rake(command = "")
5
+ sh "rake #{command}"
6
+ end
7
+
8
+ desc "Run a full build: install necessary gems with bundler, runs specs, run cukes"
9
+ task :build => :bundle_install do
10
+ rake
11
+ end
12
+
13
+ desc "Install necessary gems with bundler and runs specs"
14
+ task :spec => :bundle_install do
15
+ rake "spec"
16
+ end
17
+
18
+ desc "Install necessary gems with bundler and runs cukes"
19
+ task :cucumber => :bundle_install do
20
+ rake "cucumber"
21
+ end
22
+
23
+ desc "Prints description of current ruby interpreter"
24
+ task :print_ruby_description do
25
+ description = if defined?(RUBY_DESCRIPTION)
26
+ RUBY_DESCRIPTION
27
+ else
28
+ # RUBY_DESCRIPTION is undefined on 1.8.6
29
+ "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE} patchlevel #{RUBY_PATCHLEVEL}) [#{RUBY_PLATFORM}]"
30
+ end
31
+
32
+ puts
33
+ puts "=" * 80
34
+ puts "Using #{description}"
35
+ puts "=" * 80
36
+ puts
37
+ end
38
+
39
+ task :bundle_install => :ensure_bundler_installed do
40
+ # Unfortunately, there is no version of ruby-debug that installs cleanly on 1.9.1 and 1.9.2.
41
+ # Our Gemfile specifies different versions using conditionals, but we still need to bundle update
42
+ # to get bundler to use the different versions.
43
+ if RUBY_VERSION =~ /^1\.9/
44
+ sh "bundle update ruby-debug-base19"
45
+ end
46
+
47
+ sh "bundle install"
48
+ end
49
+
50
+ task :ensure_bundler_installed => :print_ruby_description do
51
+ installed = begin
52
+ require 'rubygems'
53
+ require 'bundler'
54
+ true
55
+ rescue LoadError
56
+ false
57
+ end
58
+
59
+ unless installed
60
+ sh "gem install bundler"
61
+ end
62
+ end
63
+
data/script/cucumber ADDED
@@ -0,0 +1 @@
1
+ rvm 1.8.6,1.8.7,ree,1.9.1,1.9.2,jruby rake -f script/FullBuildRakeFile cucumber | tee tmp/cucumber.out
data/script/full_build ADDED
@@ -0,0 +1 @@
1
+ rvm 1.8.6,1.8.7,ree,1.9.1,1.9.2,jruby rake -f script/FullBuildRakeFile build | tee tmp/full_build.out
data/script/spec ADDED
@@ -0,0 +1 @@
1
+ rvm 1.8.6,1.8.7,ree,1.9.1,1.9.2,jruby rake -f script/FullBuildRakeFile spec | tee tmp/spec.out
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe "autotest/discover.rb" do
4
+ context "with /.rspec present" do
5
+ it "adds 'rspec2' to the list of discoveries" do
6
+ File.stub(:exist?).with("./.rspec") { true }
7
+ Autotest.should_receive(:add_discovery)
8
+ load File.expand_path("../../../lib/autotest/discover.rb", __FILE__)
9
+ end
10
+ end
11
+
12
+ context "with /.rspec absent" do
13
+ it "does not add 'rspec2' to the list of discoveries" do
14
+ File.stub(:exist?) { false }
15
+ Autotest.should_not_receive(:add_discovery)
16
+ load File.expand_path("../../../lib/autotest/discover.rb", __FILE__)
17
+ end
18
+ end
19
+ end
@@ -5,17 +5,33 @@ describe "failed_results_re for autotest" do
5
5
  let(:formatter) { RSpec::Core::Formatters::BaseTextFormatter.new(output) }
6
6
  let(:example_output) do
7
7
  group = RSpec::Core::ExampleGroup.describe("group name")
8
- example = group.example("example name") { "this".should eq("that") }
9
- group.run_all(formatter)
10
- RSpec.configuration.stub(:color_enabled?) { false }
8
+ group.example("example name") { "this".should eq("that") }
9
+ group.run(formatter)
11
10
  formatter.dump_failures
12
11
  output.string
13
12
  end
14
-
15
- it "should match a failure" do
16
- re = Autotest::Rspec2.new.failed_results_re
17
- re =~ example_output
18
- $1.should == "group name example name\n Failure/Error: example = group.example(\"example name\") { \"this\".should eq(\"that\") }"
19
- $2.should == __FILE__.sub(File.expand_path('.'),'.')
13
+
14
+ context "output does not have color enabled" do
15
+ before do
16
+ RSpec.configuration.stub(:color_enabled?) { false }
17
+ end
18
+
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
+ end
24
+ end
25
+
26
+ context "output has color enabled" do
27
+ before do
28
+ RSpec.configuration.stub(:color_enabled?) { true }
29
+ end
30
+
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
+ end
20
36
  end
21
37
  end
@@ -5,6 +5,16 @@ describe Autotest::Rspec2 do
5
5
  let(:spec_cmd) { File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'rspec')) }
6
6
  let(:ruby_cmd) { "ruby" }
7
7
 
8
+ before do
9
+ File.stub(:exist?) { false }
10
+ end
11
+
12
+ it "uses autotest's prefix" do
13
+ rspec_autotest.prefix = "this is the prefix "
14
+ rspec_autotest.
15
+ make_test_cmd({'a' => 'b'}).should match(/this is the prefix/)
16
+ end
17
+
8
18
  describe "commands" do
9
19
  before do
10
20
  rspec_autotest.stub(:ruby => ruby_cmd)
@@ -39,6 +49,12 @@ describe Autotest::Rspec2 do
39
49
  cmd.should match(/'#{File.expand_path(file_to_test)}'/)
40
50
  end
41
51
  end
52
+
53
+ it "gives '--tty' to #{Autotest::Rspec2::SPEC_PROGRAM}, not '--autotest'" do
54
+ cmd = rspec_autotest.make_test_cmd(@files_to_test)
55
+ cmd.should match(' --tty ')
56
+ cmd.should_not match(' --autotest ')
57
+ end
42
58
  end
43
59
 
44
60
  describe "mappings" do
@@ -66,39 +82,32 @@ describe Autotest::Rspec2 do
66
82
  end
67
83
 
68
84
  describe "consolidating failures" do
69
- before do
70
- @spec_file = "spec/autotest/some_spec.rb"
71
- rspec_autotest.instance_variable_set("@files", {@spec_file => Time.now})
72
- rspec_autotest.stub!(:find_files_to_test).and_return true
73
- end
85
+ let(:subject_file) { "lib/autotest/some.rb" }
86
+ let(:spec_file) { "spec/autotest/some_spec.rb" }
74
87
 
75
88
  it "returns no failures if no failures were given in the output" do
76
89
  rspec_autotest.consolidate_failures([[]]).should == {}
77
90
  end
78
91
 
79
92
  it "returns a hash with the spec filename => spec name for each failure or error" do
80
- rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/some_spec.rb"
81
- failures = [
82
- [
83
- "false should be false",
84
- "#{@spec_file}"
85
- ]
86
- ]
93
+ failures = [ [ "false should be false", spec_file ] ]
87
94
  rspec_autotest.consolidate_failures(failures).should == {
88
- @spec_file => ["false should be false"]
95
+ spec_file => ["false should be false"]
89
96
  }
90
97
  end
91
98
 
92
- it "does not include the subject file" do
93
- subject_file = "lib/autotest/some.rb"
94
- rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/some_spec.rb"
95
- failures = [
96
- [
97
- "false should be false",
98
- "expected: true,\n got: false (using ==)\n#{subject_file}:143:\n#{@spec_file}:203:"
99
- ]
100
- ]
101
- rspec_autotest.consolidate_failures(failures).keys.should_not include(subject_file)
99
+ context "when subject file appears before the spec file in the backtrace" do
100
+ let(:failures) do
101
+ [ [ "false should be false", "#{subject_file}:143:\n#{spec_file}:203:" ] ]
102
+ end
103
+
104
+ it "excludes the subject file" do
105
+ rspec_autotest.consolidate_failures(failures).keys.should_not include(subject_file)
106
+ end
107
+
108
+ it "includes the spec file" do
109
+ rspec_autotest.consolidate_failures(failures).keys.should include(spec_file)
110
+ end
102
111
  end
103
112
  end
104
113
 
@@ -111,22 +120,4 @@ describe Autotest::Rspec2 do
111
120
  rspec_autotest.normalize(@files_to_test).should have(1).file
112
121
  end
113
122
  end
114
-
115
- describe "ruby command" do
116
- context "using bundler" do
117
- it "returns 'bundle exec'" do
118
- File.stub(:exists?).with("./Gemfile") { true }
119
- rspec_autotest.ruby.should eq("bundle exec")
120
- end
121
- end
122
-
123
- context "not using bundler" do
124
- it "returns the ruby command generated by Autotest" do
125
- autotest = Autotest.new
126
- autotest_ruby_command = autotest.ruby
127
- File.stub(:exists?).with("./Gemfile") { false }
128
- rspec_autotest.ruby.should eq(autotest_ruby_command)
129
- end
130
- end
131
- end
132
123
  end
@@ -4,6 +4,42 @@ require 'tmpdir'
4
4
 
5
5
  module RSpec::Core
6
6
  describe CommandLine do
7
+
8
+ describe "#run" do
9
+ include_context "spec files"
10
+
11
+ let(:out) { StringIO.new }
12
+ let(:err) { StringIO.new }
13
+
14
+ def config_options(argv=[])
15
+ options = RSpec::Core::ConfigurationOptions.new(argv)
16
+ options.parse_options
17
+ options
18
+ end
19
+
20
+ def command_line(args)
21
+ RSpec::Core::CommandLine.new(config_options(args))
22
+ end
23
+
24
+ def config_options(argv=[])
25
+ options = RSpec::Core::ConfigurationOptions.new(argv)
26
+ options.parse_options
27
+ options
28
+ end
29
+
30
+ it "returns 0 if spec passes" do
31
+ err, out = StringIO.new, StringIO.new
32
+ result = command_line([passing_spec_filename]).run(err, out)
33
+ result.should be(0)
34
+ end
35
+
36
+ it "returns 1 if spec passes" do
37
+ err, out = StringIO.new, StringIO.new
38
+ result = command_line([failing_spec_filename]).run(err, out)
39
+ result.should be(1)
40
+ end
41
+ end
42
+
7
43
  context "given an Array of options" do
8
44
  it "assigns ConfigurationOptions built from Array to @options" do
9
45
  config_options = ConfigurationOptions.new(%w[--color])
@@ -31,28 +67,46 @@ module RSpec::Core
31
67
  config_options
32
68
  end
33
69
 
34
- let(:command_line) do
35
- CommandLine.new(config_options, config)
36
- end
37
-
38
70
  let(:config) do
39
71
  RSpec::Core::Configuration.new
40
72
  end
41
73
 
74
+ let(:world) do
75
+ RSpec::Core::World.new
76
+ end
77
+
78
+ let(:command_line) do
79
+ CommandLine.new(config_options, config, world)
80
+ end
81
+
42
82
  let(:out) { ::StringIO.new }
83
+ let(:err) { ::StringIO.new }
43
84
 
44
85
  before do
45
86
  config.stub(:run_hook)
87
+
88
+ config.should_receive(:load_spec_files)
89
+
90
+ world.should_receive(:announce_inclusion_filter)
91
+ world.should_receive(:announce_exclusion_filter)
92
+ end
93
+
94
+ it "configures streams before command line options" do
95
+ # this is necessary to ensure that color works correctly on windows
96
+ config.should_receive(:error_stream=).ordered
97
+ config.should_receive(:output_stream=).ordered
98
+ config.should_receive(:color_enabled=).ordered
99
+ command_line.run(err, out) rescue nil
46
100
  end
47
101
 
48
102
  it "runs before suite hooks" do
49
103
  config.should_receive(:run_hook).with(:before, :suite)
50
- command_line.run(out, out)
104
+ command_line.run(err, out)
51
105
  end
52
106
 
53
107
  it "runs after suite hooks" do
54
108
  config.should_receive(:run_hook).with(:after, :suite)
55
- command_line.run(out, out)
109
+ command_line.run(err, out)
56
110
  end
57
111
 
58
112
  it "runs after suite hooks even after an error" do
@@ -66,10 +120,11 @@ module RSpec::Core
66
120
  end
67
121
  end
68
122
  expect do
69
- command_line.run(out, out)
123
+ command_line.run(err, out)
70
124
  end.to raise_error
71
125
  after_suite_called.should be_true
72
126
  end
127
+
73
128
  end
74
129
 
75
130
  describe "#run with custom output" do