rspec-core 2.6.0 → 2.7.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.
Files changed (113) hide show
  1. data/README.md +1 -1
  2. data/features/Upgrade.md +11 -0
  3. data/features/command_line/exit_status.feature +20 -3
  4. data/features/command_line/format_option.feature +8 -0
  5. data/features/command_line/line_number_appended_to_path.feature +35 -1
  6. data/features/command_line/line_number_option.feature +16 -3
  7. data/features/command_line/pattern_option.feature +31 -0
  8. data/features/command_line/rake_task.feature +1 -1
  9. data/features/command_line/ruby.feature +22 -0
  10. data/features/configuration/default_path.feature +38 -0
  11. data/features/example_groups/{shared_example_group.feature → shared_examples.feature} +49 -26
  12. data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
  13. data/features/filtering/inclusion_filters.feature +4 -5
  14. data/features/formatters/text_formatter.feature +16 -13
  15. data/features/helper_methods/let.feature +4 -4
  16. data/features/hooks/around_hooks.feature +1 -1
  17. data/features/hooks/before_and_after_hooks.feature +3 -3
  18. data/features/hooks/filtering.feature +13 -6
  19. data/features/metadata/user_defined.feature +12 -10
  20. data/features/pending/pending_examples.feature +21 -8
  21. data/features/step_definitions/additional_cli_steps.rb +1 -1
  22. data/features/subject/attribute_of_subject.feature +2 -2
  23. data/features/support/env.rb +1 -2
  24. data/lib/rspec/core/backward_compatibility.rb +1 -1
  25. data/lib/rspec/core/configuration.rb +71 -16
  26. data/lib/rspec/core/configuration_options.rb +46 -16
  27. data/lib/rspec/core/{extensions/object.rb → dsl.rb} +2 -4
  28. data/lib/rspec/core/example.rb +10 -7
  29. data/lib/rspec/core/example_group.rb +34 -18
  30. data/lib/rspec/core/expecting/with_rspec.rb +0 -2
  31. data/lib/rspec/core/extensions.rb +0 -1
  32. data/lib/rspec/core/formatters/base_formatter.rb +8 -4
  33. data/lib/rspec/core/formatters/base_text_formatter.rb +38 -18
  34. data/lib/rspec/core/formatters/html_formatter.rb +3 -1
  35. data/lib/rspec/core/formatters/snippet_extractor.rb +9 -3
  36. data/lib/rspec/core/formatters/text_mate_formatter.rb +20 -6
  37. data/lib/rspec/core/hooks.rb +7 -6
  38. data/lib/rspec/core/let.rb +5 -5
  39. data/lib/rspec/core/metadata.rb +136 -94
  40. data/lib/rspec/core/metadata_hash_builder.rb +1 -1
  41. data/lib/rspec/core/option_parser.rb +11 -7
  42. data/lib/rspec/core/pending.rb +2 -1
  43. data/lib/rspec/core/rake_task.rb +26 -15
  44. data/lib/rspec/core/reporter.rb +5 -6
  45. data/lib/rspec/core/runner.rb +1 -1
  46. data/lib/rspec/core/shared_example_group.rb +4 -4
  47. data/lib/rspec/core/subject.rb +7 -7
  48. data/lib/rspec/core/version.rb +1 -1
  49. data/lib/rspec/core/world.rb +9 -13
  50. data/lib/rspec/core.rb +14 -21
  51. data/spec/autotest/discover_spec.rb +2 -2
  52. data/spec/autotest/failed_results_re_spec.rb +29 -21
  53. data/spec/autotest/rspec_spec.rb +3 -3
  54. data/spec/rspec/core/command_line_spec.rb +1 -6
  55. data/spec/rspec/core/configuration_options_spec.rb +111 -27
  56. data/spec/rspec/core/configuration_spec.rb +161 -37
  57. data/spec/rspec/core/deprecations_spec.rb +2 -2
  58. data/spec/rspec/core/drb_command_line_spec.rb +6 -6
  59. data/spec/rspec/core/example_group_spec.rb +197 -61
  60. data/spec/rspec/core/example_spec.rb +33 -16
  61. data/spec/rspec/core/formatters/base_formatter_spec.rb +3 -3
  62. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +222 -71
  63. data/spec/rspec/core/formatters/helpers_spec.rb +8 -8
  64. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +90 -26
  65. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +12 -11
  66. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +12 -11
  67. data/spec/rspec/core/formatters/{html_formatted-1.9.1.html → html_formatted-1.9.3.html} +12 -11
  68. data/spec/rspec/core/formatters/html_formatter_spec.rb +5 -5
  69. data/spec/rspec/core/formatters/progress_formatter_spec.rb +2 -2
  70. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +2 -2
  71. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +91 -27
  72. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +13 -12
  73. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -28
  74. data/spec/rspec/core/formatters/{text_mate_formatted-1.9.1.html → text_mate_formatted-1.9.3.html} +29 -28
  75. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +2 -2
  76. data/spec/rspec/core/hooks_filtering_spec.rb +18 -18
  77. data/spec/rspec/core/let_spec.rb +19 -6
  78. data/spec/rspec/core/metadata_spec.rb +146 -61
  79. data/spec/rspec/core/pending_example_spec.rb +4 -4
  80. data/spec/rspec/core/rake_task_spec.rb +71 -50
  81. data/spec/rspec/core/reporter_spec.rb +2 -2
  82. data/spec/rspec/core/ruby_project_spec.rb +2 -2
  83. data/spec/rspec/core/runner_spec.rb +4 -1
  84. data/spec/rspec/core/shared_example_group_spec.rb +15 -119
  85. data/spec/rspec/core/subject_spec.rb +13 -13
  86. data/spec/rspec/core/world_spec.rb +31 -22
  87. data/spec/rspec/core_spec.rb +1 -29
  88. data/spec/spec_helper.rb +51 -50
  89. data/spec/support/shared_example_groups.rb +3 -3
  90. data/spec/support/spec_files.rb +8 -8
  91. metadata +79 -94
  92. data/.document +0 -5
  93. data/.gitignore +0 -12
  94. data/.rspec +0 -0
  95. data/.travis.yml +0 -7
  96. data/Gemfile +0 -50
  97. data/Guardfile +0 -5
  98. data/License.txt +0 -23
  99. data/Rakefile +0 -89
  100. data/cucumber.yml +0 -2
  101. data/features/.nav +0 -57
  102. data/features/Changelog.md +0 -269
  103. data/rspec-core.gemspec +0 -24
  104. data/script/FullBuildRakeFile +0 -63
  105. data/script/console +0 -8
  106. data/script/cucumber +0 -1
  107. data/script/full_build +0 -1
  108. data/script/spec +0 -1
  109. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +0 -398
  110. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +0 -398
  111. data/spec.txt +0 -1126
  112. /data/{bin → exe}/autospec +0 -0
  113. /data/{bin → exe}/rspec +0 -0
