rspec-core 2.14.0.rc1 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,17 @@
1
+ ### 2.14.0 / 2013-07-06
2
+ [full changelog](http://github.com/rspec/rspec-core/compare/v2.14.0.rc1...v2.14.0)
3
+
4
+ Enhancements
5
+
6
+ * Apply focus to examples defined with `fit` (equivalent of
7
+ `it "description", focus: true`) (Michael de Silva)
8
+
9
+ Bug fix
10
+
11
+ * Ensure methods defined by `let` take precedence over others
12
+ when there is a name collision (e.g. from an included module).
13
+ (Jon Rowe, Andy Lindeman and Myron Marston)
14
+
1
15
  ### 2.14.0.rc1 / 2013-05-27
2
16
  [full changelog](http://github.com/rspec/rspec-core/compare/v2.13.1...v2.14.0.rc1)
3
17
 
@@ -182,7 +182,7 @@ Feature: around hooks
182
182
  def included_in_configure_block; true; end
183
183
  end
184
184
 
185
- Rspec.configure do |c|
185
+ RSpec.configure do |c|
186
186
  c.include IncludedInConfigureBlock
187
187
  end
188
188
 
@@ -8,7 +8,12 @@ module RSpec
8
8
  # Temporarily support old and new APIs while we transition the other
9
9
  # rspec libs to use a hash for the 2nd arg and no version arg
10
10
  data = Hash === replacement_or_hash ? replacement_or_hash : { :replacement => replacement_or_hash }
11
- RSpec.configuration.reporter.deprecation data.merge(:deprecated => deprecated, :call_site => caller(0)[2])
11
+ RSpec.configuration.reporter.deprecation(
12
+ {
13
+ :deprecated => deprecated,
14
+ :call_site => caller(0)[2]
15
+ }.merge(data)
16
+ )
12
17
  end
13
18
 
14
19
  # @private
@@ -85,6 +85,9 @@ module RSpec
85
85
  define_example_method :focus, :focused => true, :focus => true
86
86
  # Shortcut to define an example with `:focus` => true
87
87
  define_example_method :focused, :focused => true, :focus => true
88
+ # Shortcut to define an example with `:focus` => true
89
+ # @see example
90
+ define_example_method :fit, :focused => true, :focus => true
88
91
 
89
92
  # Shortcut to define an example with :pending => true
90
93
  define_example_method :pending, :pending => true
@@ -240,6 +243,13 @@ module RSpec
240
243
  subclass = Class.new(parent)
241
244
  subclass.set_it_up(*args)
242
245
  subclass.module_eval(&example_group_block) if example_group_block
246
+
247
+ # The LetDefinitions module must be included _after_ other modules
248
+ # to ensure that it takes precendence when there are name collisions.
249
+ # Thus, we delay including it until after the example group block
250
+ # has been eval'd.
251
+ MemoizedHelpers.define_helpers_on(subclass)
252
+
243
253
  subclass
244
254
  end
245
255
 
@@ -45,8 +45,12 @@ module RSpec
45
45
  #
46
46
  # @see #should
47
47
  def subject
48
- raise NotImplementedError, 'This definition is here for documentation purposes only'
49
- ' - it is overriden anyway below when this module gets included.'
48
+ __memoized.fetch(:subject) do
49
+ __memoized[:subject] = begin
50
+ described = described_class || self.class.description
51
+ Class === described ? described.new : described
52
+ end
53
+ end
50
54
  end
51
55
 
52
56
  # When `should` is called with no explicit receiver, the call is
@@ -148,12 +152,6 @@ EOS
148
152
 
149
153
  def self.included(mod)
150
154
  mod.extend(ClassMethods)
151
-
152
- # This logic defines an implicit subject
153
- mod.subject do
154
- described = described_class || self.class.description
155
- Class === described ? described.new : described
156
- end
157
155
  end
158
156
 
159
157
  module ClassMethods
@@ -471,12 +469,16 @@ EOS
471
469
  }
472
470
  end
473
471
 
474
- example_group.__send__(:include, mod)
475
472
  example_group.const_set(:LetDefinitions, mod)
476
473
  mod
477
474
  end
478
475
  end
479
476
 
477
+ # @api private
478
+ def self.define_helpers_on(example_group)
479
+ example_group.send(:include, module_for(example_group))
480
+ end
481
+
480
482
  if Module.method(:const_defined?).arity == 1 # for 1.8
481
483
  # @api private
482
484
  #
@@ -2,7 +2,7 @@ module RSpec::Core
2
2
  class Reporter
3
3
  NOTIFICATIONS = %W[start message example_group_started example_group_finished example_started
4
4
  example_passed example_failed example_pending start_dump dump_pending
5
- dump_failures dump_summary seed close stop deprecation deprecation_summary].map(&:to_sym)
5
+ dump_failures dump_summary seed close stop deprecation deprecation_summary].map { |n| n.to_sym }
6
6
 
7
7
  def initialize(*formatters)
8
8
  @listeners = Hash.new { |h,k| h[k] = [] }
@@ -17,31 +17,37 @@ module RSpec
17
17
  # # ...
18
18
  # end
19
19
  module SharedContext
20
- include Hooks
21
- include MemoizedHelpers::ClassMethods
22
-
20
+ # @api private
23
21
  def included(group)
24
- [:before, :after].each do |type|
25
- [:all, :each].each do |scope|
26
- group.hooks[type][scope].concat hooks[type][scope]
27
- end
28
- end
29
- _nested_group_declarations.each do |name, block, *args|
30
- group.describe name, *args, &block
22
+ __shared_context_recordings.each do |recording|
23
+ recording.playback_onto(group)
31
24
  end
