rspec-core 2.12.2 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/Changelog.md +31 -0
  2. data/README.md +11 -10
  3. data/features/command_line/example_name_option.feature +6 -10
  4. data/features/command_line/tag.feature +15 -8
  5. data/features/configuration/backtrace_clean_patterns.feature +102 -0
  6. data/features/configuration/failure_exit_code.feature +36 -0
  7. data/features/configuration/order_and_seed.feature +3 -0
  8. data/features/configuration/output_stream.feature +24 -0
  9. data/features/configuration/pattern.feature +30 -0
  10. data/features/configuration/profile.feature +163 -0
  11. data/features/configuration/run_all_when_everything_filtered.feature +60 -0
  12. data/features/configuration/show_failures_in_pending_blocks.feature +61 -0
  13. data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +52 -0
  14. data/features/filtering/exclusion_filters.feature +1 -2
  15. data/features/formatters/configurable_colors.feature +31 -0
  16. data/features/step_definitions/additional_cli_steps.rb +21 -0
  17. data/features/subject/explicit_subject.feature +19 -0
  18. data/lib/autotest/rspec2.rb +1 -1
  19. data/lib/rspec/core.rb +1 -2
  20. data/lib/rspec/core/configuration.rb +33 -3
  21. data/lib/rspec/core/configuration_options.rb +5 -5
  22. data/lib/rspec/core/deprecation.rb +1 -1
  23. data/lib/rspec/core/example.rb +2 -2
  24. data/lib/rspec/core/example_group.rb +1 -3
  25. data/lib/rspec/core/formatters/base_text_formatter.rb +93 -27
  26. data/lib/rspec/core/formatters/documentation_formatter.rb +3 -3
  27. data/lib/rspec/core/formatters/progress_formatter.rb +3 -3
  28. data/lib/rspec/core/memoized_helpers.rb +425 -0
  29. data/lib/rspec/core/metadata.rb +6 -2
  30. data/lib/rspec/core/option_parser.rb +8 -2
  31. data/lib/rspec/core/pending.rb +7 -0
  32. data/lib/rspec/core/shared_context.rb +1 -1
  33. data/lib/rspec/core/version.rb +1 -1
  34. data/spec/autotest/failed_results_re_spec.rb +4 -4
  35. data/spec/autotest/rspec_spec.rb +25 -20
  36. data/spec/command_line/order_spec.rb +21 -21
  37. data/spec/rspec/core/command_line_spec.rb +6 -6
  38. data/spec/rspec/core/configuration_options_spec.rb +86 -72
  39. data/spec/rspec/core/configuration_spec.rb +161 -156
  40. data/spec/rspec/core/deprecations_spec.rb +4 -4
  41. data/spec/rspec/core/drb_command_line_spec.rb +9 -9
  42. data/spec/rspec/core/drb_options_spec.rb +46 -33
  43. data/spec/rspec/core/dsl_spec.rb +3 -3
  44. data/spec/rspec/core/example_group_spec.rb +156 -124
  45. data/spec/rspec/core/example_spec.rb +68 -52
  46. data/spec/rspec/core/filter_manager_spec.rb +36 -36
  47. data/spec/rspec/core/formatters/base_formatter_spec.rb +9 -9
  48. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +104 -42
  49. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +4 -4
  50. data/spec/rspec/core/formatters/helpers_spec.rb +13 -13
  51. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +5 -17
  52. data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +159 -44
  53. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +14 -14
  54. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +20 -20
  55. data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +5 -5
  56. data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +159 -44
  57. data/spec/rspec/core/formatters/html_formatted-1.9.3.html +20 -20
  58. data/spec/rspec/core/formatters/{html_formatted-1.9.2-jruby.html → html_formatted-2.0.0.html} +24 -18
  59. data/spec/rspec/core/formatters/html_formatter_spec.rb +9 -5
  60. data/spec/rspec/core/formatters/json_formatter_spec.rb +9 -9
  61. data/spec/rspec/core/formatters/progress_formatter_spec.rb +4 -4
  62. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +3 -3
  63. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +5 -17
  64. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-rbx.html +159 -44
  65. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +16 -16
  66. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +23 -23
  67. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-jruby.html +5 -17
  68. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-rbx.html +159 -44
  69. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +23 -23
  70. data/spec/rspec/core/formatters/{text_mate_formatted-1.9.2-jruby.html → text_mate_formatted-2.0.0.html} +25 -19
  71. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +8 -4
  72. data/spec/rspec/core/hooks_filtering_spec.rb +16 -16
  73. data/spec/rspec/core/hooks_spec.rb +11 -11
  74. data/spec/rspec/core/kernel_extensions_spec.rb +1 -1
  75. data/spec/rspec/core/memoized_helpers_spec.rb +458 -0
  76. data/spec/rspec/core/metadata_spec.rb +74 -74
  77. data/spec/rspec/core/option_parser_spec.rb +27 -27
  78. data/spec/rspec/core/pending_example_spec.rb +32 -32
  79. data/spec/rspec/core/project_initializer_spec.rb +8 -8
  80. data/spec/rspec/core/rake_task_spec.rb +16 -16
  81. data/spec/rspec/core/reporter_spec.rb +3 -3
  82. data/spec/rspec/core/resources/formatter_specs.rb +4 -4
  83. data/spec/rspec/core/ruby_project_spec.rb +4 -2
  84. data/spec/rspec/core/shared_context_spec.rb +34 -7
  85. data/spec/rspec/core/shared_example_group_spec.rb +14 -14
  86. data/spec/rspec/core/world_spec.rb +9 -9
  87. data/spec/rspec/core_spec.rb +5 -5
  88. data/spec/spec_helper.rb +4 -0
  89. data/spec/support/shared_example_groups.rb +4 -4
  90. data/spec/support/spec_files.rb +2 -2
  91. metadata +158 -150
  92. data/lib/rspec/core/let.rb +0 -110
  93. data/lib/rspec/core/subject.rb +0 -223
  94. data/spec/rspec/core/let_spec.rb +0 -55
  95. data/spec/rspec/core/subject_spec.rb +0 -255