@@ -17,67 +17,120 @@ module RSpec
17
17
  it "uses :caller if passed as part of the user metadata" do
18
18
  m = Metadata.new
19
19
  m.process('group', :caller => ['example_file:42'])
20
- m[:example_group][:location].should == 'example_file:42'
20
+ m[:example_group][:location].should eq("example_file:42")
21
21
  end
22
22
  end
23
23
 
24
- describe "#apply_condition" do
24
+ describe "#filter_applies?" do
25
25
 
26
26
  let(:parent_group_metadata) { Metadata.new.process('parent group', :caller => ["foo_spec.rb:#{__LINE__}"]) }
27
- let(:parent_group_line_number) { parent_group_metadata[:example_group][:line_number] }
28
27
  let(:group_metadata) { Metadata.new(parent_group_metadata).process('group', :caller => ["foo_spec.rb:#{__LINE__}"]) }
29
- let(:group_line_number) { group_metadata[:example_group][:line_number] }
30
28
  let(:example_metadata) { group_metadata.for_example('example', :caller => ["foo_spec.rb:#{__LINE__}"], :if => true) }
31
- let(:example_line_number) { example_metadata[:line_number] }
32
29
  let(:next_example_metadata) { group_metadata.for_example('next_example', :caller => ["foo_spec.rb:#{example_line_number + 2}"]) }
33
30
  let(:world) { World.new }
34
31
 
35
32
  before { RSpec.stub(:world) { world } }
36
33
 
