rspec-core 2.7.1 → 2.8.0.rc1
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.
- data/README.md +1 -1
- data/features/command_line/order.feature +29 -0
- data/features/command_line/tag.feature +10 -9
- data/features/configuration/default_path.feature +2 -2
- data/features/filtering/exclusion_filters.feature +1 -1
- data/features/filtering/run_all_when_everything_filtered.feature +1 -1
- data/features/subject/attribute_of_subject.feature +1 -1
- data/lib/rspec/core.rb +148 -12
- data/lib/rspec/core/command_line.rb +2 -2
- data/lib/rspec/core/configuration.rb +300 -155
- data/lib/rspec/core/configuration_options.rb +34 -53
- data/lib/rspec/core/deprecation.rb +4 -0
- data/lib/rspec/core/drb_options.rb +72 -0
- data/lib/rspec/core/example.rb +58 -24
- data/lib/rspec/core/example_group.rb +10 -5
- data/lib/rspec/core/extensions.rb +1 -0
- data/lib/rspec/core/extensions/ordered.rb +16 -0
- data/lib/rspec/core/filter_manager.rb +170 -0
- data/lib/rspec/core/formatters/base_formatter.rb +3 -1
- data/lib/rspec/core/formatters/base_text_formatter.rb +6 -0
- data/lib/rspec/core/formatters/snippet_extractor.rb +1 -1
- data/lib/rspec/core/hooks.rb +197 -1
- data/lib/rspec/core/let.rb +3 -2
- data/lib/rspec/core/metadata.rb +25 -4
- data/lib/rspec/core/option_parser.rb +89 -54
- data/lib/rspec/core/pending.rb +41 -0
- data/lib/rspec/core/rake_task.rb +9 -25
- data/lib/rspec/core/reporter.rb +43 -19
- data/lib/rspec/core/shared_context.rb +35 -0
- data/lib/rspec/core/shared_example_group.rb +0 -1
- data/lib/rspec/core/subject.rb +4 -4
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +34 -52
- data/spec/autotest/failed_results_re_spec.rb +2 -2
- data/spec/command_line/order_spec.rb +131 -0
- data/spec/rspec/core/command_line_spec.rb +2 -1
- data/spec/rspec/core/configuration_options_spec.rb +83 -163
- data/spec/rspec/core/configuration_spec.rb +311 -139
- data/spec/rspec/core/drb_options_spec.rb +131 -0
- data/spec/rspec/core/example_group_spec.rb +22 -11
- data/spec/rspec/core/example_spec.rb +1 -2
- data/spec/rspec/core/filter_manager_spec.rb +175 -0
- data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
- data/spec/rspec/core/formatters/html_formatter_spec.rb +3 -2
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +1 -1
- data/spec/rspec/core/metadata_spec.rb +21 -6
- data/spec/rspec/core/option_parser_spec.rb +74 -0
- data/spec/rspec/core/reporter_spec.rb +18 -1
- data/spec/rspec/core/shared_context_spec.rb +54 -17
- data/spec/rspec/core/subject_spec.rb +1 -1
- data/spec/rspec/core/world_spec.rb +7 -188
- data/spec/spec_helper.rb +47 -43
- data/spec/support/config_options_helper.rb +27 -0
- metadata +28 -12
- data/lib/rspec/core/expecting/with_rspec.rb +0 -9
- data/lib/rspec/core/expecting/with_stdlib.rb +0 -9
| @@ -3,13 +3,13 @@ require "spec_helper" | |
| 3 3 | 
             
            describe "failed_results_re for autotest" do
         | 
| 4 4 | 
             
              def run_example
         | 
| 5 5 | 
             
                group = RSpec::Core::ExampleGroup.describe("group")
         | 
| 6 | 
            -
                 | 
| 6 | 
            +
                group.example("example") { yield }
         | 
| 7 7 | 
             
                io = StringIO.new
         | 
| 8 8 | 
             
                formatter = RSpec::Core::Formatters::BaseTextFormatter.new(io)
         | 
| 9 9 | 
             
                reporter = RSpec::Core::Reporter.new(formatter)
         | 
| 10 10 |  | 
| 11 11 | 
             
                group.run(reporter)
         | 
| 12 | 
            -
                reporter.report(1) {}
         | 
| 12 | 
            +
                reporter.report(1, nil) {}
         | 
| 13 13 | 
             
                io.string
         | 
| 14 14 | 
             
              end
         | 
| 15 15 |  | 
| @@ -0,0 +1,131 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe 'command line', :ui do
         | 
