rspec-support 3.3.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a74da896e672529b21b1753eb56081e6f5f8f5d7
4
- data.tar.gz: 9b5f92e7bf487974d55cf1e086a113479542554d
3
+ metadata.gz: 59977f88a4871761b348df8e276629645ef92d91
4
+ data.tar.gz: e274c7de73d8807baffe176641fa6c6d4fa19f10
5
5
  SHA512:
6
- metadata.gz: 2ea71400d27d790bc32e8a208e4d371f11a4c32a1941a77013f87ae94bc309368746b2fd893397b284ffa95aeb75fc099c06a027611a2b79ce73705864cdaf2e
7
- data.tar.gz: 8902798fc1ebc40eb8c0b6d407307520434c4bf0ac1f322890d5b2d53214b45bb154fc6d1e9dc296d3ee3c6541a562d17529e8515f6c845ac3a1dc518c272dab
6
+ metadata.gz: bca64f883edddd2aa11aafb66eef09f26ccc291d33f9a72b2a263e38bde47ed3957b70107677903981087a1407675e0d50156cb68df3650f5b37e3eefd07f313
7
+ data.tar.gz: 6d53d754611ab738d697c25c0249c4b90069c951ef2fb717f6578401109eed57b22af5c7071da60c2500ad8293e7035a4ee7e4ad6d540a8d794882c15cf269dc
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,19 @@
1
+ ### 3.4.0 / 2015-11-11
2
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.3.0...v3.4.0)
3
+
4
+ Enhancements:
5
+
6
+ * Improve formatting of `Delegator` based objects (e.g. `SimpleDelgator`) in
7
+ failure messages and diffs. (Andrew Horner, #215)
8
+ * Add `ComparableVersion`. (Yuji Nakayama, #245)
9
+ * Add `Ripper` support detection. (Yuji Nakayama, #245)
10
+
11
+ Bug Fixes:
12
+
13
+ * Work around bug in JRuby that reports that `attr_writer` methods
14
+ have no parameters, causing RSpec's verifying doubles to wrongly
15
+ fail when mocking or stubbing a writer method on JRuby. (Myron Marston, #225)
16
+
1
17
  ### 3.3.0 / 2015-06-12
2
18
  [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.2.2...v3.3.0)
3
19
 
@@ -1,6 +1,7 @@
1
- Copyright (c) 2013 David Chelimsky, Myron Marston, Jon Rowe, Sam Phippen, Xavier Shay, Bradley Schaefer
1
+ The MIT License (MIT)
2
+ ====================
2
3
 
3
- MIT License
4
+ * Copyright © 2013 David Chelimsky, Myron Marston, Jon Rowe, Sam Phippen, Xavier Shay, Bradley Schaefer
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining
6
7
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -19,8 +19,22 @@ end
19
19
 
20
20
  ## Contributing
21
21
 
22
- 1. Fork it
23
- 2. Create your feature branch (`git checkout -b my-new-feature`)
24
- 3. Commit your changes (`git commit -am 'Add some feature'`)
25
- 4. Push to the branch (`git push origin my-new-feature`)
26
- 5. Create new Pull Request
22
+ Once you've set up the environment, you'll need to cd into the working
23
+ directory of whichever repo you want to work in. From there you can run the
24
+ specs and cucumber features, and make patches.
25
+
26
+ NOTE: You do not need to use rspec-dev to work on a specific RSpec repo. You
27
+ can treat each RSpec repo as an independent project.
28
+
29
+ - [Build details](BUILD_DETAIL.md)
30
+ - [Code of Conduct](CODE_OF_CONDUCT.md)
31
+ - [Detailed contributing guide](CONTRIBUTING.md)
32
+ - [Development setup guide](DEVELOPMENT.md)
33
+
34
+ ## Patches
35
+
36
+ Please submit a pull request or a github issue to one of the issue trackers
37
+ listed below. If you submit an issue, please include a link to either of:
38
+
39
+ * a gist (or equivalent) of the patch
40
+ * a branch or commit in your github fork of the repo
@@ -51,7 +51,7 @@ module RSpec
51
51
  handle = object.method(method_name)
52
52
  raise original unless handle.is_a? Method
53
53
  handle
54
- rescue Exception
54
+ rescue Support::AllExceptionsExceptOnesWeMustNotRescue
55
55
  raise original
56
56
  end
57
57
  end
@@ -67,7 +67,7 @@ module RSpec
67
67
  handle = object.method(method_name)
68
68
  raise original unless handle.is_a? Method
69
69
  handle
70
- rescue Exception
70
+ rescue Support::AllExceptionsExceptOnesWeMustNotRescue
71
71
  raise original
72
72
  end
73
73
  end
@@ -78,6 +78,7 @@ module RSpec
78
78
  Thread.current[:__rspec] ||= {}
79
79
  end
80
80
 
81
+ # @api private
81
82
  def self.failure_notifier=(callable)
82
83
  thread_local_data[:failure_notifier] = callable
83
84
  end
@@ -85,14 +86,17 @@ module RSpec
85
86
  # @private
86
87
  DEFAULT_FAILURE_NOTIFIER = lambda { |failure, _opts| raise failure }
87
88
 
89
+ # @api private
88
90
  def self.failure_notifier
89
91
  thread_local_data[:failure_notifier] || DEFAULT_FAILURE_NOTIFIER
90
92
  end
91
93
 
94
+ # @api private
92
95
  def self.notify_failure(failure, options={})
93
96
  failure_notifier.call(failure, options)
94
97
  end
95
98
 
99
+ # @api private
96
100
  def self.with_failure_notifier(callable)
97
101
  orig_notifier = failure_notifier
98
102
  self.failure_notifier = callable
@@ -101,6 +105,30 @@ module RSpec
101
105
  self.failure_notifier = orig_notifier
102
106
  end
103
107
 
108
+ class << self
109
+ # @api private
110
+ attr_writer :warning_notifier
111
+ end
112
+
113
+ # @private
114
+ DEFAULT_WARNING_NOTIFIER = lambda { |warning| ::Kernel.warn warning }
115
+
116
+ # @api private
117
+ def self.warning_notifier
118
+ @warning_notifier ||= DEFAULT_WARNING_NOTIFIER
119
+ end
120
+
121
+ # @private
122
+ module AllExceptionsExceptOnesWeMustNotRescue
123
+ # These exceptions are dangerous to rescue as rescuing them
124
+ # would interfere with things we should not interfere with.
125
+ AVOID_RESCUING = [NoMemoryError, SignalException, Interrupt, SystemExit]
126
+
127
+ def self.===(exception)
128
+ AVOID_RESCUING.none? { |ar| ar === exception }
129
+ end
130
+ end
131
+
104
132
  # The Differ is only needed when a a spec fails with a diffable failure.
105
133
  # In the more common case of all specs passing or the only failures being
106
134
  # non-diffable, we can avoid the extra cost of loading the differ, diff-lcs,
@@ -0,0 +1,46 @@
1
+ module RSpec
2
+ module Support
3
+ # @private
4
+ class ComparableVersion
5
+ include Comparable
6
+
7
+ attr_reader :string
8
+
9
+ def initialize(string)
10
+ @string = string
11
+ end
12
+
13
+ def <=>(other)
14
+ other = self.class.new(other) unless other.is_a?(self.class)
15
+
16
+ return 0 if string == other.string
17
+
18
+ longer_segment_count = [self, other].map { |version| version.segments.count }.max
19
+
20
+ longer_segment_count.times do |index|
21
+ self_segment = segments[index] || 0
22
+ other_segment = other.segments[index] || 0
23
+
24
+ if self_segment.class == other_segment.class
25
+ result = self_segment <=> other_segment
26
+ return result unless result == 0
27
+ else
28
+ return self_segment.is_a?(String) ? -1 : 1
29
+ end
30
+ end
31
+
32
+ 0
33
+ end
34
+
35
+ def segments
36
+ @segments ||= string.scan(/[a-z]+|\d+/i).map do |segment|
37
+ if segment =~ /\A\d+\z/
38
+ segment.to_i
39
+ else
40
+ segment
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -136,6 +136,23 @@ module RSpec
136
136
  INFINITY = 1 / 0.0
137
137
  end
138
138
 
139
+ # Some versions of JRuby have a nasty bug we have to work around :(.
140
+ # https://github.com/jruby/jruby/issues/2816
141
+ if RSpec::Support::Ruby.jruby? &&
142
+ RubyFeatures.optional_and_splat_args_supported? &&
143
+ Class.new { attr_writer :foo }.instance_method(:foo=).parameters == []
144
+
145
+ class MethodSignature < remove_const(:MethodSignature)
146
+ private
147
+
148
+ def classify_parameters
149
+ super
150
+ return unless @method.parameters == [] && @method.arity == 1
151
+ @max_non_kw_args = @min_non_kw_args = 1
152
+ end
153
+ end
154
+ end
155
+
139
156
  # Deals with the slightly different semantics of block arguments.
140
157
  # For methods, arguments are required unless a default value is provided.
141
158
  # For blocks, arguments are optional, even if no default value is provided.
@@ -0,0 +1,73 @@
1
+ module RSpec
2
+ module Support
3
+ # On 1.8.7, it's in the stdlib.
4
+ # We don't want to load the stdlib, b/c this is a test tool, and can affect
5
+ # the test environment, causing tests to pass where they should fail.
6
+ #
7
+ # So we're transcribing/modifying it from
8
+ # https://github.com/ruby/ruby/blob/v1_8_7_374/lib/thread.rb#L56
9
+ # Some methods we don't need are deleted. Anything I don't
10
+ # understand (there's quite a bit, actually) is left in.
11
+ #
12
+ # Some formating changes are made to appease the robot overlord:
13
+ # https://travis-ci.org/rspec/rspec-core/jobs/54410874
14
+ # @private
15
+ class Mutex
16
+ def initialize
17
+ @waiting = []
18
+ @locked = false
19
+ @waiting.taint
20
+ taint
21
+ end
22
+
23
+ # @private
24
+ def lock
25
+ while Thread.critical = true && @locked
26
+ @waiting.push Thread.current
27
+ Thread.stop
28
+ end
29
+ @locked = true
30
+ Thread.critical = false
31
+ self
32
+ end
33
+
34
+ # @private
35
+ def unlock
36
+ return unless @locked
37
+ Thread.critical = true
38
+ @locked = false
39
+ wakeup_and_run_waiting_thread
40
+ self
41
+ end
42
+
43
+ # @private
44
+ def synchronize
45
+ lock
46
+ begin
47
+ yield
48
+ ensure
49
+ unlock
50
+ end
51
+ end
52
+
53
+ private
54
+
55
+ def wakeup_and_run_waiting_thread
56
+ begin
57
+ t = @waiting.shift
58
+ t.wakeup if t
59
+ rescue ThreadError
60
+ retry
61
+ end
62
+ Thread.critical = false
63
+ begin
64
+ t.run if t
65
+ rescue ThreadError
66
+ :noop
67
+ end
68
+ end
69
+
70
+ # Avoid warnings for library wide checks spec
71
+ end unless defined?(::RSpec::Support::Mutex) || defined?(::Mutex)
72
+ end
73
+ end
@@ -36,7 +36,7 @@ module RSpec
36
36
  elsif RSpec::Support.is_a_matcher?(object) && object.respond_to?(:description)
37
37
  inspection = object.description
38
38
  else
39
- return object
39
+ return DelegatingInspector.new(object)
40
40
  end
41
41
  end
42
42
 
@@ -88,6 +88,21 @@ module RSpec
88
88
  pp.text inspection
89
89
  end
90
90
  end
91
+
92
+ # @private
93
+ DelegatingInspector = Struct.new(:object) do
94
+ def inspect
95
+ if defined?(::Delegator) && ::Delegator === object
96
+ "#<#{object.class}(#{ObjectFormatter.format(object.__getobj__)})>"
97
+ else
98
+ object.inspect
99
+ end
100
+ end
101
+
102
+ def pretty_print(pp)
103
+ pp.text inspect
104
+ end
105
+ end
91
106
  end
92
107
  end
93
108
  end
@@ -0,0 +1,53 @@
1
+ module RSpec
2
+ module Support
3
+ # Allows a thread to lock out other threads from a critical section of code,
4
+ # while allowing the thread with the lock to reenter that section.
5
+ #
6
+ # Based on Monitor as of 2.2 -
7
+ # https://github.com/ruby/ruby/blob/eb7ddaa3a47bf48045d26c72eb0f263a53524ebc/lib/monitor.rb#L9
8
+ #
9
+ # Depends on Mutex, but Mutex is only available as part of core since 1.9.1:
10
+ # exists - http://ruby-doc.org/core-1.9.1/Mutex.html
11
+ # dne - http://ruby-doc.org/core-1.9.0/Mutex.html
12
+ #
13
+ # @private
14
+ class ReentrantMutex
15
+ def initialize
16
+ @owner = nil
17
+ @count = 0
18
+ @mutex = Mutex.new
19
+ end
20
+
21
+ def synchronize
22
+ enter
23
+ yield
24
+ ensure
25
+ exit
26
+ end
27
+
28
+ private
29
+
30
+ def enter
31
+ @mutex.lock if @owner != Thread.current
32
+ @owner = Thread.current
33
+ @count += 1
34
+ end
35
+
36
+ def exit
37
+ @count -= 1
38
+ return unless @count == 0
39
+ @owner = nil
40
+ @mutex.unlock
41
+ end
42
+ end
43
+
44
+ if defined? ::Mutex
45
+ # On 1.9 and up, this is in core, so we just use the real one
46
+ Mutex = ::Mutex
47
+ else # For 1.8.7
48
+ # :nocov:
49
+ RSpec::Support.require_rspec_support "mutex"
50
+ # :nocov:
51
+ end
52
+ end
53
+ end
@@ -1,4 +1,5 @@
1
1
  require 'rbconfig'
2
+ RSpec::Support.require_rspec_support "comparable_version"
2
3
 
3
4
  module RSpec
4
5
  module Support
@@ -9,7 +10,7 @@ module RSpec
9
10
  module_function
10
11
 
11
12
  def windows?
12
- RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/
13
+ !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
13
14
  end
14
15
 
15
16
  def windows_file_path?
@@ -55,6 +56,34 @@ module RSpec
55
56
  respond_to?(:caller_locations, true)
56
57
  end
57
58
 
59
+ if Exception.method_defined?(:cause)
60
+ def supports_exception_cause?
61
+ true
62
+ end
63
+ else
64
+ def supports_exception_cause?
65
+ false
66
+ end
67
+ end
68
+
69
+ ripper_requirements = [ComparableVersion.new(RUBY_VERSION) >= '1.9.2']
70
+
71
+ if Ruby.jruby?
72
+ ripper_requirements.push(ComparableVersion.new(JRUBY_VERSION) >= '1.7.5')
73
+ # Ripper on JRuby 9.0.0.0.rc1 or later reports wrong line number.
74
+ ripper_requirements.push(ComparableVersion.new(JRUBY_VERSION) < '9.0.0.0.rc1')
75
+ end
76
+
77
+ if ripper_requirements.all?
78
+ def ripper_supported?
79
+ true
80
+ end
81
+ else
82
+ def ripper_supported?
83
+ false
84
+ end
85
+ end
86
+
58
87
  if Ruby.mri?
59
88
  def kw_args_supported?
60
89
  RUBY_VERSION >= '2.0.0'
@@ -16,7 +16,7 @@ module RSpec
16
16
  begin
17
17
  yield
18
18
  warning_preventer.verify_no_warnings! if prevent_warnings
19
- rescue Exception => e
19
+ rescue Support::AllExceptionsExceptOnesWeMustNotRescue => e
20
20
  exception = e
21
21
  end
22
22
 
@@ -1,5 +1,34 @@
1
1
  require 'rspec/support/spec/shell_out'
2
2
 
3
+ module RSpec
4
+ module Support
5
+ module WhitespaceChecks
6
+ # This malformed whitespace detection logic has been borrowed from bundler:
7
+ # https://github.com/bundler/bundler/blob/v1.8.0/spec/quality_spec.rb
8
+ def check_for_tab_characters(filename)
9
+ failing_lines = []
10
+ File.readlines(filename).each_with_index do |line, number|
11
+ failing_lines << number + 1 if line =~ /\t/
12
+ end
13
+
14
+ return if failing_lines.empty?
15
+ "#{filename} has tab characters on lines #{failing_lines.join(', ')}"
16
+ end
17
+
18
+ def check_for_extra_spaces(filename)
19
+ failing_lines = []
20
+ File.readlines(filename).each_with_index do |line, number|
21
+ next if line =~ /^\s+#.*\s+\n$/
22
+ failing_lines << number + 1 if line =~ /\s+\n$/
23
+ end
24
+
25
+ return if failing_lines.empty?
26
+ "#{filename} has spaces on the EOL on lines #{failing_lines.join(', ')}"
27
+ end
28
+ end
29
+ end
30
+ end
31
+
3
32
  RSpec.shared_examples_for "library wide checks" do |lib, options|
4
33
  consider_a_test_env_file = options.fetch(:consider_a_test_env_file, /MATCHES NOTHING/)
5
34
  allowed_loaded_feature_regexps = options.fetch(:allowed_loaded_feature_regexps, [])
@@ -8,6 +37,7 @@ RSpec.shared_examples_for "library wide checks" do |lib, options|
8
37
  skip_spec_files = options.fetch(:skip_spec_files, /MATCHES NOTHING/)
9
38
 
10
39
  include RSpec::Support::ShellOut
40
+ include RSpec::Support::WhitespaceChecks
11
41
 
12
42
  define_method :files_to_require_for do |sub_dir|
13
43
  slash = File::SEPARATOR
@@ -101,29 +131,6 @@ RSpec.shared_examples_for "library wide checks" do |lib, options|
101
131
  expect(loaded_features).to eq([])
102
132
  end
103
133
 
104
- # This malformed whitespace detection logic has been borrowed from bundler:
105
- # https://github.com/bundler/bundler/blob/v1.8.0/spec/quality_spec.rb
106
- def check_for_tab_characters(filename)
107
- failing_lines = []
108
- File.readlines(filename).each_with_index do |line, number|
109
- failing_lines << number + 1 if line =~ /\t/
110
- end
111
-
112
- return if failing_lines.empty?
113
- "#{filename} has tab characters on lines #{failing_lines.join(', ')}"
114
- end
115
-
116
- def check_for_extra_spaces(filename)
117
- failing_lines = []
118
- File.readlines(filename).each_with_index do |line, number|
119
- next if line =~ /^\s+#.*\s+\n$/
120
- failing_lines << number + 1 if line =~ /\s+\n$/
121
- end
122
-
123
- return if failing_lines.empty?
124
- "#{filename} has spaces on the EOL on lines #{failing_lines.join(', ')}"
125
- end
126
-
127
134
  RSpec::Matchers.define :be_well_formed do
128
135
  match do |actual|
129
136
  actual.empty?
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Support
3
3
  module Version
4
- STRING = '3.3.0'
4
+ STRING = '3.4.0'
5
5
  end
6
6
  end
7
7
  end
@@ -30,7 +30,7 @@ module RSpec
30
30
  call_site = options.fetch(:call_site) { CallerFilter.first_non_rspec_line }
31
31
  message << " Use #{options[:replacement]} instead." if options[:replacement]
32
32
  message << " Called from #{call_site}." if call_site
33
- ::Kernel.warn message
33
+ Support.warning_notifier.call message
34
34
  end
35
35
  end
36
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
@@ -48,7 +48,7 @@ cert_chain:
48
48
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
49
49
  F3MdtaDehhjC
50
50
  -----END CERTIFICATE-----
51
- date: 2015-06-12 00:00:00.000000000 Z
51
+ date: 2015-11-12 00:00:00.000000000 Z
52
52
  dependencies:
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: bundler
@@ -78,6 +78,20 @@ dependencies:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
80
  version: 10.0.0
81
+ - !ruby/object:Gem::Dependency
82
+ name: thread_order
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: 1.1.0
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: 1.1.0
81
95
  description: Support utilities for RSpec gems
82
96
  email: rspec-users@rubyforge.org
83
97
  executables: []
@@ -85,10 +99,11 @@ extensions: []
85
99
  extra_rdoc_files: []
86
100
  files:
87
101
  - Changelog.md
88
- - LICENSE.txt
102
+ - LICENSE.md
89
103
  - README.md
90
104
  - lib/rspec/support.rb
91
105
  - lib/rspec/support/caller_filter.rb
106
+ - lib/rspec/support/comparable_version.rb
92
107
  - lib/rspec/support/differ.rb
93
108
  - lib/rspec/support/directory_maker.rb
94
109
  - lib/rspec/support/encoded_string.rb
@@ -96,8 +111,10 @@ files:
96
111
  - lib/rspec/support/hunk_generator.rb
97
112
  - lib/rspec/support/matcher_definition.rb
98
113
  - lib/rspec/support/method_signature_verifier.rb
114
+ - lib/rspec/support/mutex.rb
99
115
  - lib/rspec/support/object_formatter.rb
100
116
  - lib/rspec/support/recursive_const_methods.rb
117
+ - lib/rspec/support/reentrant_mutex.rb
101
118
  - lib/rspec/support/ruby_features.rb
102
119
  - lib/rspec/support/spec.rb
103
120
  - lib/rspec/support/spec/deprecation_helpers.rb
@@ -136,5 +153,5 @@ rubyforge_project:
136
153
  rubygems_version: 2.2.2
137
154
  signing_key:
138
155
  specification_version: 4
139
- summary: rspec-support-3.3.0
156
+ summary: rspec-support-3.4.0
140
157
  test_files: []
metadata.gz.sig CHANGED
Binary file