37
- it "matches the group when the line_number is the example group line number" do
38
- world.should_receive(:preceding_declaration_line).and_return(group_line_number)
39
- # this call doesn't really make sense since apply_condition is only called
40
- # for example metadata not group metadata
41
- group_metadata.apply_condition(:line_number, group_line_number).should be_true
42
- end
34
+ shared_examples_for "matching by line number" do
35
+ let(:preceeding_declaration_lines) {{
36
+ parent_group_metadata[:example_group][:line_number] => parent_group_metadata[:example_group][:line_number],
37
+ group_metadata[:example_group][:line_number] => group_metadata[:example_group][:line_number],
38
+ example_metadata[:line_number] => example_metadata[:line_number],
39
+ (example_metadata[:line_number] + 1) => example_metadata[:line_number],
40
+ (example_metadata[:line_number] + 2) => example_metadata[:line_number] + 2,
41
+ }}
42
+ before do
43
+ world.should_receive(:preceding_declaration_line).at_least(:once).and_return do |v|
44
+ preceeding_declaration_lines[v]
45
+ end
46
+ end
43
47
 
44
- it "matches the example when the line_number is the grandparent example group line number" do
45
- world.should_receive(:preceding_declaration_line).and_return(parent_group_line_number)
46
- example_metadata.apply_condition(:line_number, parent_group_line_number).should be_true
47
- end
48
+ it "matches the group when the line_number is the example group line number" do
49
+ # this call doesn't really make sense since filter_applies? is only called
50
+ # for example metadata not group metadata
51
+ group_metadata.filter_applies?(condition_key, group_condition).should be_true
52
+ end
53
+
54
+ it "matches the example when the line_number is the grandparent example group line number" do
55
+ example_metadata.filter_applies?(condition_key, parent_group_condition).should be_true
56
+ end
57
+
58
+ it "matches the example when the line_number is the parent example group line number" do
59
+ example_metadata.filter_applies?(condition_key, group_condition).should be_true
60
+ end
61
+
62
+ it "matches the example when the line_number is the example line number" do
63
+ example_metadata.filter_applies?(condition_key, example_condition).should be_true
64
+ end
48
65
 
49
- it "matches the example when the line_number is the parent example group line number" do
50
- world.should_receive(:preceding_declaration_line).and_return(group_line_number)
51
- example_metadata.apply_condition(:line_number, group_line_number).should be_true
66
+ it "matches when the line number is between this example and the next" do
67
+ example_metadata.filter_applies?(condition_key, between_examples_condition).should be_true
68
+ end
69
+
70
+ it "does not match when the line number matches the next example" do
71
+ example_metadata.filter_applies?(condition_key, next_example_condition).should be_false
72
+ end
52
73
  end
53
74
 
54
- it "matches the example when the line_number is the example line number" do
55
- world.should_receive(:preceding_declaration_line).and_return(example_line_number)
56
- example_metadata.apply_condition(:line_number, example_line_number).should be_true
75
+ context "with a single line number" do
76
+ let(:condition_key){ :line_numbers }
77
+ let(:parent_group_condition) { [parent_group_metadata[:example_group][:line_number]] }
78
+ let(:group_condition) { [group_metadata[:example_group][:line_number]] }
79
+ let(:example_condition) { [example_metadata[:line_number]] }
80
+ let(:between_examples_condition) { [group_metadata[:example_group][:line_number] + 1] }
81
+ let(:next_example_condition) { [example_metadata[:line_number] + 2] }
82
+
83
+ it_has_behavior "matching by line number"
57
84
  end
58
85
 
59
- it "matches when the line number is between this example and the next" do
60
- world.should_receive(:preceding_declaration_line).and_return(example_line_number)
61
- example_metadata.apply_condition(:line_number, example_line_number + 1).should be_true
86
+ context "with multiple line numbers" do
87
+ let(:condition_key){ :line_numbers }
88
+ let(:parent_group_condition) { [-1, parent_group_metadata[:example_group][:line_number]] }
89
+ let(:group_condition) { [-1, group_metadata[:example_group][:line_number]] }
90
+ let(:example_condition) { [-1, example_metadata[:line_number]] }
91
+ let(:between_examples_condition) { [-1, group_metadata[:example_group][:line_number] + 1] }
92
+ let(:next_example_condition) { [-1, example_metadata[:line_number] + 2] }
93
+
94
+ it_has_behavior "matching by line number"
62
95
  end
63
96
 