| 4 | 
            +
              before :all do
         | 
| 5 | 
            +
                write_file 'spec/order_spec.rb', """
         | 
| 6 | 
            +
                  describe 'group 1' do
         | 
| 7 | 
            +
                    specify('group 1 example 1')  {}
         | 
| 8 | 
            +
                    specify('group 1 example 2')  {}
         | 
| 9 | 
            +
                    specify('group 1 example 3')  {}
         | 
| 10 | 
            +
                    specify('group 1 example 4')  {}
         | 
| 11 | 
            +
                    specify('group 1 example 5')  {}
         | 
| 12 | 
            +
                    specify('group 1 example 6')  {}
         | 
| 13 | 
            +
                    specify('group 1 example 5')  {}
         | 
| 14 | 
            +
                    specify('group 1 example 7')  {}
         | 
| 15 | 
            +
                    specify('group 1 example 8')  {}
         | 
| 16 | 
            +
                    specify('group 1 example 9')  {}
         | 
| 17 | 
            +
                    specify('group 1 example 10') {}
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    describe 'group 1-1' do
         | 
| 20 | 
            +
                      specify('group 1-1 example 1')  {}
         | 
| 21 | 
            +
                      specify('group 1-1 example 2')  {}
         | 
| 22 | 
            +
                      specify('group 1-1 example 3')  {}
         | 
| 23 | 
            +
                      specify('group 1-1 example 4')  {}
         | 
| 24 | 
            +
                      specify('group 1-1 example 5')  {}
         | 
| 25 | 
            +
                      specify('group 1-1 example 6')  {}
         | 
| 26 | 
            +
                      specify('group 1-1 example 7')  {}
         | 
| 27 | 
            +
                      specify('group 1-1 example 8')  {}
         | 
| 28 | 
            +
                      specify('group 1-1 example 9')  {}
         | 
| 29 | 
            +
                      specify('group 1-1 example 10') {}
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    describe('group 1-2')  { specify('example') {} }
         | 
| 33 | 
            +
                    describe('group 1-3')  { specify('example') {} }
         | 
| 34 | 
            +
                    describe('group 1-4')  { specify('example') {} }
         | 
| 35 | 
            +
                    describe('group 1-5')  { specify('example') {} }
         | 
| 36 | 
            +
                    describe('group 1-6')  { specify('example') {} }
         | 
| 37 | 
            +
                    describe('group 1-7')  { specify('example') {} }
         | 
| 38 | 
            +
                    describe('group 1-8')  { specify('example') {} }
         | 
| 39 | 
            +
                    describe('group 1-9')  { specify('example') {} }
         | 
| 40 | 
            +
                    describe('group 1-10') { specify('example') {} }
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  describe('group 2')  { specify('example') {} }
         | 
| 44 | 
            +
                  describe('group 3')  { specify('example') {} }
         | 
| 45 | 
            +
                  describe('group 4')  { specify('example') {} }
         | 
| 46 | 
            +
                  describe('group 5')  { specify('example') {} }
         | 
| 47 | 
            +
                  describe('group 6')  { specify('example') {} }
         | 
| 48 | 
            +
                  describe('group 7')  { specify('example') {} }
         | 
| 49 | 
            +
                  describe('group 8')  { specify('example') {} }
         | 
| 50 | 
            +
                  describe('group 9')  { specify('example') {} }
         | 
| 51 | 
            +
                  describe('group 10') { specify('example') {} }
         | 
| 52 | 
            +
                """
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              describe '--order rand' do
         | 
| 56 | 
            +
                it 'runs the examples and groups in a different order each time' do
         | 
| 57 | 
            +
                  2.times { run_command 'rspec spec/order_spec.rb --order rand -f doc' }
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  all_output.should match(/Randomized with seed \d+/)
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                  top_level_groups      {|first_run, second_run| first_run.should_not eq(second_run)}
         | 
| 62 | 
            +
                  nested_groups         {|first_run, second_run| first_run.should_not eq(second_run)}
         | 
| 63 | 
            +
                  examples('group 1')   {|first_run, second_run| first_run.should_not eq(second_run)}
         | 
| 64 | 
            +
                  examples('group 1-1') {|first_run, second_run| first_run.should_not eq(second_run)}
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
              end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
              describe '--order rand:SEED' do
         | 
| 69 | 
            +
                it 'runs the examples and groups in the same order each time' do
         | 
