rspec-core 2.6.0.rc2 → 2.6.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  ### rspec libs
4
- %w[rspec-core rspec-expectations rspec-mocks].each do |lib|
4
+ %w[rspec rspec-core rspec-expectations rspec-mocks].each do |lib|
5
5
  library_path = File.expand_path("../../#{lib}", __FILE__)
6
6
  if File.exist?(library_path)
7
7
  gem lib, :path => library_path
@@ -10,10 +10,11 @@ source "http://rubygems.org"
10
10
  end
11
11
  end
12
12
 
13
+
13
14
  ### dev dependencies
14
15
  gem "rake", "0.8.7"
15
- # gem "cucumber", "~> 0.10.2"
16
- # gem "aruba", :git => "git://github.com/aslakhellesoy/aruba"
16
+ gem "cucumber", "~> 0.10.2"
17
+ gem "aruba", "~> 0.3.6"
17
18
  gem "rcov", "0.9.9", :platforms => :mri
18
19
  gem "relish", "0.2.0"
19
20
  gem "guard-rspec", "0.1.9"
@@ -1,6 +1,13 @@
1
+ ### 2.6.0.rc4 / 2011-05-01
2
+
3
+ [full changelog](http://github.com/rspec/rspec-core/compare/v2.6.0.rc2...v2.6.0.rc4)
4
+
5
+ * Enhancements
6
+ * Clean up messages for filters/tags.
7
+
1
8
  ### 2.6.0.rc2 / 2011-04-18
2
9
 
3
- [full changelog](http://github.com/rspec/rspec-core/compare/v2.5.1...v2.6.1.rc2)
10
+ [full changelog](http://github.com/rspec/rspec-core/compare/v2.5.1...v2.6.0.rc2)
4
11
 
5
12
  * Enhancements
6
13
  * `shared_context` (Damian Nurzynski)
@@ -1,3 +1,36 @@
1
+ # rspec-core-2.6
2
+
3
+ ## new APIs for sharing content
4
+
5
+ Use `shared_context` together with `include_context` to share before/after
6
+ hooks, let declarations, and method definitions across example groups.
7
+
8
+ Use `shared_examples` together with `include_examples` to share examples
9
+ across different contexts.
10
+
11
+ All of the old APIs are still supported, but these 4 are easy to remember, and
12
+ serve most use cases.
13
+
14
+ See `shared_context` and `shared_examples` under "Example Groups" for more
15
+ information.
16
+
17
+ ## `treat_symbols_as_metadata_keys_with_true_values`
18
+
19
+ Yes it's a long name, but it's a great feature, and it's going to be the
20
+ default behavior in rspec-3. This lets you add metadata to a group or example
21
+ like this:
22
+
23
+ describe "something", :awesome do
24
+ ...
25
+
26
+ And then you can run that group (or example) using the tags feature:
27
+
28
+ rspec spec --tag awesome
29
+
30
+ We're making this an opt-in for rspec-2.6 because `describe "string", :symbol`
31
+ is a perfectly legal construct in pre-2.6 releases and we want to maintain
32
+ compatibility in minor releases as much as is possible.
33
+
1
34
  # rspec-core-2.3
2
35
 
3
36
  ## `config.expect_with`
@@ -106,7 +139,7 @@ The most obvious use is for filtering the run. For example:
106
139
  end
107
140
 
108
141
  When you run the `rspec` command, rspec will run only the examples that have
109
- `:focus => true` in the hash.
142
+ `:focus => true` in the hash.
110
143
 
111
144
  You can also add `run_all_when_everything_filtered` to the config:
112
145
 
@@ -207,7 +240,7 @@ A few things changed in the Rake task used to run specs:
207
240
  the `rspec` command no longer supports the `--options` command line option
208
241
  so the options must be embedded directly in the Rakefile, or stored in the
209
242
  `.rspec` files mentioned above.
210
-
243
+
211
244
  3. In RSpec-1, the rake task would read in rcov options from an `rcov.opts`
212
245
  file. This is ignored by RSpec-2. RCov options are now set directly on the Rake
213
246
  task:
@@ -33,19 +33,19 @@ Feature: --tag option
33
33
 
34
34
  Scenario: filter examples with a simple tag
35
35
  When I run `rspec . --tag focus`
36
- Then the output should contain "Run filtered using {:focus=>true}"
36
+ Then the output should contain "Run filtered including {:focus=>true}"
37
37
  And the examples should all pass
38
38
 
39
39
  Scenario: filter examples with a simple tag and @
40
40
  When I run `rspec . --tag @focus`
41
- Then the output should contain "Run filtered using {:focus=>true}"
41
+ Then the output should contain "Run filtered including {:focus=>true}"
42
42
  Then the examples should all pass
43
43
 
44
44
  Scenario: filter examples with a name:value tag
45
45
  When I run `rspec . --tag type:special`
46
46
  Then the output should contain:
47
47
  """
48
- Run filtered using {:type=>"special"}
48
+ Run filtered including {:type=>"special"}
49
49
  """
50
50
  And the output should contain "2 examples"
51
51
  And the examples should all pass
@@ -54,7 +54,7 @@ Feature: --tag option
54
54
  When I run `rspec . --tag @type:special`
55
55
  Then the output should contain:
56
56
  """
57
- Run filtered using {:type=>"special"}
57
+ Run filtered including {:type=>"special"}
58
58
  """
59
59
  And the examples should all pass
60
60
 
@@ -86,5 +86,5 @@ Feature: --tag option
86
86
 
87
87
  Scenario: filter examples with a simple tag, exclude examples with another tag
88
88
  When I run `rspec . --tag focus --tag ~skip`
89
- Then the output should contain "Run filtered using {:focus=>true}, excluding {:skip=>true}"
89
+ Then the output should contain "Run filtered including {:focus=>true}, excluding {:skip=>true}"
90
90
  And the examples should all pass
@@ -32,7 +32,7 @@ Feature: run all when everything filtered
32
32
  end
33
33
  """
34
34
  When I run `rspec spec/sample_spec.rb --format doc`
35
- Then the output should contain "No examples were matched by {:focus=>true}, running all"
35
+ Then the output should contain "No examples matched {:focus=>true}"
36
36
  And the examples should all pass
37
37
  And the output should contain:
38
38
  """
@@ -26,8 +26,9 @@ module RSpec
26
26
  add_setting :profile_examples
27
27
  add_setting :fail_fast
28
28
  add_setting :run_all_when_everything_filtered
29
- add_setting :filter
30
29
  add_setting :exclusion_filter
30
+ add_setting :inclusion_filter
31
+ add_setting :filter, :alias => :inclusion_filter
31
32
  add_setting :filename_pattern, :default => '**/*_spec.rb'
32
33
  add_setting :files_to_run
33
34
  add_setting :include_or_extend_modules
@@ -36,6 +37,11 @@ module RSpec
36
37
  add_setting :treat_symbols_as_metadata_keys_with_true_values, :default => false
37
38
  add_setting :expecting_with_rspec
38
39
 
40
+ CONDITIONAL_FILTERS = {
41
+ :if => lambda { |value, metadata| metadata.has_key?(:if) && !value },
42
+ :unless => lambda { |value| value }
43
+ }
44
+
39
45
  def initialize
40
46
  @color_enabled = false
41
47
  self.include_or_extend_modules = []
@@ -48,10 +54,7 @@ module RSpec
48
54
  /lib\/rspec\/(core|expectations|matchers|mocks)/
49
55
  ]
50
56
 
51
- self.exclusion_filter = {
52
- :if => lambda { |value, metadata| metadata.has_key?(:if) && !value },
53
- :unless => lambda { |value| value }
54
- }
57
+ self.exclusion_filter = CONDITIONAL_FILTERS.dup
55
58
  end
56
59
 
57
60
  # :call-seq:
@@ -105,7 +108,7 @@ module RSpec
105
108
  end
106
109
 
107
110
  def clear_inclusion_filter # :nodoc:
108
- self.filter = nil
111
+ self.inclusion_filter = nil
109
112
  end
110
113
 
111
114
  def cleaned_from_backtrace?(line)
@@ -335,6 +338,14 @@ EOM
335
338
  RSpec::Core::ExampleGroup.alias_it_should_behave_like_to(new_name, report_label)
336
339
  end
337
340
 
341
+ def exclusion_filter=(filter)
342
+ settings[:exclusion_filter] = filter
343
+ end
344
+
345
+ def inclusion_filter=(filter)
346
+ settings[:inclusion_filter] = filter
347
+ end
348
+
338
349
  def filter_run_including(*args)
339
350
  force_overwrite = if args.last.is_a?(Hash) || args.last.is_a?(Symbol)
340
351
  false
@@ -344,14 +355,14 @@ EOM
344
355
 
345
356
  options = build_metadata_hash_from(args)
346
357
 
347
- if filter and filter[:line_number] || filter[:full_description]
358
+ if inclusion_filter and inclusion_filter[:line_number] || inclusion_filter[:full_description]
348
359
  warn "Filtering by #{options.inspect} is not possible since " \
349
- "you are already filtering by #{filter.inspect}"
360
+ "you are already filtering by #{inclusion_filter.inspect}"
350
361
  else
351
362
  if force_overwrite
352
- self.filter = options
363
+ self.inclusion_filter = options
353
364
  else
354
- self.filter = (filter || {}).merge(options)
365
+ self.inclusion_filter = (inclusion_filter || {}).merge(options)
355
366
  end
356
367
  end
357
368
  end
@@ -2,7 +2,6 @@ module RSpec
2
2
  module Core
3
3
  module ObjectExtensions
4
4
  def describe(*args, &example_group_block)
5
- args << {} unless args.last.is_a?(Hash)
6
5
  RSpec::Core::ExampleGroup.describe(*args, &example_group_block).register
7
6
  end
8
7
  end
@@ -1,7 +1,7 @@
1
1
  module RSpec # :nodoc:
2
2
  module Core # :nodoc:
3
3
  module Version # :nodoc:
4
- STRING = '2.6.0.rc2'
4
+ STRING = '2.6.0.rc4'
5
5
  end
6
6
  end
7
7
  end
@@ -2,6 +2,29 @@ module RSpec
2
2
  module Core
3
3
  class World
4
4
 
5
+ module Describable
6
+ PROC_HEX_NUMBER = /0x[0-9a-f]+@/
7
+ PROJECT_DIR = File.expand_path('.')
8
+
9
+ def description
10
+ reject { |k, v| RSpec::Core::Configuration::CONDITIONAL_FILTERS[k] == v }.inspect.gsub(PROC_HEX_NUMBER, '').gsub(PROJECT_DIR, '.').gsub(' (lambda)','')
11
+ end
12
+
13
+ def empty_without_conditional_filters?
14
+ reject { |k, v| RSpec::Core::Configuration::CONDITIONAL_FILTERS[k] == v }.empty?
15
+ end
16
+
17
+ def reject
18
+ super rescue {}
19
+ end
20
+
21
+ def empty?
22
+ super rescue false
23
+ end
24
+ end
25
+
26
+ include RSpec::Core::Hooks
27
+
5
28
  attr_reader :example_groups, :filtered_examples, :wants_to_quit
6
29
  attr_writer :wants_to_quit
7
30
 
@@ -24,11 +47,11 @@ module RSpec
24
47
  end
25
48
 
26
49
  def inclusion_filter
27
- @configuration.filter
50
+ @configuration.inclusion_filter.extend(Describable)
28
51
  end
29
52
 
30
53
  def exclusion_filter
31
- @configuration.exclusion_filter
54
+ @configuration.exclusion_filter.extend(Describable)
32
55
  end
33
56
 
34
57
  def configure_group(group)
@@ -59,40 +82,53 @@ module RSpec
59
82
  end
60
83
  end
61
84
 
85
+ def reporter
86
+ @configuration.reporter
87
+ end
88
+
62
89
  def announce_filters
63
90
  filter_announcements = []
91
+
92
+ if @configuration.run_all_when_everything_filtered? && example_count.zero?
93
+ reporter.message( "No examples matched #{inclusion_filter.description}. Running all.")
94
+ filtered_examples.clear
95
+ @configuration.clear_inclusion_filter
96
+ end
97
+
64
98
  announce_inclusion_filter filter_announcements
65
99
  announce_exclusion_filter filter_announcements
66
100
 
67
- unless filter_announcements.empty?
68
- @configuration.reporter.message("Run filtered #{filter_announcements.join(', ')}")
101
+ if example_count.zero?
102
+ example_groups.clear
103
+ if filter_announcements.empty?
104
+ reporter.message("No examples found.")
105
+ elsif inclusion_filter
106
+ message = "No examples matched #{inclusion_filter.description}."
107
+ if @configuration.run_all_when_everything_filtered?
108
+ message << " Running all."
109
+ end
110
+ reporter.message(message)
111
+ elsif exclusion_filter
112
+ reporter.message(
113
+ "No examples were matched. Perhaps #{exclusion_filter.description} is excluding everything?")
114
+ end
115
+ else
116
+ reporter.message("Run filtered #{filter_announcements.join(', ')}")
69
117
  end
70
118
  end
71
119
 
72
120
  def announce_inclusion_filter(announcements)
73
121
  if inclusion_filter
74
- if @configuration.run_all_when_everything_filtered? && RSpec.world.example_count.zero?
75
- @configuration.reporter.message "No examples were matched by #{inclusion_filter.inspect}, running all"
76
- @configuration.clear_inclusion_filter
77
- filtered_examples.clear
78
- else
79
- announcements << "using #{inclusion_filter.inspect}"
80
- end
122
+ announcements << "including #{inclusion_filter.description}"
81
123
  end
82
124
  end
83
-
125
+
84
126
  def announce_exclusion_filter(announcements)
85
- if exclusion_filter && RSpec.world.example_count.zero?
86
- @configuration.reporter.message(
87
- "No examples were matched. Perhaps #{exclusion_filter.inspect} is excluding everything?")
88
- example_groups.clear
89
- else
90
- announcements << "excluding #{exclusion_filter.inspect}"
127
+ unless exclusion_filter.empty_without_conditional_filters?
128
+ announcements << "excluding #{exclusion_filter.description}"
91
129
  end
92
130
  end
93
131
 
94
- include RSpec::Core::Hooks
95
-
96
132
  def find_hook(hook, scope, group, example = nil)
97
133
  @configuration.find_hook(hook, scope, group, example)
98
134
  end
@@ -5,8 +5,9 @@ class Foo; end
5
5
 
6
6
  module RSpec::Core
7
7
 
8
- describe World do
9
- let(:world) { RSpec::Core::World.new }
8
+ describe RSpec::Core::World do
9
+ let(:configuration) { RSpec::Core::Configuration.new }
10
+ let(:world) { RSpec::Core::World.new(configuration) }
10
11
 
11
12
  describe "#example_groups" do
12
13
  it "contains all registered example groups" do
@@ -192,6 +193,103 @@ module RSpec::Core
192
193
  end
193
194
  end
194
195
 
195
- end
196
+ describe "#announce_filters" do
197
+ let(:reporter) { double('reporter').as_null_object }
198
+ before { world.stub(:reporter) { reporter } }
199
+
200
+ context "with no examples" do
201
+ before { world.stub(:example_count) { 0 } }
202
+
203
+ context "with no filters" do
204
+ it "announces" do
205
+ reporter.should_receive(:message).
206
+ with("No examples found.")
207
+ world.announce_filters
208
+ end
209
+ end
210
+
211
+ context "with an inclusion filter" do
212
+ it "announces" do
213
+ configuration.inclusion_filter = { :foo => 'bar' }
214
+ reporter.should_receive(:message).
215
+ with("No examples matched #{{ :foo => 'bar' }.inspect}.")
216
+ world.announce_filters
217
+ end
218
+ end
219
+
220
+ context "with an inclusion filter and run_all_when_everything_filtered" do
221
+ it "announces" do
222
+ configuration.stub(:run_all_when_everything_filtered?) { true }
223
+ configuration.inclusion_filter = { :foo => 'bar' }
224
+ reporter.should_receive(:message).
225
+ with("No examples matched #{{ :foo => 'bar' }.inspect}. Running all.")
226
+ world.announce_filters
227
+ end
228
+ end
229
+
230
+ context "with an exclusion filter" do
231
+ it "announces" do
232
+ configuration.exclusion_filter = { :foo => 'bar' }
233
+ reporter.should_receive(:message).
234
+ with("No examples were matched. Perhaps #{{ :foo => 'bar' }.inspect} is excluding everything?")
235
+ world.announce_filters
236
+ end
237
+ end
238
+ end
239
+ end
240
+
241
+ describe "#inclusion_filter" do
242
+ describe "#description" do
243
+ it 'cleans up the description' do
244
+ # check the assumptions of this example
245
+ project_dir = File.expand_path('.')
246
+ lambda { }.inspect.should include(project_dir)
247
+ lambda { }.inspect.should include('0x')
248
+ lambda { }.inspect.should include(' (lambda)') if RUBY_VERSION > '1.9'
249
+
250
+ configuration.filter_run :foo => lambda { }
251
+ world.inclusion_filter.description.should_not include('0x')
252
+ world.inclusion_filter.description.should_not include(project_dir)
253
+ world.inclusion_filter.description.should_not include(' (lambda)')
254
+ end
255
+ end
256
+ end
257
+
258
+ describe "#exclusion_filter" do
259
+ describe "#description" do
260
+ it 'returns `{}` when it only contains the default filters' do
261
+ world.exclusion_filter.description.should == {}.inspect
262
+ end
263
+
264
+ it 'includes other filters' do
265
+ configuration.exclusion_filter[:foo] = :bar
266
+ world.exclusion_filter.description.should == { :foo => :bar }.inspect
267
+ end
268
+
269
+ it 'includes an overriden :if filter' do
270
+ configuration.exclusion_filter[:if] = :custom_filter
271
+ world.exclusion_filter.description.should == { :if => :custom_filter }.inspect
272
+ end
273
+
274
+ it 'includes an overriden :unless filter' do
275
+ configuration.exclusion_filter[:unless] = :custom_filter
276
+ world.exclusion_filter.description.should == { :unless => :custom_filter }.inspect
277
+ end
196
278
 
279
+ it 'cleans up the description' do
280
+ # check the assumptions of this example
281
+ project_dir = File.expand_path('.')
282
+ lambda { }.inspect.should include(project_dir)
283
+ lambda { }.inspect.should include('0x')
284
+ lambda { }.inspect.should include(' (lambda)') if RUBY_VERSION > '1.9'
285
+
286
+ configuration.exclusion_filter[:foo] = lambda { }
287
+ configuration.filter_run_excluding :bar => lambda { }
288
+ world.exclusion_filter.description.should_not include('0x')
289
+ world.exclusion_filter.description.should_not include(project_dir)
290
+ world.exclusion_filter.description.should_not include(' (lambda)')
291
+ end
292
+ end
293
+ end
294
+ end
197
295
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424049
4
+ hash: 15424061
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 2
8
8
  - 6
9
9
  - 0
10
10
  - rc
11
- - 2
12
- version: 2.6.0.rc2
11
+ - 4
12
+ version: 2.6.0.rc4
13
13
  platform: ruby
14
14
  authors:
15
15
  - Chad Humphries
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-04-18 00:00:00 -05:00
21
+ date: 2011-05-01 00:00:00 -04:00
22
22
  default_executable:
23
23
  dependencies: []
24
24
 
@@ -242,10 +242,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
242
  requirements: []
243
243
 
244
244
  rubyforge_project: rspec
245
- rubygems_version: 1.5.2
245
+ rubygems_version: 1.6.2
246
246
  signing_key:
247
247
  specification_version: 3
248
- summary: rspec-core-2.6.0.rc2
248
+ summary: rspec-core-2.6.0.rc4
249
249
  test_files:
250
250
  - features/Autotest.md
251
251
  - features/Changelog.md