64
- it "does not match when the line number matches the next example" do
65
- world.should_receive(:preceding_declaration_line).and_return(example_line_number + 2)
66
- example_metadata.apply_condition(:line_number, example_line_number + 2).should be_false
97
+ context "with locations" do
98
+ let(:condition_key){ :locations }
99
+ let(:parent_group_condition) do
100
+ {File.expand_path(parent_group_metadata[:example_group][:file_path]) => [parent_group_metadata[:example_group][:line_number]]}
101
+ end
102
+ let(:group_condition) do
103
+ {File.expand_path(group_metadata[:example_group][:file_path]) => [group_metadata[:example_group][:line_number]]}
104
+ end
105
+ let(:example_condition) do
106
+ {File.expand_path(example_metadata[:file_path]) => [example_metadata[:line_number]]}
107
+ end
108
+ let(:between_examples_condition) do
109
+ {File.expand_path(group_metadata[:example_group][:file_path]) => [group_metadata[:example_group][:line_number] + 1]}
110
+ end
111
+ let(:next_example_condition) do
112
+ {File.expand_path(example_metadata[:file_path]) => [example_metadata[:line_number] + 2]}
113
+ end
114
+
115
+ it_has_behavior "matching by line number"
116
+
117
+ it "ignores location filters for other files" do
118
+ example_metadata.filter_applies?(:locations, {"/path/to/other_spec.rb" => [3,5,7]}).should be_true
119
+ end
67
120
  end
68
121
 
69
122
  it "matches a proc that evaluates to true" do
70
- example_metadata.apply_condition(:if, lambda { |v| v }).should be_true
123
+ example_metadata.filter_applies?(:if, lambda { |v| v }).should be_true
71
124
  end
72
125
 
73
126
  it "does not match a proc that evaluates to false" do
74
- example_metadata.apply_condition(:if, lambda { |v| !v }).should be_false
127
+ example_metadata.filter_applies?(:if, lambda { |v| !v }).should be_false
75
128
  end
76
129
 
77
130
  it "passes the metadata hash as the second argument if a given proc expects 2 args" do
78
131
  passed_metadata = nil
79
- example_metadata.apply_condition(:if, lambda { |v, m| passed_metadata = m })
80
- passed_metadata.should == example_metadata
132
+ example_metadata.filter_applies?(:if, lambda { |v, m| passed_metadata = m })
133
+ passed_metadata.should eq(example_metadata)
81
134
  end
82
135
  end
83
136
 
@@ -87,43 +140,43 @@ module RSpec
87
140
  let(:line_number) { __LINE__ - 1 }
88
141
 
89
142
  it "stores the description" do
90
- mfe[:description].should == "example description"
143
+ mfe[:description].should eq("example description")
91
144
  end
92
145
 
93
146
  it "stores the full_description (group description + example description)" do
94
- mfe[:full_description].should == "group description example description"
147
+ mfe[:full_description].should eq("group description example description")
95
148
  end
96
149
 
97
150
  it "creates an empty execution result" do
98
- mfe[:execution_result].should == {}
151
+ mfe[:execution_result].should eq({})
99
152
  end
100
153
 
101
154
  it "extracts file path from caller" do
102
- mfe[:file_path].should == __FILE__
155
+ mfe[:file_path].should eq(__FILE__)
103
156
  end
104
157
 
105
158
  it "extracts line number from caller" do
106
- mfe[:line_number].should == line_number
159
+ mfe[:line_number].should eq(line_number)
107
160
  end
108
161
 
109
162
  it "extracts location from caller" do
110
- mfe[:location].should == "#{__FILE__}:#{line_number}"
163
+ mfe[:location].should eq("#{__FILE__}:#{line_number}")
111
164
  end
112
165
 
113
166
  it "uses :caller if passed as an option" do
114
167
  example_metadata = metadata.for_example('example description', {:caller => ['example_file:42']})
115
- example_metadata[:location].should == 'example_file:42'
168
+ example_metadata[:location].should eq("example_file:42")
116
169
  end
117
170
 
118
171
  it "merges arbitrary options" do
119
- mfe[:arbitrary].should == :options
172
+ mfe[:arbitrary].should eq(:options)
120
173
  end
121
174
 
122
175
  it "points :example_group to the same hash object" do
123
176
  a = metadata.for_example("foo", {})[:example_group]
124
177
  b = metadata.for_example("bar", {})[:example_group]
125
178
  a[:description] = "new description"
126
- b[:description].should == "new description"
179
+ b[:description].should eq("new description")
127
180
  end
128
181
  end
129
182
 
@@ -133,7 +186,6 @@ module RSpec
133
186
  m = Metadata.new