| 70 | 
            +
                  2.times { run_command 'rspec spec/order_spec.rb --order rand:123 -f doc' }
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                  all_output.should match(/Randomized with seed 123/)
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                  top_level_groups      {|first_run, second_run| first_run.should eq(second_run)}
         | 
| 75 | 
            +
                  nested_groups         {|first_run, second_run| first_run.should eq(second_run)}
         | 
| 76 | 
            +
                  examples('group 1')   {|first_run, second_run| first_run.should eq(second_run)}
         | 
| 77 | 
            +
                  examples('group 1-1') {|first_run, second_run| first_run.should eq(second_run)}
         | 
| 78 | 
            +
                end
         | 
| 79 | 
            +
              end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
              describe '--seed SEED' do
         | 
| 82 | 
            +
                it "forces '--order rand' and runs the examples and groups in the same order each time" do
         | 
| 83 | 
            +
                  2.times { run_command 'rspec spec/order_spec.rb --seed 123 -f doc' }
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                  all_output.should match(/Randomized with seed \d+/)
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                  top_level_groups      {|first_run, second_run| first_run.should eq(second_run)}
         | 
| 88 | 
            +
                  nested_groups         {|first_run, second_run| first_run.should eq(second_run)}
         | 
| 89 | 
            +
                  examples('group 1')   {|first_run, second_run| first_run.should eq(second_run)}
         | 
| 90 | 
            +
                  examples('group 1-1') {|first_run, second_run| first_run.should eq(second_run)}
         | 
| 91 | 
            +
                end
         | 
| 92 | 
            +
              end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
              describe '--order default on CLI with --order rand in .rspec' do
         | 
| 95 | 
            +
                it "overrides --order rand with --order default" do
         | 
| 96 | 
            +
                  write_file '.rspec', '--order rand'
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                  run_command 'rspec spec/order_spec.rb --order default -f doc'
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                  all_output.should_not match(/Randomized/)
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  all_output.should match(/group 1.*group 1 example 1.*group 1 example 2.*group 1-1.*group 1-2.*group 2.*/m)
         | 
| 103 | 
            +
                end
         | 
| 104 | 
            +
              end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
              def examples(group)
         | 