@@ -126,8 +126,12 @@ module RSpec
126
126
 
127
127
  def described_class
128
128
  container_stack.each do |g|
129
- return g[:described_class] if g.has_key?(:described_class)
130
- return g[:describes] if g.has_key?(:describes)
129
+ [:described_class, :describes].each do |key|
130
+ if g.has_key?(key)
131
+ value = g[key]
132
+ return value unless value.nil?
133
+ end
134
+ end
131
135
  end
132
136
 
133
137
  container_stack.reverse.each do |g|
@@ -135,8 +135,14 @@ module RSpec::Core
135
135
  options[:color] = o
136
136
  end
137
137
 
138
- parser.on('-p', '--profile', 'Enable profiling of examples and list 10 slowest examples.') do |o|
139
- options[:profile_examples] = o
138
+ parser.on('-p', '--[no-]profile [COUNT]', 'Enable profiling of examples and list the slowest examples (default: 10).') do |argument|
139
+ options[:profile_examples] = if argument.nil?
140
+ true
141
+ elsif argument == false
142
+ false
143
+ else
144
+ argument.to_i
145
+ end
140
146
  end
141
147
 
142
148
  parser.separator <<-FILTERING
@@ -68,6 +68,13 @@ module RSpec
68
68
  # it "does something", :pending => true do
69
69
  # # ...
70
70
  # end
71
+ #
72
+ # or pass `:pending => "something else getting finished"` to add a
73
+ # message to the summary report:
74
+ #
75
+ # it "does something", :pending => "something else getting finished" do
76
+ # # ...
77
+ # end
71
78
  def pending(*args)
72
79
  return self.class.before(:each) { pending(*args) } unless example
73
80
 
@@ -18,7 +18,7 @@ module RSpec
18
18
  # end
19
19
  module SharedContext
20
20
  include Hooks
21
- include Let::ExampleGroupMethods
21
+ include MemoizedHelpers::ClassMethods
22
22
 
23
23
  def included(group)
24
24
  [:before, :after].each do |type|
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Core
3
3
  module Version
4
- STRING = '2.12.2'
4
+ STRING = '2.13.0'
5
5
  end
6
6
  end
7
7
  end
@@ -16,14 +16,14 @@ describe "failed_results_re for autotest" do
16
16
  shared_examples "autotest failed_results_re" do
17
17
  it "matches a failure" do
18
18
  output = run_example { fail }
19
- output.should match(Autotest::Rspec2.new.failed_results_re)
20
- output.should include(__FILE__.sub(File.expand_path('.'),'.'))
19
+ expect(output).to match(Autotest::Rspec2.new.failed_results_re)
20
+ expect(output).to include(__FILE__.sub(File.expand_path('.'),'.'))
21
21
  end
22
22
 
23
23
  it "does not match when there are no failures" do
24
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('.'),'.'))
25
+ expect(output).not_to match(Autotest::Rspec2.new.failed_results_re)
26
+ expect(output).not_to include(__FILE__.sub(File.expand_path('.'),'.'))
27
27
  end
28
28
  end
29
29
 
@@ -11,8 +11,7 @@ describe Autotest::Rspec2 do
11
11
 
12
12
  it "uses autotest's prefix" do
13
13
  rspec_autotest.prefix = "this is the prefix "
14
- rspec_autotest.
15
- make_test_cmd({'a' => 'b'}).should match(/this is the prefix/)
14
+ expect(rspec_autotest.make_test_cmd({'a' => 'b'})).to match(/this is the prefix/)
16
15
  end
17
16
 
18
17
  describe "commands" do
@@ -28,37 +27,43 @@ describe Autotest::Rspec2 do
28
27
  @to_test = files.map { |f| File.expand_path(f) }.join ' '
29
28
  end
30
29
 
30
+ it "uses double quotes for windows compatibility" do
31
+ command = rspec_autotest.make_test_cmd(@files_to_test)
32
+ expect(command).to include('"')
33
+ expect(command).not_to include("'")
34
+ end
35
+
31
36
  it "makes the appropriate test command" do
32
37
  actual_command = rspec_autotest.make_test_cmd(@files_to_test)
33
- expected_command = /#{ruby_cmd}.*'#{spec_cmd}' (.*)/
38
+ expected_command = /#{ruby_cmd}.*"#{spec_cmd}" (.*)/
34
39
 
35
- actual_command.should match(expected_command)
40
+ expect(actual_command).to match(expected_command)
36
41
 
37
42
  actual_command =~ expected_command