134
187
  m.process('group')
135
188
 
136
- m = m.for_example("example", {})
137
189
  m[:example_group][:describes].should be_nil
138
190
  end
139
191
  end
@@ -143,7 +195,6 @@ module RSpec
143
195
  m = Metadata.new
144
196
  m.process(:group)
145
197
 
146
- m = m.for_example("example", {})
147
198
  m[:example_group][:describes].should be_nil
148
199
  end
149
200
  end
@@ -153,49 +204,73 @@ module RSpec
153
204
  m = Metadata.new
154
205
  m.process(String)
155
206
 
156
- m = m.for_example("example", {})
157
207
  m[:example_group][:describes].should be(String)
158
208
  end
159
209
  end
160
210
 
161
- context "with describes from a superclass metadata" do
162
- it "returns the superclass' described class" do
211
+ context "in a nested group" do
212
+ it "returns the parent group's described class" do
163
213
  sm = Metadata.new
164
214
  sm.process(String)
165
215
 
166
216
  m = Metadata.new(sm)
167
217
  m.process(Array)
168
218
 
169
- m = m.for_example("example", {})
170
219
  m[:example_group][:describes].should be(String)
171
220
  end
221
+
222
+ it "returns own described class if parent doesn't have one" do
223
+ sm = Metadata.new
224
+ sm.process("foo")
225
+
226
+ m = Metadata.new(sm)
227
+ m.process(Array)
228
+
229
+ m[:example_group][:describes].should be(Array)
230
+ end
231
+
232
+ it "can override a parent group's described class" do
233
+ parent = Metadata.new
234
+ parent.process(String)
235
+
236
+ child = Metadata.new(parent)
237
+ child.process(Fixnum)
238
+ child[:example_group][:describes] = Hash
239
+
240
+ grandchild = Metadata.new(child)
241
+ grandchild.process(Array)
242
+
243
+ grandchild[:example_group][:describes].should be(Hash)
244
+ child[:example_group][:describes].should be(Hash)
245
+ parent[:example_group][:describes].should be(String)
246
+ end
172
247
  end
173
248
  end
174
249
 
175
250
  describe ":description" do
176
251
  it "just has the example description" do
177
252
  m = Metadata.new
178
- m.process('group')
253
+ m.process("group")
179
254
 
180
255
  m = m.for_example("example", {})
181
- m[:description].should == "example"
256
+ m[:description].should eq("example")
182
257
  end
183
258
 
184
259
  context "with a string" do
185
260
  it "provides the submitted description" do
186
261
  m = Metadata.new
187
- m.process('group')
262
+ m.process("group")
188
263
 
189
- m[:example_group][:description].should == "group"
264
+ m[:example_group][:description].should eq("group")
190
265
  end
191
266
  end
192
267
 
193
268
  context "with a non-string" do
194
269
  it "provides the submitted description" do
195
270
  m = Metadata.new
196
- m.process('group')
271
+ m.process("group")
197
272
 
198
- m[:example_group][:description].should == "group"
273
+ m[:example_group][:description].should eq("group")
199
274
  end
200
275
  end
201
276
 
@@ -204,7 +279,16 @@ module RSpec
204
279
  m = Metadata.new
205
280
  m.process(Object, 'group')
206
281
 
207
- m[:example_group][:description].should == "Object group"
282
+ m[:example_group][:description].should eq("Object group")
283
+ end
284
+ end
285
+
286
+ context "with empty args" do
287
+ it "returns empty string for [:example_group][:description]" do
288
+ m = Metadata.new
289
+ m.process()
290
+
291
+ m[:example_group][:description].should eq("")
208
292
  end
209
293
  end
210
294
  end
@@ -215,17 +299,18 @@ module RSpec
215
299
  group_metadata.process('group')
216
300
 
217
301
  example_metadata = group_metadata.for_example("example", {})
218
- example_metadata[:full_description].should == "group example"
302
+ example_metadata[:full_description].should eq("group example")
219
303
  end
220
304
 
221
305
  it "concats nested example group descriptions" do
222
306
  parent = Metadata.new
223
- parent.process(Object, 'parent')
307
+ parent.process('parent')
224
308
 
225
309
  child = Metadata.new(parent)
226
310
  child.process('child')
227
311
 