| 107 | 
            +
                yield split_in_half(all_stdout.scan(/^\s+#{group} example.*$/))
         | 
| 108 | 
            +
              end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
              def top_level_groups
         | 
| 111 | 
            +
                yield example_groups_at_level(0)
         | 
| 112 | 
            +
              end
         | 
| 113 | 
            +
             | 
| 114 | 
            +
              def nested_groups
         | 
| 115 | 
            +
                yield example_groups_at_level(2)
         | 
| 116 | 
            +
              end
         | 
| 117 | 
            +
             | 
| 118 | 
            +
              def example_groups_at_level(level)
         | 
| 119 | 
            +
                split_in_half(all_stdout.scan(/^\s{#{level*2}}group.*$/))
         | 
| 120 | 
            +
              end
         | 
| 121 | 
            +
             | 
| 122 | 
            +
              def split_in_half(array)
         | 
| 123 | 
            +
                length, midpoint = array.length, array.length / 2
         | 
| 124 | 
            +
                return array.slice(0, midpoint), array.slice(midpoint, length)
         | 
| 125 | 
            +
              end
         | 
| 126 | 
            +
             | 
| 127 | 
            +
              def run_command(cmd)
         | 
| 128 | 
            +
                # Wraps aruba api - 2nd param is fail_on_error
         | 
| 129 | 
            +
                run_simple cmd, false
         | 
| 130 | 
            +
              end
         | 
| 131 | 
            +
            end
         | 
| @@ -95,7 +95,8 @@ module RSpec::Core | |
| 95 95 | 
             
                    # this is necessary to ensure that color works correctly on windows
         | 
| 96 96 | 
             
                    config.should_receive(:error_stream=).ordered
         | 
| 97 97 | 
             
                    config.should_receive(:output_stream=).ordered
         | 
| 98 | 
            -
                    config.should_receive(: | 
| 98 | 
            +
                    config.should_receive(:force).with(:default_path => anything).ordered
         | 
| 99 | 
            +
                    config.should_receive(:force).with(:color => true).ordered
         | 
| 99 100 | 
             
                    command_line.run(err, out) rescue nil
         | 
| 100 101 | 
             
                  end
         | 
| 101 102 |  | 
| @@ -1,18 +1,8 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 | 
             
            require 'ostruct'
         | 
| 3 | 
            -
            require 'tmpdir'
         | 
| 4 3 |  | 
| 5 4 | 
             
            describe RSpec::Core::ConfigurationOptions do
         | 
| 6 | 
            -
             | 
| 7 | 
            -
              def config_options_object(*args)
         | 
| 8 | 
            -
                coo = RSpec::Core::ConfigurationOptions.new(args)
         | 
| 9 | 
            -
                coo.parse_options
         | 
| 10 | 
            -
                coo
         | 
| 11 | 
            -
              end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              def parse_options(*args)
         | 
| 14 | 
            -
                config_options_object(*args).options
         | 
| 15 | 
            -
              end
         | 
| 5 | 
            +
              include ConfigOptionsHelper
         | 
| 16 6 |  | 
| 17 7 | 
             
              it "warns when HOME env var is not set", :unless => (RUBY_PLATFORM == 'java') do
         | 
| 18 8 | 
             
                begin
         | 
| @@ -45,7 +35,7 @@ describe RSpec::Core::ConfigurationOptions do | |
| 45 35 | 
             
                it "sends default_path before files_or_directories_to_run" do
         | 
| 46 36 | 
             
                  opts = config_options_object(*%w[--default_path spec])
         | 
| 47 37 | 
             
                  config = double("config").as_null_object
         | 
| 48 | 
            -
                  config.should_receive(:default_path | 
| 38 | 
            +
                  config.should_receive(:force).with(:default_path => 'spec').ordered
         | 
| 49 39 | 
             
                  config.should_receive(:files_or_directories_to_run=).ordered
         | 
| 50 40 | 
             
                  opts.configure(config)
         | 
| 51 41 | 
             
                end
         | 
| @@ -53,7 +43,7 @@ describe RSpec::Core::ConfigurationOptions do | |
| 53 43 | 
             
                it "sends pattern before files_or_directories_to_run" do
         | 
| 54 44 | 
             
                  opts = config_options_object(*%w[--pattern **/*.spec])
         | 
| 55 45 | 
             
                  config = double("config").as_null_object
         | 
| 56 | 
            -
                  config.should_receive(:pattern | 
| 46 | 
            +
                  config.should_receive(:force).with(:pattern => '**/*.spec').ordered
         | 
| 57 47 | 
             
                  config.should_receive(:files_or_directories_to_run=).ordered
         | 
| 58 48 | 
             
                  opts.configure(config)
         | 
| 59 49 | 
             
                end
         | 
| @@ -64,27 +54,81 @@ describe RSpec::Core::ConfigurationOptions do | |
| 64 54 | 
             
                  opts.configure(config)
         | 
| 65 55 | 
             
                  config.exclusion_filter.should have_key(:slow)
         | 
| 66 56 | 
             
                end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                it "forces color_enabled" do
         | 
| 59 | 
            +
                  opts = config_options_object(*%w[--color])
         | 
| 60 | 
            +
                  config = RSpec::Core::Configuration.new
         | 
| 61 | 
            +
                  config.should_receive(:force).with(:color => true)
         | 
| 62 | 
            +
                  opts.configure(config)
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                it "assigns filter" do
         | 
| 66 | 
            +
                  pending
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                [
         | 
| 70 | 
            +
                  ["--failure-exit-code", "3", :failure_exit_code, 3 ],
         | 
| 71 | 
            +
                  ["--pattern", "foo/bar", :pattern, "foo/bar"],
         | 
| 72 | 
            +
                  ["--failure-exit-code", "37", :failure_exit_code, 37],
         | 
| 73 | 
            +
                  ["--default_path", "behavior", :default_path, "behavior"],
         | 
| 74 | 
            +
                  ["--drb", nil, :drb, true],
         | 
| 75 | 
            +
                  ["--drb-port", "37", :drb_port, 37],
         | 
| 76 | 
            +
                  ["--backtrace", nil, :full_backtrace, true],
         | 
| 77 | 
            +
                  ["--profile", nil, :profile_examples, true],
         | 
| 78 | 
            +
                  ["--tty", nil, :tty, true]
         | 
| 79 | 
            +
                ].each do |cli_option, cli_value, config_key, config_value|
         | 
| 80 | 
            +
                  it "forces #{config_key}" do
         | 
| 81 | 
            +
                    opts = config_options_object(*[cli_option, cli_value].compact)
         | 
| 82 | 
            +
                    config = RSpec::Core::Configuration.new
         | 
| 83 | 
            +
                    config.should_receive(:force) do |pair|
         | 
| 84 | 
            +
                      pair.keys.first.should eq(config_key)
         | 
| 85 | 
            +
                      pair.values.first.should eq(config_value)
         | 
| 86 | 
            +
                    end
         | 
| 87 | 
            +
                    opts.configure(config)
         | 
| 88 | 
            +
                  end
         | 
| 89 | 
            +
                end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                it "sets order directly" do
         | 
| 92 | 
            +
                  opts = config_options_object("--order", "rand")
         | 
| 93 | 
            +
                  config = RSpec::Core::Configuration.new
         | 
| 94 | 
            +
                  opts.configure(config)
         | 
| 95 | 
            +
                  config.order.should eq("rand")
         | 
| 96 | 
            +
                end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                it "sets seed directly" do
         | 
| 99 | 
            +
                  opts = config_options_object("--seed", "37")
         | 
| 100 | 
            +
                  config = RSpec::Core::Configuration.new
         | 
| 101 | 
            +
                  opts.configure(config)
         | 
| 102 | 
            +
                  config.seed.should eq(37)
         | 
| 103 | 
            +
                end
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                it "sets debug directly" do
         | 
| 106 | 
            +
                  opts = config_options_object("--debug")
         | 
| 107 | 
            +
                  config = RSpec::Core::Configuration.new
         | 
| 108 | 
            +
                  config.should_receive(:debug=).with(true)
         | 
| 109 | 
            +
                  opts.configure(config)
         | 
| 110 | 
            +
                end
         | 
| 67 111 | 
             
              end
         | 
| 68 112 |  | 
| 69 113 | 
             
              describe "-c, --color, and --colour" do
         | 
| 70 | 
            -
                it "sets : | 
| 71 | 
            -
                  parse_options('-c').should include(: | 
| 72 | 
            -
                  parse_options('--color').should include(: | 
| 73 | 
            -
                  parse_options('--colour').should include(: | 
| 114 | 
            +
                it "sets :color => true" do
         | 
| 115 | 
            +
                  parse_options('-c').should include(:color => true)
         | 
| 116 | 
            +
                  parse_options('--color').should include(:color => true)
         | 
| 117 | 
            +
                  parse_options('--colour').should include(:color => true)
         | 
| 74 118 | 
             
                end
         | 
| 75 119 | 
             
              end
         | 
| 76 120 |  | 
| 77 121 | 
             
              describe "--no-color" do
         | 
| 78 | 
            -
                it "sets : | 
| 79 | 
            -
                  parse_options('--no-color').should include(: | 
| 122 | 
            +
                it "sets :color => false" do
         | 
| 123 | 
            +
                  parse_options('--no-color').should include(:color => false)
         | 
| 80 124 | 
             
                end
         | 
| 81 125 |  | 
| 82 | 
            -
                it "overrides previous : | 
| 83 | 
            -
                  parse_options('--color', '--no-color').should include(: | 
| 126 | 
            +
                it "overrides previous :color => true" do
         | 
| 127 | 
            +
                  parse_options('--color', '--no-color').should include(:color => false)
         | 
| 84 128 | 
             
                end
         | 
| 85 129 |  | 
| 86 | 
            -
                it "gets overriden by a subsequent : | 
| 87 | 
            -
                  parse_options('--no-color', '--color').should include(: | 
| 130 | 
            +
                it "gets overriden by a subsequent :color => true" do
         | 
| 131 | 
            +
                  parse_options('--no-color', '--color').should include(:color => true)
         | 
| 88 132 | 
             
                end
         | 
| 89 133 | 
             
              end
         | 
| 90 134 |  | 
| @@ -204,15 +248,13 @@ describe RSpec::Core::ConfigurationOptions do | |
| 204 248 | 
             
                  end
         | 
| 205 249 |  | 
| 206 250 | 
             
                  it "turns off the debugger option if --drb is specified in the options file" do
         | 
| 207 | 
            -
                    File. | 
| 208 | 
            -
                    IO.stub(:read) { "--drb" }
         | 
| 251 | 
            +
                    File.open("./.rspec", "w") {|f| f << "--drb"}
         | 
| 209 252 | 
             
                    config_options_object("--debug").drb_argv.should_not include("--debug")
         | 
| 210 253 | 
             
                    config_options_object("-d"     ).drb_argv.should_not include("--debug")
         | 
| 211 254 | 
             
                  end
         | 
| 212 255 |  | 
| 213 256 | 
             
                  it "turns off the debugger option if --debug is specified in the options file" do
         | 
| 214 | 
            -
                    File. | 
| 215 | 
            -
                    IO.stub(:read) { "--debug" }
         | 
| 257 | 
            +
                    File.open("./.rspec", "w") {|f| f << "--debug"}
         | 
| 216 258 | 
             
                    config_options_object("--drb").drb_argv.should_not include("--debug")
         | 
| 217 259 | 
             
                    config_options_object("-X"   ).drb_argv.should_not include("--debug")
         | 
| 218 260 | 
             
                  end
         | 
| @@ -265,145 +307,20 @@ describe RSpec::Core::ConfigurationOptions do | |
| 265 307 | 
             
              describe "default_path" do
         | 
| 266 308 | 
             
                it "gets set before files_or_directories_to_run" do
         | 
| 267 309 | 
             
                  config = double("config").as_null_object
         | 
| 268 | 
            -
                  config.should_receive(:default_path | 
| 310 | 
            +
                  config.should_receive(:force).with(:default_path => 'foo').ordered
         | 
| 269 311 | 
             
                  config.should_receive(:files_or_directories_to_run=).ordered
         | 
| 270 312 | 
             
                  opts = config_options_object("--default_path", "foo")
         | 
| 271 313 | 
             
                  opts.configure(config)
         | 
| 272 314 | 
             
                end
         | 
| 273 315 | 
             
              end
         | 
| 274 316 |  | 
| 275 | 
            -
              # TODO ensure all options are output
         | 
| 276 | 
            -
              describe "#drb_argv" do
         | 
| 277 | 
            -
                it "preserves extra arguments" do
         | 
| 278 | 
            -
                  File.stub(:exist?) { false }
         | 
| 279 | 
            -
                  config_options_object(*%w[ a --drb b --color c ]).drb_argv.should =~ %w[ --color a b c ]
         | 
| 280 | 
            -
                end
         | 
| 281 | 
            -
             | 
| 282 | 
            -
                it "includes --fail-fast" do
         | 
| 283 | 
            -
                  config_options_object(*%w[--fail-fast]).drb_argv.should include("--fail-fast")
         | 
| 284 | 
            -
                end
         | 
| 285 | 
            -
             | 
| 286 | 
            -
                it "includes --options" do
         | 
| 287 | 
            -
                  config_options_object(*%w[--options custom.opts]).drb_argv.should include("--options", "custom.opts")
         | 
| 288 | 
            -
                end
         | 
| 289 | 
            -
             | 
| 290 | 
            -
                context "with --example" do
         | 
| 291 | 
            -
                  it "includes --example" do
         | 
| 292 | 
            -
                    config_options_object(*%w[--example foo]).drb_argv.should include("--example", "foo")
         | 
| 293 | 
            -
                  end
         | 
| 294 | 
            -
             | 
| 295 | 
            -
                  it "unescapes characters which were escaped upon storing --example originally" do
         | 
| 296 | 
            -
                    config_options_object("--example", "foo\\ bar").drb_argv.should include("--example", "foo bar")
         | 
| 297 | 
            -
                  end
         | 
| 298 | 
            -
                end
         | 
| 299 | 
            -
             | 
| 300 | 
            -
                context "with tags" do
         | 
| 301 | 
            -
                  it "includes the inclusion tags" do
         | 
| 302 | 
            -
                    coo = config_options_object("--tag", "tag")
         | 
| 303 | 
            -
                    coo.drb_argv.should eq(["--tag", "tag"])
         | 
| 304 | 
            -
                  end
         | 
| 305 | 
            -
             | 
| 306 | 
            -
                  it "leaves inclusion tags intact" do
         | 
| 307 | 
            -
                    coo = config_options_object("--tag", "tag")
         | 
| 308 | 
            -
                    coo.drb_argv
         | 
| 309 | 
            -
                    coo.options[:filter].should eq( {:tag=>true} )
         | 
| 310 | 
            -
                  end
         | 
| 311 | 
            -
             | 
| 312 | 
            -
                  it "includes the exclusion tags" do
         | 
| 313 | 
            -
                    coo = config_options_object("--tag", "~tag")
         | 
| 314 | 
            -
                    coo.drb_argv.should eq(["--tag", "~tag"])
         | 
| 315 | 
            -
                  end
         | 
| 316 | 
            -
             | 
| 317 | 
            -
                  it "leaves exclusion tags intact" do
         | 
| 318 | 
            -
                    coo = config_options_object("--tag", "~tag")
         | 
| 319 | 
            -
                    coo.drb_argv
         | 
| 320 | 
            -
                    coo.options[:exclusion_filter].should eq( {:tag=>true} )
         | 
| 321 | 
            -
                  end
         | 
| 322 | 
            -
                end
         | 
| 323 | 
            -
             | 
| 324 | 
            -
                context "with formatters" do
         | 
| 325 | 
            -
                  it "includes the formatters" do
         | 
| 326 | 
            -
                    coo = config_options_object("--format", "d")
         | 
| 327 | 
            -
                    coo.drb_argv.should eq(["--format", "d"])
         | 
| 328 | 
            -
                  end
         | 
| 329 | 
            -
             | 
| 330 | 
            -
                  it "leaves formatters intact" do
         | 
| 331 | 
            -
                    coo = config_options_object("--format", "d")
         | 
| 332 | 
            -
                    coo.drb_argv
         | 
| 333 | 
            -
                    coo.options[:formatters].should eq([["d"]])
         | 
| 334 | 
            -
                  end
         | 
| 335 | 
            -
             | 
| 336 | 
            -
                  it "leaves output intact" do
         | 
| 337 | 
            -
                    coo = config_options_object("--format", "p", "--out", "foo.txt", "--format", "d")
         | 
| 338 | 
            -
                    coo.drb_argv
         | 
| 339 | 
            -
                    coo.options[:formatters].should eq([["p","foo.txt"],["d"]])
         | 
| 340 | 
            -
                  end
         | 
| 341 | 
            -
                end
         | 
| 342 | 
            -
             | 
| 343 | 
            -
                context "--drb specified in ARGV" do
         | 
| 344 | 
            -
                  it "renders all the original arguments except --drb" do
         | 
| 345 | 
            -
                    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]).
         | 
| 346 | 
            -
                      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])
         | 
| 347 | 
            -
                  end
         | 
| 348 | 
            -
                end
         | 
| 349 | 
            -
             | 
| 350 | 
            -
                context "--drb specified in the options file" do
         | 
| 351 | 
            -
                  it "renders all the original arguments except --drb" do
         | 
| 352 | 
            -
                    File.stub(:exist?) { true }
         | 
| 353 | 
            -
                    IO.stub(:read) { "--drb --color" }
         | 
| 354 | 
            -
                    config_options_object(*%w[ --tty --format s --example pattern --line_number 1 --profile --backtrace ]).
         | 
| 355 | 
            -
                      drb_argv.should eq(%w[ --color --profile --backtrace --tty --example pattern --line_number 1 --format s])
         | 
| 356 | 
            -
                  end
         | 
| 357 | 
            -
                end
         | 
| 358 | 
            -
             | 
| 359 | 
            -
                context "--drb specified in ARGV and the options file" do
         | 
| 360 | 
            -
                  it "renders all the original arguments except --drb" do
         | 
| 361 | 
            -
                    File.stub(:exist?) { true }
         | 
| 362 | 
            -
                    IO.stub(:read) { "--drb --color" }
         | 
| 363 | 
            -
                    config_options_object(*%w[ --drb --format s --example pattern --line_number 1 --profile --backtrace]).
         | 
| 364 | 
            -
                      drb_argv.should eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s])
         | 
| 365 | 
            -
                  end
         | 
| 366 | 
            -
                end
         | 
| 367 | 
            -
             | 
| 368 | 
            -
                context "--drb specified in ARGV and in as ARGV-specified --options file" do
         | 
| 369 | 
            -
                  it "renders all the original arguments except --drb and --options" do
         | 
| 370 | 
            -
                    File.stub(:exist?) { true }
         | 
| 371 | 
            -
                    IO.stub(:read) { "--drb --color" }
         | 
| 372 | 
            -
                    config_options_object(*%w[ --drb --format s --example pattern --line_number 1 --profile --backtrace]).
         | 
| 373 | 
            -
                      drb_argv.should eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s ])
         | 
| 374 | 
            -
                  end
         | 
| 375 | 
            -
                end
         | 
| 376 | 
            -
              end
         | 
| 377 | 
            -
             | 
| 378 317 | 
             
              describe "sources: ~/.rspec, ./.rspec, custom, CLI, and SPEC_OPTS" do
         | 
| 379 | 
            -
                let(:local_options_file)  { File.join(Dir.tmpdir, ".rspec-local") }
         | 
| 380 | 
            -
                let(:global_options_file) { File.join(Dir.tmpdir, ".rspec-global") }
         | 
| 381 | 
            -
                let(:custom_options_file) { File.join(Dir.tmpdir, "custom.options") }
         | 
| 382 | 
            -
             | 
| 383 | 
            -
                before do
         | 
| 384 | 
            -
                  @orig_spec_opts = ENV["SPEC_OPTS"]
         | 
| 385 | 
            -
                  RSpec::Core::ConfigurationOptions::send :public, :global_options_file
         | 
| 386 | 
            -
                  RSpec::Core::ConfigurationOptions::send :public, :local_options_file
         | 
| 387 | 
            -
                  RSpec::Core::ConfigurationOptions::any_instance.stub(:global_options_file) { global_options_file }
         | 
| 388 | 
            -
                  RSpec::Core::ConfigurationOptions::any_instance.stub(:local_options_file) { local_options_file }
         | 
| 389 | 
            -
                end
         | 
| 390 | 
            -
             | 
| 391 | 
            -
                after do
         | 
| 392 | 
            -
                  ENV["SPEC_OPTS"] = @orig_spec_opts
         | 
| 393 | 
            -
                  RSpec::Core::ConfigurationOptions::send :private, :global_options_file
         | 
| 394 | 
            -
                  RSpec::Core::ConfigurationOptions::send :private, :local_options_file
         | 
| 395 | 
            -
                end
         | 
| 396 | 
            -
             | 
| 397 | 
            -
                def write_options(scope, options)
         | 
| 398 | 
            -
                  File.open(send("#{scope}_options_file"), 'w') { |f| f.write(options) }
         | 
| 399 | 
            -
                end
         | 
| 400 | 
            -
             | 
| 401 318 | 
             
                it "merges global, local, SPEC_OPTS, and CLI" do
         | 
| 402 | 
            -
                   | 
| 403 | 
            -
                   | 
| 319 | 
            +
                  File.open("./.rspec", "w") {|f| f << "--line 37"}
         | 
| 320 | 
            +
                  File.open("~/.rspec", "w") {|f| f << "--color"}
         | 
| 404 321 | 
             
                  ENV["SPEC_OPTS"] = "--debug"
         | 
| 405 322 | 
             
                  options = parse_options("--drb")
         | 
| 406 | 
            -
                  options[: | 
| 323 | 
            +
                  options[:color].should be_true
         | 
| 407 324 | 
             
                  options[:line_numbers].should eq(["37"])
         | 
| 408 325 | 
             
                  options[:debug].should be_true
         | 
| 409 326 | 
             
                  options[:drb].should be_true
         | 
| @@ -415,22 +332,25 @@ describe RSpec::Core::ConfigurationOptions do | |
| 415 332 | 
             
                end
         | 
| 416 333 |  | 
| 417 334 | 
             
                it "prefers CLI over file options" do
         | 
| 418 | 
            -
                   | 
| 419 | 
            -
                   | 
| 335 | 
            +
                  File.open("./.rspec", "w") {|f| f << "--format local"}
         | 
| 336 | 
            +
                  File.open("~/.rspec", "w") {|f| f << "--format global"}
         | 
| 420 337 | 
             
                  parse_options("--format", "cli")[:formatters].should eq([['cli']])
         | 
| 421 338 | 
             
                end
         | 
| 422 339 |  | 
| 423 340 | 
             
                it "prefers local file options over global" do
         | 
| 424 | 
            -
                   | 
| 425 | 
            -
                   | 
| 341 | 
            +
                  File.open("./.rspec", "w") {|f| f << "--format local"}
         | 
| 342 | 
            +
                  File.open("~/.rspec", "w") {|f| f << "--format global"}
         | 
| 426 343 | 
             
                  parse_options[:formatters].should eq([['local']])
         | 
| 427 344 | 
             
                end
         | 
| 428 345 |  | 
| 429 346 | 
             
                context "with custom options file" do
         | 
| 430 347 | 
             
                  it "ignores local and global options files" do
         | 
| 431 | 
            -
                     | 
| 432 | 
            -
                     | 
| 433 | 
            -
                     | 
| 348 | 
            +
                    File.open("./.rspec", "w") {|f| f << "--format local"}
         | 
| 349 | 
            +
                    File.open("~/.rspec", "w") {|f| f << "--format global"}
         | 
| 350 | 
            +
                    File.open("./custom.opts", "w") {|f| f << "--color"}
         | 
| 351 | 
            +
                    options = parse_options("-O", "./custom.opts")
         | 
| 352 | 
            +
                    options[:format].should be_nil
         | 
| 353 | 
            +
                    options[:color].should be_true
         | 
| 434 354 | 
             
                  end
         | 
| 435 355 | 
             
                end
         | 
| 436 356 | 
             
              end
         |