38
- $1.should =~ /#{File.expand_path('file_one')}/
39
- $1.should =~ /#{File.expand_path('file_two')}/
43
+ expect($1).to match /#{File.expand_path('file_one')}/
44
+ expect($1).to match /#{File.expand_path('file_two')}/
40
45
  end
41
46
 
42
47
  it "returns a blank command for no files" do
43
- rspec_autotest.make_test_cmd({}).should eq('')
48
+ expect(rspec_autotest.make_test_cmd({})).to eq('')
44
49
  end
45
50
 
46
51
  it "quotes the paths of files to test" do
47
52
  cmd = rspec_autotest.make_test_cmd(@files_to_test)
48
53
  @files_to_test.keys.each do |file_to_test|
49
- cmd.should match(/'#{File.expand_path(file_to_test)}'/)
54
+ expect(cmd).to match(/"#{File.expand_path(file_to_test)}"/)
50
55
  end
51
56
  end
52
57
 
53
58
  it "quotes the path of the ruby executable" do
54
59
  cmd = rspec_autotest.make_test_cmd(@files_to_test)
55
- cmd.should match(%r('/path/to/ruby'))
60
+ expect(cmd).to match(%r("/path/to/ruby"))
56
61
  end
57
62
 
58
63
  it "gives '--tty' to #{Autotest::Rspec2::RSPEC_EXECUTABLE}, not '--autotest'" do
59
64
  cmd = rspec_autotest.make_test_cmd(@files_to_test)
60
- cmd.should match(' --tty ')
61
- cmd.should_not match(' --autotest ')
65
+ expect(cmd).to match(' --tty ')
66
+ expect(cmd).not_to match(' --autotest ')
62
67
  end
63
68
  end
64
69
 
@@ -70,19 +75,19 @@ describe Autotest::Rspec2 do
70
75
  end
71
76
 
72
77
  it "finds the spec file for a given lib file" do
73
- rspec_autotest.should map_specs([@spec_file]).to(@lib_file)
78
+ expect(rspec_autotest).to map_specs([@spec_file]).to(@lib_file)
74
79
  end
75
80
 
76
81
  it "finds the spec file if given a spec file" do
77
- rspec_autotest.should map_specs([@spec_file]).to(@spec_file)
82
+ expect(rspec_autotest).to map_specs([@spec_file]).to(@spec_file)
78
83
  end
79
84
 
80
85
  it "ignores files in spec dir that aren't specs" do
81
- rspec_autotest.should map_specs([]).to("spec/spec_helper.rb")
86
+ expect(rspec_autotest).to map_specs([]).to("spec/spec_helper.rb")
82
87
  end
83
88
 
84
89
  it "ignores untracked files (in @file)" do
85
- rspec_autotest.should map_specs([]).to("lib/untracked_file")
90
+ expect(rspec_autotest).to map_specs([]).to("lib/untracked_file")
86
91
  end
87
92
  end
88
93
 
@@ -91,12 +96,12 @@ describe Autotest::Rspec2 do
91
96
  let(:spec_file) { "spec/autotest/some_spec.rb" }
92
97
 
93
98
  it "returns no failures if no failures were given in the output" do
94
- rspec_autotest.consolidate_failures([[]]).should eq({})
99
+ expect(rspec_autotest.consolidate_failures([[]])).to eq({})
95
100
  end
96
101
 
97
102
  it "returns a hash with the spec filename => spec name for each failure or error" do
98
103
  failures = [ [ "false should be false", spec_file ] ]