228
- child[:example_group][:full_description].should == "Object parent child"
312
+ child[:example_group][:full_description].should eq("parent child")
313
+ child.for_example('example', child)[:full_description].should eq("parent child example")
229
314
  end
230
315
 
231
316
  %w[# . ::].each do |char|
@@ -258,7 +343,7 @@ module RSpec
258
343
  "./lib/rspec/core/foo.rb",
259
344
  "#{__FILE__}:#{__LINE__}"
260
345
  ])
261
- m[:example_group][:file_path].should == __FILE__
346
+ m[:example_group][:file_path].should eq(__FILE__)
262
347
  end
263
348
  end
264
349
 
@@ -266,19 +351,19 @@ module RSpec
266
351
  it "finds the line number with the first non-rspec lib file in the backtrace" do
267
352
  m = Metadata.new
268
353
  m.process({})
269
- m[:example_group][:line_number].should == __LINE__ - 1
354
+ m[:example_group][:line_number].should eq(__LINE__ - 1)
270
355
  end
271
356
 
272
357
  it "finds the line number with the first spec file with drive letter" do
273
358
  m = Metadata.new
274
359
  m.process(:caller => [ "C:/path/to/file_spec.rb:#{__LINE__}" ])
275
- m[:example_group][:line_number].should == __LINE__ - 1
360
+ m[:example_group][:line_number].should eq(__LINE__ - 1)
276
361
  end
277
362
 
278
363
  it "uses the number after the first : for ruby 1.9" do
279
364
  m = Metadata.new
280
365
  m.process(:caller => [ "#{__FILE__}:#{__LINE__}:999" ])
281
- m[:example_group][:line_number].should == __LINE__ - 1
366
+ m[:example_group][:line_number].should eq(__LINE__ - 1)
282
367
  end
283
368
  end
284
369
 
@@ -290,7 +375,7 @@ module RSpec
290
375
  child = Metadata.new(parent)
291
376
  child.process()
292
377
 
293
- child[:example_group][:example_group].should == parent[:example_group]
378
+ child[:example_group][:example_group].should eq(parent[:example_group])
294
379
  end
295
380
  end
296
381
  end
@@ -30,10 +30,10 @@ describe "an example" do
30
30
  it "does not have an auto-generated description" do
31
31
  group = RSpec::Core::ExampleGroup.describe('group') do
32
32
  it "checks something" do
33
- (3+4).should == 7
33
+ (3+4).should eq(7)
34
34
  end
35
35
  pending do
36
- "string".reverse.should == "gnirts"
36
+ "string".reverse.should eq("gnirts")
37
37
  end
38
38
  end
39
39
  example = group.examples.last
@@ -45,7 +45,7 @@ describe "an example" do
45
45
  it "does not show any message" do
46
46
  group = RSpec::Core::ExampleGroup.describe('group') do
47
47
  it "checks something" do
48
- (3+4).should == 7
48
+ (3+4).should eq(7)
49
49
  end
50
50
  specify do
51
51
  pending
@@ -145,7 +145,7 @@ describe "an example" do
145
145
 
146
146
  context "that passes" do
147
147
  def run_example(*pending_args)
148
- super(*pending_args) { 3.should == 3 }
148
+ super(*pending_args) { 3.should eq(3) }
149
149
  end
150
150
 
151
151
  context "when given no options" do
@@ -1,18 +1,29 @@
1
1
  require "spec_helper"
2
2
  require "rspec/core/rake_task"
3
+ require 'tempfile'
3
4
 
4
5
  module RSpec::Core
5
6
  describe RakeTask do
6
7
  let(:task) { RakeTask.new }
7
8
 
8
- before do
9
- File.stub(:exist?) { false }
9
+ def ruby
10
+ FileUtils::RUBY
10
11
  end
11
12
 
12
- def with_bundler
13
- task.skip_bundler = false
14
- File.stub(:exist?) { true }
15
- yield
13
+ def with_bundle_gemfile(val)
14
+ begin
15
+ orig = ENV['BUNDLE_GEMFILE']
16
+ ENV['BUNDLE_GEMFILE'] = val
17
+ yield
18
+ ensure
19
+ ENV['BUNDLE_GEMFILE'] = orig
20
+ end
21
+ end
22
+
23
+ def without_bundler
24
+ with_bundle_gemfile nil do
25
+ yield
26
+ end
16
27
  end
17
28
 
18
29
  def with_rcov