32
25
  end
33
26
 
34
- def describe(name, *args, &block)
35
- _nested_group_declarations << [name, block, *args]
27
+ # @api private
28
+ def __shared_context_recordings
29
+ @__shared_context_recordings ||= []
36
30
  end
37
31
 
38
- alias_method :context, :describe
39
-
40
- private
32
+ Recording = Struct.new(:method_name, :args, :block) do
33
+ def playback_onto(group)
34
+ group.__send__(method_name, *args, &block)
35
+ end
36
+ end
41
37
 
42
- def _nested_group_declarations
43
- @_nested_group_declarations ||= []
38
+ # @api private
39
+ def self.record(methods)
40
+ methods.each do |meth|
41
+ class_eval <<-EOS, __FILE__, __LINE__ + 1
42
+ def #{meth}(*args, &block)
43
+ __shared_context_recordings << Recording.new(:#{meth}, args, block)
44
+ end
45
+ EOS
46
+ end
44
47
  end
48
+
49
+ record [:describe, :context] + Hooks.instance_methods(false) +
50
+ MemoizedHelpers::ClassMethods.instance_methods(false)
45
51
  end
46
52
  end
47
53
 
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Core
3
3
  module Version
4
- STRING = '2.14.0.rc1'
4
+ STRING = '2.14.0'
5
5
  end
6
6
  end
7
7
  end
@@ -1106,11 +1106,6 @@ module RSpec::Core
1106
1106
  debugger.should_receive(:start)
1107
1107
  config.debug = true
1108
1108
  end
1109
-
1110
- it 'sets the reader to true' do
1111
- config.debug = true
1112
- expect(config.debug?).to eq true
1113
- end
1114
1109
  end
1115
1110
 
1116
1111
  describe "#debug=false" do
@@ -1118,10 +1113,17 @@ module RSpec::Core
1118
1113
  config.should_not_receive(:require).with('ruby-debug')
1119
1114
  config.debug = false
1120
1115
  end
1116
+ end
1121
1117
 
1122
- it 'sets the reader to false' do
1123
- config.debug = false
1124
- expect(config.debug?).to eq false
1118
+ describe "#debug?" do
1119
+ it 'returns true if the debugger has been loaded' do
1120
+ stub_const("Debugger", Object.new)
1121
+ expect(config.debug?).to be_true
1122
+ end
1123
+
1124
+ it 'returns false if the debugger has not been loaded' do
1125
+ hide_const("Debugger")
1126
+ expect(config.debug?).to be_false
1125
1127
  end
1126
1128
  end
1127
1129
 
@@ -17,6 +17,11 @@ describe RSpec::Core::Deprecation do
17
17
  expect(RSpec.configuration.reporter).to receive(:deprecation).with(hash_including :call_site => caller(0)[1])
18
18
  RSpec.deprecate("deprecated_method")
19
19
  end
20
+
21
+ it "doesn't override the existing callsite" do
22
+ expect(RSpec.configuration.reporter).to receive(:deprecation).with(hash_including :call_site => "/path")
23
+ RSpec.deprecate("deprecated_method", :call_site => "/path")
24
+ end
20
25
  end
21
26
 
22
27
  context "new API with a hash after the first arg" do
@@ -397,7 +397,7 @@ module RSpec::Core
397
397
  end
398
398
  end
399
399
 
400
- [:focus, :focused].each do |example_alias|
400
+ [:focus, :focused, :fit].each do |example_alias|
401
401
  describe "##{example_alias}" do
402
402
  let(:focused_example) { ExampleGroup.describe.send example_alias, "a focused example" }
403
403
 
@@ -616,6 +616,24 @@ module RSpec::Core
616
616
  })
617
617
  end
618
618
  end
619
+
620
+ context "when included modules have hooks that define memoized helpers" do
621
+ it "allows memoized helpers to override methods in previously included modules" do
622
+ group = ExampleGroup.describe do
623
+ include Module.new {
624
+ def self.included(m); m.let(:unrelated) { :unrelated }; end
625
+ }
626
+
627
+ include Module.new {
628
+ def hello_message; "Hello from module"; end
629
+ }
630
+
631
+ let(:hello_message) { "Hello from let" }
632
+ end
633
+
634
+ expect(group.new.hello_message).to eq("Hello from let")
635
+ end
636
+ end
619
637
  end
620
638
 
621
639
  describe "#let!" do
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-core
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 7
5
- version: 2.14.0.rc1
4
+ prerelease:
5
+ version: 2.14.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Steven Baker
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2013-05-27 00:00:00.000000000 Z
14
+ date: 2013-07-06 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  version_requirements: !ruby/object:Gem::Requirement
@@ -382,20 +382,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
382
382
  version: '0'
383
383
  segments:
384
384
  - 0
385
- hash: 56049946215868305
385
+ hash: -1933471996242347119
386
386
  none: false
387
387
  required_rubygems_version: !ruby/object:Gem::Requirement
388
388
  requirements:
389
- - - ! '>'
389
+ - - ! '>='
390
390
  - !ruby/object:Gem::Version
391
- version: 1.3.1
391
+ version: '0'
392
+ segments:
393
+ - 0
394
+ hash: -1933471996242347119
392
395
  none: false
393
396
  requirements: []
394
397
  rubyforge_project: rspec
395
398
  rubygems_version: 1.8.24
396
399
  signing_key:
397
400
  specification_version: 3
398
- summary: rspec-core-2.14.0.rc1
401
+ summary: rspec-core-2.14.0
399
402
  test_files:
400
403
  - features/Autotest.md
401
404
  - features/README.md