99
- rspec_autotest.consolidate_failures(failures).should eq({
104
+ expect(rspec_autotest.consolidate_failures(failures)).to eq({
100
105
  spec_file => ["false should be false"]
101
106
  })
102
107
  end
@@ -107,11 +112,11 @@ describe Autotest::Rspec2 do
107
112
  end
108
113
 
109
114
  it "excludes the subject file" do
110
- rspec_autotest.consolidate_failures(failures).keys.should_not include(subject_file)
115
+ expect(rspec_autotest.consolidate_failures(failures).keys).not_to include(subject_file)
111
116
  end
112
117
 
113
118
  it "includes the spec file" do
114
- rspec_autotest.consolidate_failures(failures).keys.should include(spec_file)
119
+ expect(rspec_autotest.consolidate_failures(failures).keys).to include(spec_file)
115
120
  end
116
121
  end
117
122
  end
@@ -122,7 +127,7 @@ describe Autotest::Rspec2 do
122
127
  ['filename.rb', './filename.rb', File.expand_path('filename.rb')].each do |file|
123
128
  @files_to_test[file] = []
124
129
  end
125
- rspec_autotest.normalize(@files_to_test).should have(1).file
130
+ expect(rspec_autotest.normalize(@files_to_test)).to have(1).file
126
131
  end
127
132
  end
128
133
  end
@@ -87,12 +87,12 @@ describe 'command line', :ui do
87
87
  RSpec.configuration.seed = srand && srand # reset seed in same process
88
88
  run_command 'tmp/aruba/spec/order_spec.rb --order rand -f doc'
89
89
 
90
- stdout.string.should match(/Randomized with seed \d+/)
90
+ expect(stdout.string).to match(/Randomized with seed \d+/)
91
91
 
92
- top_level_groups {|first_run, second_run| first_run.should_not eq(second_run)}
93
- nested_groups {|first_run, second_run| first_run.should_not eq(second_run)}
94
- examples('group 1') {|first_run, second_run| first_run.should_not eq(second_run)}
95
- examples('group 1-1') {|first_run, second_run| first_run.should_not eq(second_run)}
92
+ top_level_groups {|first_run, second_run| expect(first_run).to_not eq(second_run)}
93
+ nested_groups {|first_run, second_run| expect(first_run).to_not eq(second_run)}
94
+ examples('group 1') {|first_run, second_run| expect(first_run).to_not eq(second_run)}
95
+ examples('group 1-1') {|first_run, second_run| expect(first_run).to_not eq(second_run)}
96
96
  end
97
97
  end
98
98
 
@@ -100,12 +100,12 @@ describe 'command line', :ui do
100
100
  it 'runs the examples and groups in the same order each time' do
101
101
  2.times { run_command 'tmp/aruba/spec/order_spec.rb --order rand:123 -f doc' }
102
102
 
103
- stdout.string.should match(/Randomized with seed 123/)
103
+ expect(stdout.string).to match(/Randomized with seed 123/)
104
104
 
105
- top_level_groups {|first_run, second_run| first_run.should eq(second_run)}
106
- nested_groups {|first_run, second_run| first_run.should eq(second_run)}
107
- examples('group 1') {|first_run, second_run| first_run.should eq(second_run)}
108
- examples('group 1-1') {|first_run, second_run| first_run.should eq(second_run)}
105
+ top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
106
+ nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
107
+ examples('group 1') {|first_run, second_run| expect(first_run).to eq(second_run)}
108
+ examples('group 1-1') {|first_run, second_run| expect(first_run).to eq(second_run)}
109
109
  end
110
110
  end
111
111
 
@@ -113,20 +113,20 @@ describe 'command line', :ui do
113
113
  it "forces '--order rand' and runs the examples and groups in the same order each time" do
114
114
  2.times { run_command 'tmp/aruba/spec/order_spec.rb --seed 123 -f doc' }
115
115
 
116
- stdout.string.should match(/Randomized with seed \d+/)
116
+ expect(stdout.string).to match(/Randomized with seed \d+/)
117
117
 
118
- top_level_groups {|first_run, second_run| first_run.should eq(second_run)}
119
- nested_groups {|first_run, second_run| first_run.should eq(second_run)}
120
- examples('group 1') {|first_run, second_run| first_run.should eq(second_run)}
121
- examples('group 1-1') {|first_run, second_run| first_run.should eq(second_run)}
118
+ top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
119
+ nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
120
+ examples('group 1') {|first_run, second_run| expect(first_run).to eq(second_run)}
121
+ examples('group 1-1') {|first_run, second_run| expect(first_run).to eq(second_run)}
122
122
  end
123
123
 
124
124
  it "runs examples in the same order, regardless of the order in which files are given" do
125
125
  run_command 'tmp/aruba/spec/simple_spec.rb tmp/aruba/spec/simple_spec2.rb --seed 1337 -f doc'
126
126
  run_command 'tmp/aruba/spec/simple_spec2.rb tmp/aruba/spec/simple_spec.rb --seed 1337 -f doc'
127
127
 
128
- top_level_groups {|first_run, second_run| first_run.should eq(second_run)}
129
- nested_groups {|first_run, second_run| first_run.should eq(second_run)}
128
+ top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
129
+ nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
130
130
  end
131
131
  end
132
132
 
@@ -136,9 +136,9 @@ describe 'command line', :ui do
136
136
 
137
137
  run_command 'tmp/aruba/spec/order_spec.rb --order default -f doc'
138
138
 
139
- stdout.string.should_not match(/Randomized/)
139
+ expect(stdout.string).not_to match(/Randomized/)
140
140
 
141
- stdout.string.should match(
141
+ expect(stdout.string).to match(
142
142
  /group 1.*group 1 example 1.*group 1 example 2.*group 1-1.*group 1-2.*group 2.*/m
143
143
  )
144
144
  end
@@ -169,10 +169,10 @@ describe 'command line', :ui do
169
169
  it 'orders the groups and examples by the provided strategy' do
170
170
  run_command 'tmp/aruba/spec/custom_order_spec.rb -f doc'
171
171
 
172
- top_level_groups { |groups| groups.flatten.should eq(['group A', 'group B']) }
172
+ top_level_groups { |groups| expect(groups.flatten).to eq(['group A', 'group B']) }
173
173
  examples('group B') do |examples|
174
174
  letters = examples.flatten.map { |e| e[/(.)\z/, 1] }
175
- letters.should eq(['A', 'B', 'C', 'D'])
175
+ expect(letters).to eq(['A', 'B', 'C', 'D'])
176
176
  end
177
177
  end
178
178
  end
@@ -27,13 +27,13 @@ module RSpec::Core
27
27
  it "assigns ConfigurationOptions built from Array of options to @options" do
28
28
  config_options = ConfigurationOptions.new(%w[--color])
29
29
  command_line = CommandLine.new(%w[--color])
30
- command_line.instance_eval { @options.options }.should eq(config_options.parse_options)
30
+ expect(command_line.instance_eval { @options.options }).to eq(config_options.parse_options)
31
31
  end
32
32
 
33
33
  it "assigns submitted ConfigurationOptions to @options" do
34
34
  config_options = ConfigurationOptions.new(%w[--color])
35
35
  command_line = CommandLine.new(config_options)
36
- command_line.instance_eval { @options }.should be(config_options)
36
+ expect(command_line.instance_eval { @options }).to be(config_options)
37
37
  end
38
38
 
39
39
  describe "#run" do
@@ -42,17 +42,17 @@ module RSpec::Core
42
42
 
43
43
  it "returns 0 if spec passes" do
44
44
  command_line = build_command_line passing_spec_filename
45
- command_line.run(err, out).should eq 0
45
+ expect(command_line.run(err, out)).to eq 0
46
46
  end
47
47
 
48
48
  it "returns 1 if spec fails" do
49
49
  command_line = build_command_line failing_spec_filename
50
- command_line.run(err, out).should eq 1
50
+ expect(command_line.run(err, out)).to eq 1
51
51
  end
52
52
 
53
53
  it "returns 2 if spec fails and --failure-exit-code is 2" do
54
54
  command_line = build_command_line failing_spec_filename, "--failure-exit-code", "2"
55
- command_line.run(err, out).should eq 2
55
+ expect(command_line.run(err, out)).to eq 2
56
56
  end
57
57
  end
58
58
 
@@ -91,7 +91,7 @@ module RSpec::Core
91
91
  config.output_stream = output_file
92
92
  command_line = build_command_line
93
93
  command_line.run err, out
94
- command_line.instance_eval { @configuration.output_stream }.should eq output_file
94
+ expect(command_line.instance_eval { @configuration.output_stream }).to eq output_file
95
95
  end
96
96
  end
97
97
 
@@ -13,6 +13,13 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
13
13
  end
14
14
  end
15
15
 
16
+ it "duplicates the arguments array" do
17
+ args = ['-e', 'some spec']
18
+ coo = RSpec::Core::ConfigurationOptions.new(args)
19
+ coo.parse_options
20
+ expect(args).to eq(['-e', 'some spec'])
21
+ end
22
+
16
23
  describe "#configure" do
17
24
  it "sends libs before requires" do
18
25
  opts = config_options_object(*%w[--require a/path -I a/lib])
@@ -50,14 +57,14 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
50
57
  opts = config_options_object(*%w[--tag awesome])
51
58
  config = RSpec::Core::Configuration.new
52
59
  opts.configure(config)
53
- config.inclusion_filter.should have_key(:awesome)
60
+ expect(config.inclusion_filter).to have_key(:awesome)
54
61
  end
55
62
 
56
63
  it "merges the :exclusion_filter option with the default exclusion_filter" do
57
64
  opts = config_options_object(*%w[--tag ~slow])
58
65
  config = RSpec::Core::Configuration.new
59
66
  opts.configure(config)
60
- config.exclusion_filter.should have_key(:slow)
67
+ expect(config.exclusion_filter).to have_key(:slow)
61
68
  end
62
69
 
63
70
  it "forces color_enabled" do
@@ -80,8 +87,8 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
80
87
  opts = config_options_object(*[cli_option, cli_value].compact)
81
88
  config = RSpec::Core::Configuration.new
82
89
  config.should_receive(:force) do |pair|
83
- pair.keys.first.should eq(config_key)
84
- pair.values.first.should eq(config_value)
90
+ expect(pair.keys.first).to eq(config_key)
91
+ expect(pair.values.first).to eq(config_value)
85
92
  end
86
93
  opts.configure(config)
87
94
  end
@@ -115,195 +122,203 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
115
122
 
116
123
  describe "-c, --color, and --colour" do
117
124
  it "sets :color => true" do
118
- parse_options('-c').should include(:color => true)
119
- parse_options('--color').should include(:color => true)
120
- parse_options('--colour').should include(:color => true)
125
+ expect(parse_options('-c')).to include(:color => true)
126
+ expect(parse_options('--color')).to include(:color => true)
127
+ expect(parse_options('--colour')).to include(:color => true)
121
128
  end
122
129
  end
123
130
 
124
131
  describe "--no-color" do
125
132
  it "sets :color => false" do
126
- parse_options('--no-color').should include(:color => false)
133
+ expect(parse_options('--no-color')).to include(:color => false)
127
134
  end
128
135
 
129
136
  it "overrides previous :color => true" do
130
- parse_options('--color', '--no-color').should include(:color => false)
137
+ expect(parse_options('--color', '--no-color')).to include(:color => false)
131
138
  end
132
139
 
133
140
  it "gets overriden by a subsequent :color => true" do
134
- parse_options('--no-color', '--color').should include(:color => true)
141
+ expect(parse_options('--no-color', '--color')).to include(:color => true)
135
142
  end
136
143
  end
137
144
 
138
145
  describe "-I" do
139
146
  example "adds to :libs" do
140
- parse_options('-I', 'a_dir').should include(:libs => ['a_dir'])
147
+ expect(parse_options('-I', 'a_dir')).to include(:libs => ['a_dir'])
141
148
  end
142
149
  example "can be used more than once" do
143
- parse_options('-I', 'dir_1', '-I', 'dir_2').should include(:libs => ['dir_1','dir_2'])
150
+ expect(parse_options('-I', 'dir_1', '-I', 'dir_2')).to include(:libs => ['dir_1','dir_2'])
144
151
  end
145
152
  end
146
153
 
147
154
  describe '--require' do
148
155
  example "requires files" do
149
- parse_options('--require', 'a/path').should include(:requires => ['a/path'])
156
+ expect(parse_options('--require', 'a/path')).to include(:requires => ['a/path'])
150
157
  end
151
158
  example "can be used more than once" do
152
- parse_options('--require', 'path/1', '--require', 'path/2').should include(:requires => ['path/1','path/2'])
159
+ expect(parse_options('--require', 'path/1', '--require', 'path/2')).to include(:requires => ['path/1','path/2'])
153
160
  end
154
161
  end
155
162
 
156
163
  describe "--format, -f" do
157
164
  it "sets :formatter" do
158
165
  [['--format', 'd'], ['-f', 'd'], '-fd'].each do |args|
159
- parse_options(*args).should include(:formatters => [['d']])
166
+ expect(parse_options(*args)).to include(:formatters => [['d']])
160
167
  end
161
168
  end
162
169
 
163
170
  example "can accept a class name" do
164
- parse_options('-fSome::Formatter::Class').should include(:formatters => [['Some::Formatter::Class']])
171
+ expect(parse_options('-fSome::Formatter::Class')).to include(:formatters => [['Some::Formatter::Class']])
165
172
  end
166
173
  end
167
174
 
168
175
  describe "--profile, -p" do
169
- it "sets :profile_examples => true" do
170
- parse_options('-p').should include(:profile_examples => true)
171
- parse_options('--profile').should include(:profile_examples => true)
176
+ it "sets :profile_examples" do
177
+ expect(parse_options('-p')).to include(:profile_examples => true)
178
+ expect(parse_options('--profile')).to include(:profile_examples => true)
179
+ expect(parse_options('-p', '4')).to include(:profile_examples => 4)
180
+ expect(parse_options('--profile', '3')).to include(:profile_examples => 3)
181
+ end
182
+ end
183
+
184
+ describe "--no-profile" do
185
+ it "sets :profile_examples to false" do
186
+ expect(parse_options('--no-profile')).to include(:profile_examples => false)
172
187
  end
173
188
  end
174
189
 
175
190
  describe '--line_number' do
176
191
  it "sets :line_number" do
177
- parse_options('-l','3').should include(:line_numbers => ['3'])
178
- parse_options('--line_number','3').should include(:line_numbers => ['3'])
192
+ expect(parse_options('-l','3')).to include(:line_numbers => ['3'])
193
+ expect(parse_options('--line_number','3')).to include(:line_numbers => ['3'])
179
194
  end
180
195
 
181
196
  it "can be specified multiple times" do
182
- parse_options('-l','3', '-l', '6').should include(:line_numbers => ['3', '6'])
183
- parse_options('--line_number','3', '--line_number', '6').should include(:line_numbers => ['3', '6'])
197
+ expect(parse_options('-l','3', '-l', '6')).to include(:line_numbers => ['3', '6'])
198
+ expect(parse_options('--line_number','3', '--line_number', '6')).to include(:line_numbers => ['3', '6'])
184
199
  end
185
200
  end
186
201
 
187
202
  describe "--example" do
188
203
  it "sets :full_description" do
189
- parse_options('--example','foo').should include(:full_description => [/foo/])
190
- parse_options('-e','bar').should include(:full_description => [/bar/])
204
+ expect(parse_options('--example','foo')).to include(:full_description => [/foo/])
205
+ expect(parse_options('-e','bar')).to include(:full_description => [/bar/])
191
206
  end
192
207
  end
193
208
 
194
209
  describe "--backtrace, -b" do
195
210
  it "sets full_backtrace on config" do
196
- parse_options("--backtrace").should include(:full_backtrace => true)
197
- parse_options("-b").should include(:full_backtrace => true)
211
+ expect(parse_options("--backtrace")).to include(:full_backtrace => true)
212
+ expect(parse_options("-b")).to include(:full_backtrace => true)
198
213
  end
199
214
  end
200
215
 
201
216
  describe "--debug, -d" do
202
217
  it "sets :debug => true" do
203
- parse_options("--debug").should include(:debug => true)
204
- parse_options("-d").should include(:debug => true)
218
+ expect(parse_options("--debug")).to include(:debug => true)
219
+ expect(parse_options("-d")).to include(:debug => true)
205
220
  end
206
221
  end
207
222
 
208
223
  describe "--fail-fast" do
209
224
  it "defaults to false" do
210
- parse_options[:fail_fast].should be_false
225
+ expect(parse_options[:fail_fast]).to be_false
211
226
  end
212
227
 
213
228
  it "sets fail_fast on config" do
214
- parse_options("--fail-fast")[:fail_fast].should be_true
229
+ expect(parse_options("--fail-fast")[:fail_fast]).to be_true
215
230
  end
216
231
  end
217
232
 
218
233
  describe "--failure-exit-code" do
219
234
  it "sets :failure_exit_code" do
220
- parse_options('--failure-exit-code', '0').should include(:failure_exit_code => 0)
221
- parse_options('--failure-exit-code', '1').should include(:failure_exit_code => 1)
222
- parse_options('--failure-exit-code', '2').should include(:failure_exit_code => 2)
235
+ expect(parse_options('--failure-exit-code', '0')).to include(:failure_exit_code => 0)
236
+ expect(parse_options('--failure-exit-code', '1')).to include(:failure_exit_code => 1)
237
+ expect(parse_options('--failure-exit-code', '2')).to include(:failure_exit_code => 2)
223
238
  end
224
239
 
225
240
  it "overrides previous :failure_exit_code" do
226
- parse_options('--failure-exit-code', '2', '--failure-exit-code', '3').should include(:failure_exit_code => 3)
241
+ expect(parse_options('--failure-exit-code', '2', '--failure-exit-code', '3')).to include(:failure_exit_code => 3)
227
242
  end
228
243
  end
229
244
 
230
245
  describe "--options" do
231
246
  it "sets :custom_options_file" do
232
- parse_options(*%w[-O my.opts]).should include(:custom_options_file => "my.opts")
233
- parse_options(*%w[--options my.opts]).should include(:custom_options_file => "my.opts")
247
+ expect(parse_options(*%w[-O my.opts])).to include(:custom_options_file => "my.opts")
248
+ expect(parse_options(*%w[--options my.opts])).to include(:custom_options_file => "my.opts")
234
249
  end
235
250
  end
236
251
 
237
252
  describe "--drb, -X" do
238
253
  context "combined with --debug" do
239
254
  it "turns off the debugger if --drb is specified first" do
240
- config_options_object("--drb", "--debug").drb_argv.should_not include("--debug")
241
- config_options_object("--drb", "-d" ).drb_argv.should_not include("--debug")
242
- config_options_object("-X", "--debug").drb_argv.should_not include("--debug")
243
- config_options_object("-X", "-d" ).drb_argv.should_not include("--debug")
255
+ expect(config_options_object("--drb", "--debug").drb_argv).not_to include("--debug")
256
+ expect(config_options_object("--drb", "-d" ).drb_argv).not_to include("--debug")
257
+ expect(config_options_object("-X", "--debug").drb_argv).not_to include("--debug")
258
+ expect(config_options_object("-X", "-d" ).drb_argv).not_to include("--debug")
244
259
  end
245
260
 
246
261
  it "turns off the debugger option if --drb is specified later" do
247
- config_options_object("--debug", "--drb").drb_argv.should_not include("--debug")
248
- config_options_object("-d", "--drb").drb_argv.should_not include("--debug")
249
- config_options_object("--debug", "-X" ).drb_argv.should_not include("--debug")
250
- config_options_object("-d", "-X" ).drb_argv.should_not include("--debug")
262
+ expect(config_options_object("--debug", "--drb").drb_argv).not_to include("--debug")
263
+ expect(config_options_object("-d", "--drb").drb_argv).not_to include("--debug")
264
+ expect(config_options_object("--debug", "-X" ).drb_argv).not_to include("--debug")
265
+ expect(config_options_object("-d", "-X" ).drb_argv).not_to include("--debug")
251
266
  end
252
267
 
253
268
  it "turns off the debugger option if --drb is specified in the options file" do
254
269
  File.open("./.rspec", "w") {|f| f << "--drb"}
255
- config_options_object("--debug").drb_argv.should_not include("--debug")
256
- config_options_object("-d" ).drb_argv.should_not include("--debug")
270
+ expect(config_options_object("--debug").drb_argv).not_to include("--debug")
271
+ expect(config_options_object("-d" ).drb_argv).not_to include("--debug")
257
272
  end
258
273
 
259
274
  it "turns off the debugger option if --debug is specified in the options file" do
260
275
  File.open("./.rspec", "w") {|f| f << "--debug"}
261
- config_options_object("--drb").drb_argv.should_not include("--debug")
262
- config_options_object("-X" ).drb_argv.should_not include("--debug")
276
+ expect(config_options_object("--drb").drb_argv).not_to include("--debug")
277
+ expect(config_options_object("-X" ).drb_argv).not_to include("--debug")
263
278
  end
264
279
  end
265
280
 
266
281
  it "does not send --drb back to the parser after parsing options" do
267
- config_options_object("--drb", "--color").drb_argv.should_not include("--drb")
282
+ expect(config_options_object("--drb", "--color").drb_argv).not_to include("--drb")
268
283
  end
269
284
 
270
285
  end
271
286
 
272
287
  describe "--no-drb" do
273
288
  it "disables drb" do
274
- parse_options("--no-drb").should include(:drb => false)
289
+ expect(parse_options("--no-drb")).to include(:drb => false)
275
290
  end
276
291
 
277
292
  it "overrides a previous drb => true" do
278
- parse_options("--drb", "--no-drb").should include(:drb => false)
293
+ expect(parse_options("--drb", "--no-drb")).to include(:drb => false)
279
294
  end
280
295
 
281
296
  it "gets overriden by a subsquent drb => true" do
282
- parse_options("--no-drb", "--drb").should include(:drb => true)
297
+ expect(parse_options("--no-drb", "--drb")).to include(:drb => true)
283
298
  end
284
299
  end
285
300
 
286
301
 
287
302
  describe "files_or_directories_to_run" do
288
303
  it "parses files from '-c file.rb dir/file.rb'" do
289
- parse_options("-c", "file.rb", "dir/file.rb").should include(
304
+ expect(parse_options("-c", "file.rb", "dir/file.rb")).to include(
290
305
  :files_or_directories_to_run => ["file.rb", "dir/file.rb"]
291
306
  )
292
307
  end
293
308
 
294
309
  it "parses dir from 'dir'" do
295
- parse_options("dir").should include(:files_or_directories_to_run => ["dir"])
310
+ expect(parse_options("dir")).to include(:files_or_directories_to_run => ["dir"])
296
311
  end
297
312
 
298
313
  it "parses dir and files from 'spec/file1_spec.rb, spec/file2_spec.rb'" do
299
- parse_options("dir", "spec/file1_spec.rb", "spec/file2_spec.rb").should include(
314
+ expect(parse_options("dir", "spec/file1_spec.rb", "spec/file2_spec.rb")).to include(
300
315
  :files_or_directories_to_run => ["dir", "spec/file1_spec.rb", "spec/file2_spec.rb"]
301
316
  )
302
317
  end
303
318
 
304
319
  it "provides no files or directories if spec directory does not exist" do
305
320
  FileTest.stub(:directory?).with("spec").and_return false
306
- parse_options().should include(:files_or_directories_to_run => [])
321
+ expect(parse_options()).to include(:files_or_directories_to_run => [])
307
322
  end
308
323
  end
309
324
 
@@ -319,8 +334,7 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
319
334
 
320
335
  describe "#filter_manager" do
321
336
  it "returns the same object as RSpec::configuration.filter_manager" do
322
- config_options_object.filter_manager.
323
- should be(RSpec::configuration.filter_manager)
337
+ expect(config_options_object.filter_manager).to be(RSpec::configuration.filter_manager)
324
338
  end
325
339
  end
326
340
 
@@ -331,37 +345,37 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
331
345
  File.open(File.expand_path("~/.rspec"), "w") {|f| f << "--color"}
332
346
  with_env_vars 'SPEC_OPTS' => "--debug --example 'foo bar'" do
333
347
  options = parse_options("--drb")
334
- options[:color].should be_true
335
- options[:line_numbers].should eq(["37"])
336
- options[:debug].should be_true
337
- options[:full_description].should eq([/foo\ bar/])
338
- options[:drb].should be_true
339
- options[:formatters].should eq([['global']])
348
+ expect(options[:color]).to be_true
349
+ expect(options[:line_numbers]).to eq(["37"])
350
+ expect(options[:debug]).to be_true
351
+ expect(options[:full_description]).to eq([/foo\ bar/])
352
+ expect(options[:drb]).to be_true
353
+ expect(options[:formatters]).to eq([['global']])
340
354
  end
341
355
  end
342
356
 
343
357
  it "prefers SPEC_OPTS over CLI" do
344
358
  with_env_vars 'SPEC_OPTS' => "--format spec_opts" do
345
- parse_options("--format", "cli")[:formatters].should eq([['spec_opts']])
359
+ expect(parse_options("--format", "cli")[:formatters]).to eq([['spec_opts']])
346
360
  end
347
361
  end
348
362
 
349
363
  it "prefers CLI over file options" do
350
364
  File.open("./.rspec", "w") {|f| f << "--format project"}
351
365
  File.open(File.expand_path("~/.rspec"), "w") {|f| f << "--format global"}
352
- parse_options("--format", "cli")[:formatters].should eq([['cli']])
366
+ expect(parse_options("--format", "cli")[:formatters]).to eq([['cli']])
353
367
  end
354
368
 
355
369
  it "prefers project file options over global file options" do
356
370
  File.open("./.rspec", "w") {|f| f << "--format project"}
357
371
  File.open(File.expand_path("~/.rspec"), "w") {|f| f << "--format global"}
358
- parse_options[:formatters].should eq([['project']])
372
+ expect(parse_options[:formatters]).to eq([['project']])
359
373
  end
360
374
 
361
375
  it "prefers local file options over project file options" do
362
376
  File.open("./.rspec-local", "w") {|f| f << "--format local"}
363
377
  File.open("./.rspec", "w") {|f| f << "--format global"}
364
- parse_options[:formatters].should eq([['local']])
378
+ expect(parse_options[:formatters]).to eq([['local']])
365
379
  end
366
380
 
367
381
  context "with custom options file" do
@@ -370,14 +384,14 @@ describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolat
370
384
  File.open(File.expand_path("~/.rspec"), "w") {|f| f << "--format global"}
371
385
  File.open("./custom.opts", "w") {|f| f << "--color"}
372
386
  options = parse_options("-O", "./custom.opts")
373
- options[:format].should be_nil
374
- options[:color].should be_true
387
+ expect(options[:format]).to be_nil
388
+ expect(options[:color]).to be_true
375
389
  end
376
390
 
377
391
  it "parses -e 'full spec description'" do
378
392
  File.open("./custom.opts", "w") {|f| f << "-e 'The quick brown fox jumps over the lazy dog'"}
379
393
  options = parse_options("-O", "./custom.opts")
380
- options[:full_description].should eq([/The\ quick\ brown\ fox\ jumps\ over\ the\ lazy\ dog/])
394
+ expect(options[:full_description]).to eq([/The\ quick\ brown\ fox\ jumps\ over\ the\ lazy\ dog/])
381
395
  end
382
396
  end
383
397
  end