@@ -24,52 +35,41 @@ module RSpec::Core
24
35
  task.__send__(:spec_command)
25
36
  end
26
37
 
27
- context "default" do
38
+ context "default (BUNDLE_GEMFILE nil)" do
28
39
  it "renders rspec" do
29
- spec_command.should =~ /^-S rspec/
30
- end
31
- end
32
-
33
- context "with bundler" do
34
- context "with Gemfile" do
35
- it "renders bundle exec rspec" do
36
- File.stub(:exist?) { true }
37
- task.skip_bundler = false
38
- spec_command.should match(/bundle exec/)
40
+ with_bundle_gemfile nil do
41
+ spec_command.should =~ /^#{ruby} -S rspec/
39
42
  end
40
43
  end
44
+ end
41
45
 
42
- context "with non-standard Gemfile" do
43
- it "renders bundle exec rspec" do
44
- File.stub(:exist?) {|f| f =~ /AltGemfile/}
45
- task.gemfile = 'AltGemfile'
46
- task.skip_bundler = false
47
- spec_command.should match(/bundle exec/)
46
+ context "default (BUNDLE_GEMFILE '')" do
47
+ it "renders rspec" do
48
+ with_bundle_gemfile '' do
49
+ spec_command.should =~ /^#{ruby} -S rspec/
48
50
  end
49
51
  end
52
+ end
50
53
 
51
- context "without Gemfile" do
52
- it "renders bundle exec rspec" do
53
- File.stub(:exist?) { false }
54
- task.skip_bundler = false
55
- spec_command.should_not match(/bundle exec/)
56
- end
54
+ context "with bundler (BUNDLE_GEMFILE non-blank)" do
55
+ it "renders bundle exec rspec" do
56
+ spec_command.should match(/bundle exec/)
57
57
  end
58
58
  end
59
59
 
60
60
  context "with rcov" do
61
61
  it "renders rcov" do
62
- with_rcov do
63
- spec_command.should =~ /^-S rcov/
62
+ without_bundler do
63
+ with_rcov do
64
+ spec_command.should =~ /^#{ruby} -S rcov/
65
+ end
64
66
  end
65
67
  end
66
- end
67
68
 
68
- context "with bundler and rcov" do
69
- it "renders bundle exec rcov" do
70
- with_bundler do
69
+ context "with bundler" do
70
+ it "renders bundle exec rcov" do
71
71
  with_rcov do
72
- spec_command.should =~ /^-S bundle exec rcov/
72
+ spec_command.should =~ /^bundle exec #{ruby} -S rcov/
73
73
  end
74
74
  end
75
75
  end
@@ -77,8 +77,10 @@ module RSpec::Core
77
77
 
78
78
  context "with ruby options" do
79
79
  it "renders them before -S" do
80
- task.ruby_opts = "-w"
81
- spec_command.should =~ /^-w -S rspec/
80
+ without_bundler do
81
+ task.ruby_opts = "-w"
82
+ spec_command.should =~ /^#{ruby} -w -S rspec/
83
+ end
82
84
  end
83
85
  end
84
86
 
@@ -138,23 +140,42 @@ module RSpec::Core
138
140
  end
139
141
 
140
142
  context "with paths with quotes" do
141
- before do
142
- @tmp_dir = File.expand_path('./tmp/rake_task_example/')
143
- FileUtils.mkdir_p @tmp_dir
144
- @task = RakeTask.new do |t|
145
- t.pattern = File.join(@tmp_dir, "*spec.rb")
143
+ it "escapes the quotes" do
144
+ task = RakeTask.new do |t|
145
+ t.pattern = File.join(Dir.tmpdir, "*spec.rb")
146
146
  end
147
147
  ["first_spec.rb", "second_\"spec.rb", "third_\'spec.rb"].each do |file_name|
148
- FileUtils.touch(File.join(@tmp_dir, file_name))
148
+ FileUtils.touch(File.join(Dir.tmpdir, file_name))
149
149
  end
150
+ task.__send__(:files_to_run).sort.should eq([
151
+ File.join(Dir.tmpdir, "first_spec.rb"),
152
+ File.join(Dir.tmpdir, "second_\\\"spec.rb"),
153
+ File.join(Dir.tmpdir, "third_\\\'spec.rb")
154
+ ])
150
155
  end
156
+ end
151
157
 
152
- it "escapes the quotes" do
153
- @task.__send__(:files_to_run).sort.should eq([
154
- File.join(@tmp_dir, "first_spec.rb"),
155
- File.join(@tmp_dir, "second_\\\"spec.rb"),
156
- File.join(@tmp_dir, "third_\\\'spec.rb")
157
- ])
158
+ context "with paths including symlinked directories" do
159
+ it "finds the files" do
160
+ project_dir = File.join(Dir.tmpdir, "project")
161
+ FileUtils.rm_rf project_dir
162
+
163
+ foos_dir = File.join(project_dir, "spec/foos")
164
+ FileUtils.mkdir_p foos_dir
165
+ FileUtils.touch(File.join(foos_dir, "foo_spec.rb"))
166
+
167
+ bars_dir = File.join(Dir.tmpdir, "shared/spec/bars")
168
+ FileUtils.mkdir_p bars_dir
169
+ FileUtils.touch(File.join(bars_dir, "bar_spec.rb"))
170
+
171
+ FileUtils.ln_s bars_dir, File.join(project_dir, "spec/bars")
172
+
173
+ FileUtils.cd(project_dir) do
174
+ RakeTask.new.__send__(:files_to_run).sort.should eq([
175
+ "./spec/bars/bar_spec.rb",
176
+ "./spec/foos/foo_spec.rb"
177
+ ])
178
+ end
158
179
  end
159
180
  end
160
181
  end
@@ -44,14 +44,14 @@ module RSpec::Core
44
44
 
45
45
  group.run(Reporter.new(formatter))
46
46
 
47
- order.should == [
47
+ order.should eq([
48
48
  "Started: root",
49
49
  "Started: context 1",
50
50
  "Finished: context 1",
51
51
  "Started: context 2",
52
52
  "Finished: context 2",
53
53
  "Finished: root"
54
- ]
54
+ ])
55
55
  end
56
56
  end
57
57
 
@@ -7,14 +7,14 @@ module RSpec
7
7
  context "with ancestor containing spec directory" do
8
8
  it "returns ancestor containing the spec directory" do
9
9
  RubyProject.stub(:ascend_until).and_return('foodir')
10
- RubyProject.determine_root.should == 'foodir'
10
+ RubyProject.determine_root.should eq("foodir")
11
11
  end
12
12
  end
13
13
 
14
14
  context "without ancestor containing spec directory" do
15
15
  it "returns current working directory" do
16
16
  RubyProject.stub(:find_first_parent_containing).and_return(nil)
17
- RubyProject.determine_root.should == '.'
17
+ RubyProject.determine_root.should eq(".")
18
18
  end
19
19
  end
20
20
 
@@ -7,6 +7,7 @@ module RSpec::Core
7
7
  RSpec::Core::Runner.stub(:installed_at_exit?).and_return(false)
8
8
  RSpec::Core::Runner.stub(:running_in_drb?).and_return(false)
9
9
  RSpec::Core::Runner.stub(:at_exit_hook_disabled?).and_return(false)
10
+ RSpec::Core::Runner.stub(:run).and_return(-1)
10
11
  RSpec::Core::Runner.should_receive(:at_exit)
11
12
  RSpec::Core::Runner.autorun
12
13
  end
@@ -25,6 +26,7 @@ module RSpec::Core
25
26
  let(:out) { StringIO.new }
26
27
 
27
28
  it "resets world and configuration" do
29
+ RSpec.configuration.stub(:files_to_run) { [] }
28
30
  RSpec.configuration.should_receive(:reset)
29
31
  RSpec.world.should_receive(:reset)
30
32
  RSpec::Core::Runner.run([], err, out)
@@ -58,6 +60,7 @@ module RSpec::Core
58
60
  end
59
61
 
60
62
  it "outputs a message" do
63
+ RSpec.configuration.stub(:files_to_run) { [] }
61
64
  err.should_receive(:puts).with(
62
65
  "No DRb server is running. Running in local process instead ..."
63
66
  )
@@ -65,7 +68,7 @@ module RSpec::Core
65
68
  end
66
69
 
67
70
  it "builds a CommandLine and runs the specs" do
68
- process_proxy = double(RSpec::Core::CommandLine, :run => true)
71
+ process_proxy = double(RSpec::Core::CommandLine, :run => 0)
69
72
  process_proxy.should_receive(:run).with(err, out)
70
73
 
71
74
  RSpec::Core::CommandLine.should_receive(:new).and_return(process_proxy)