rspec-expectations 3.0.0.beta1 → 3.0.0.beta2

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 (122) hide show
  1. data.tar.gz.sig +2 -2
  2. data/.yardopts +1 -0
  3. data/Changelog.md +138 -0
  4. data/README.md +75 -8
  5. data/features/README.md +2 -2
  6. data/features/built_in_matchers/README.md +12 -9
  7. data/features/built_in_matchers/comparisons.feature +2 -2
  8. data/features/built_in_matchers/contain_exactly.feature +46 -0
  9. data/features/built_in_matchers/expect_change.feature +2 -2
  10. data/features/built_in_matchers/include.feature +0 -48
  11. data/features/built_in_matchers/output.feature +70 -0
  12. data/features/composing_matchers.feature +250 -0
  13. data/features/compound_expectations.feature +45 -0
  14. data/features/custom_matchers/access_running_example.feature +1 -1
  15. data/features/custom_matchers/define_matcher.feature +6 -6
  16. data/features/custom_matchers/define_matcher_outside_rspec.feature +4 -8
  17. data/features/test_frameworks/{test_unit.feature → minitest.feature} +11 -11
  18. data/lib/rspec/expectations.rb +31 -42
  19. data/lib/rspec/expectations/diff_presenter.rb +141 -0
  20. data/lib/rspec/expectations/differ.rb +22 -132
  21. data/lib/rspec/expectations/encoded_string.rb +56 -0
  22. data/lib/rspec/expectations/expectation_target.rb +0 -30
  23. data/lib/rspec/expectations/fail_with.rb +2 -2
  24. data/lib/rspec/expectations/handler.rb +128 -31
  25. data/lib/rspec/expectations/minitest_integration.rb +16 -0
  26. data/lib/rspec/expectations/syntax.rb +4 -58
  27. data/lib/rspec/expectations/version.rb +1 -1
  28. data/lib/rspec/matchers.rb +298 -60
  29. data/lib/rspec/matchers/aliased_matcher.rb +35 -0
  30. data/lib/rspec/matchers/built_in.rb +37 -33
  31. data/lib/rspec/matchers/built_in/base_matcher.rb +25 -15
  32. data/lib/rspec/matchers/built_in/be.rb +23 -31
  33. data/lib/rspec/matchers/built_in/be_between.rb +55 -0
  34. data/lib/rspec/matchers/built_in/be_within.rb +15 -11
  35. data/lib/rspec/matchers/built_in/change.rb +198 -81
  36. data/lib/rspec/matchers/built_in/compound.rb +106 -0
  37. data/lib/rspec/matchers/built_in/contain_exactly.rb +245 -0
  38. data/lib/rspec/matchers/built_in/eq.rb +43 -4
  39. data/lib/rspec/matchers/built_in/eql.rb +2 -2
  40. data/lib/rspec/matchers/built_in/equal.rb +35 -18
  41. data/lib/rspec/matchers/built_in/has.rb +16 -15
  42. data/lib/rspec/matchers/built_in/include.rb +45 -23
  43. data/lib/rspec/matchers/built_in/match.rb +6 -3
  44. data/lib/rspec/matchers/built_in/operators.rb +103 -0
  45. data/lib/rspec/matchers/built_in/output.rb +108 -0
  46. data/lib/rspec/matchers/built_in/raise_error.rb +9 -15
  47. data/lib/rspec/matchers/built_in/respond_to.rb +5 -4
  48. data/lib/rspec/matchers/built_in/satisfy.rb +4 -3
  49. data/lib/rspec/matchers/built_in/start_and_end_with.rb +37 -16
  50. data/lib/rspec/matchers/built_in/throw_symbol.rb +6 -5
  51. data/lib/rspec/matchers/built_in/yield.rb +31 -29
  52. data/lib/rspec/matchers/composable.rb +138 -0
  53. data/lib/rspec/matchers/dsl.rb +330 -0
  54. data/lib/rspec/matchers/generated_descriptions.rb +6 -6
  55. data/lib/rspec/matchers/matcher_delegator.rb +33 -0
  56. data/lib/rspec/matchers/pretty.rb +13 -2
  57. data/spec/rspec/expectations/{differ_spec.rb → diff_presenter_spec.rb} +56 -36
  58. data/spec/rspec/expectations/encoded_string_spec.rb +74 -0
  59. data/spec/rspec/expectations/extensions/kernel_spec.rb +11 -11
  60. data/spec/rspec/expectations/fail_with_spec.rb +8 -8
  61. data/spec/rspec/expectations/handler_spec.rb +27 -49
  62. data/spec/rspec/expectations/minitest_integration_spec.rb +27 -0
  63. data/spec/rspec/expectations/syntax_spec.rb +17 -67
  64. data/spec/rspec/expectations_spec.rb +7 -52
  65. data/spec/rspec/matchers/aliased_matcher_spec.rb +48 -0
  66. data/spec/rspec/matchers/aliases_spec.rb +449 -0
  67. data/spec/rspec/matchers/{base_matcher_spec.rb → built_in/base_matcher_spec.rb} +24 -3
  68. data/spec/rspec/matchers/built_in/be_between_spec.rb +159 -0
  69. data/spec/rspec/matchers/{be_instance_of_spec.rb → built_in/be_instance_of_spec.rb} +0 -0
  70. data/spec/rspec/matchers/{be_kind_of_spec.rb → built_in/be_kind_of_spec.rb} +0 -0
  71. data/spec/rspec/matchers/{be_spec.rb → built_in/be_spec.rb} +76 -32
  72. data/spec/rspec/matchers/{be_within_spec.rb → built_in/be_within_spec.rb} +6 -2
  73. data/spec/rspec/matchers/{change_spec.rb → built_in/change_spec.rb} +310 -69
  74. data/spec/rspec/matchers/built_in/compound_spec.rb +292 -0
  75. data/spec/rspec/matchers/built_in/contain_exactly_spec.rb +441 -0
  76. data/spec/rspec/matchers/{cover_spec.rb → built_in/cover_spec.rb} +0 -0
  77. data/spec/rspec/matchers/built_in/eq_spec.rb +156 -0
  78. data/spec/rspec/matchers/{eql_spec.rb → built_in/eql_spec.rb} +2 -2
  79. data/spec/rspec/matchers/built_in/equal_spec.rb +106 -0
  80. data/spec/rspec/matchers/{exist_spec.rb → built_in/exist_spec.rb} +1 -1
  81. data/spec/rspec/matchers/{has_spec.rb → built_in/has_spec.rb} +39 -0
  82. data/spec/rspec/matchers/{include_spec.rb → built_in/include_spec.rb} +118 -109
  83. data/spec/rspec/matchers/{match_spec.rb → built_in/match_spec.rb} +30 -2
  84. data/spec/rspec/matchers/{operator_matcher_spec.rb → built_in/operators_spec.rb} +26 -26
  85. data/spec/rspec/matchers/built_in/output_spec.rb +165 -0
  86. data/spec/rspec/matchers/{raise_error_spec.rb → built_in/raise_error_spec.rb} +81 -11
  87. data/spec/rspec/matchers/{respond_to_spec.rb → built_in/respond_to_spec.rb} +0 -0
  88. data/spec/rspec/matchers/{satisfy_spec.rb → built_in/satisfy_spec.rb} +0 -0
  89. data/spec/rspec/matchers/{start_with_end_with_spec.rb → built_in/start_and_end_with_spec.rb} +82 -15
  90. data/spec/rspec/matchers/{throw_symbol_spec.rb → built_in/throw_symbol_spec.rb} +29 -10
  91. data/spec/rspec/matchers/{yield_spec.rb → built_in/yield_spec.rb} +90 -0
  92. data/spec/rspec/matchers/configuration_spec.rb +7 -39
  93. data/spec/rspec/matchers/description_generation_spec.rb +22 -6
  94. data/spec/rspec/matchers/dsl_spec.rb +838 -0
  95. data/spec/rspec/matchers/legacy_spec.rb +101 -0
  96. data/spec/rspec/matchers_spec.rb +74 -0
  97. data/spec/spec_helper.rb +35 -21
  98. data/spec/support/shared_examples.rb +26 -4
  99. metadata +172 -116
  100. metadata.gz.sig +3 -4
  101. checksums.yaml +0 -15
  102. checksums.yaml.gz.sig +0 -0
  103. data/features/built_in_matchers/match_array.feature +0 -37
  104. data/lib/rspec/expectations/errors.rb +0 -9
  105. data/lib/rspec/expectations/extensions.rb +0 -1
  106. data/lib/rspec/expectations/extensions/object.rb +0 -29
  107. data/lib/rspec/matchers/built_in/match_array.rb +0 -51
  108. data/lib/rspec/matchers/compatibility.rb +0 -14
  109. data/lib/rspec/matchers/matcher.rb +0 -301
  110. data/lib/rspec/matchers/method_missing.rb +0 -12
  111. data/lib/rspec/matchers/operator_matcher.rb +0 -99
  112. data/lib/rspec/matchers/test_unit_integration.rb +0 -11
  113. data/spec/rspec/matchers/eq_spec.rb +0 -60
  114. data/spec/rspec/matchers/equal_spec.rb +0 -78
  115. data/spec/rspec/matchers/include_matcher_integration_spec.rb +0 -30
  116. data/spec/rspec/matchers/match_array_spec.rb +0 -194
  117. data/spec/rspec/matchers/matcher_spec.rb +0 -706
  118. data/spec/rspec/matchers/matchers_spec.rb +0 -36
  119. data/spec/rspec/matchers/method_missing_spec.rb +0 -28
  120. data/spec/support/classes.rb +0 -56
  121. data/spec/support/in_sub_process.rb +0 -37
  122. data/spec/support/ruby_version.rb +0 -10
@@ -0,0 +1,56 @@
1
+ require "delegate"
2
+
3
+ module RSpec
4
+ module Expectations
5
+ class EncodedString < SimpleDelegator
6
+
7
+ def initialize(string, encoding = nil)
8
+ @encoding = encoding
9
+ @source_encoding = detect_source_encoding(string)
10
+ @string = matching_encoding(string)
11
+ super(@string)
12
+ end
13
+ attr_reader :source_encoding
14
+
15
+ def <<(string)
16
+ @string << matching_encoding(string)
17
+ end
18
+
19
+ def split(regex_or_string)
20
+ @string.split(matching_encoding(regex_or_string))
21
+ end
22
+
23
+ private
24
+
25
+ if String.method_defined?(:encoding)
26
+ def matching_encoding(string)
27
+ string.encode(@encoding)
28
+ rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError
29
+ normalize_missing(string.encode(@encoding, :invalid => :replace, :undef => :replace))
30
+ rescue Encoding::ConverterNotFoundError
31
+ normalize_missing(string.force_encoding(@encoding).encode(:invalid => :replace))
32
+ end
33
+
34
+ def normalize_missing(string)
35
+ if @encoding.to_s == "UTF-8"
36
+ string.gsub("\xEF\xBF\xBD".force_encoding(@encoding), "?")
37
+ else
38
+ string
39
+ end
40
+ end
41
+
42
+ def detect_source_encoding(string)
43
+ string.encoding
44
+ end
45
+ else
46
+ def matching_encoding(string)
47
+ string
48
+ end
49
+
50
+ def detect_source_encoding(string)
51
+ 'US-ASCII'
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -10,11 +10,6 @@ module RSpec
10
10
  # # with `not_to`
11
11
  # expect(actual).not_to eq(3)
12
12
  class ExpectationTarget
13
- class << self
14
- attr_accessor :deprecated_should_enabled
15
- alias deprecated_should_enabled? deprecated_should_enabled
16
- end
17
-
18
13
  # @api private
19
14
  def initialize(target)
20
15
  @target = target
@@ -48,31 +43,6 @@ module RSpec
48
43
  end
49
44
  alias to_not not_to
50
45
 
51
- def self.enable_deprecated_should
52
- return if deprecated_should_enabled?
53
-
54
- def should(*args)
55
- RSpec.deprecate "`expect { }.should`", :replacement => "`expect { }.to`"
56
- @target.should(*args)
57
- end
58
-
59
- def should_not(*args)
60
- RSpec.deprecate "`expect { }.should_not`", :replacement => "`expect { }.not_to`"
61
- @target.should_not(*args)
62
- end
63
-
64
- self.deprecated_should_enabled = true
65
- end
66
-
67
- def self.disable_deprecated_should
68
- return unless deprecated_should_enabled?
69
-
70
- remove_method :should
71
- remove_method :should_not
72
-
73
- self.deprecated_should_enabled = false
74
- end
75
-
76
46
  private
77
47
 
78
48
  def prevent_operator_matchers(verb, matcher)
@@ -3,7 +3,7 @@ module RSpec
3
3
  class << self
4
4
  # @private
5
5
  def differ
6
- @differ ||= Differ.new
6
+ DiffPresenter.new
7
7
  end
8
8
 
9
9
  # Raises an RSpec::Expectations::ExpectationNotMetError with message.
@@ -16,7 +16,7 @@ module RSpec
16
16
  def fail_with(message, expected=nil, actual=nil)
17
17
  if !message
18
18
  raise ArgumentError, "Failure message is nil. Does your matcher define the " +
19
- "appropriate failure_message_for_* method to return a string?"
19
+ "appropriate failure_message[_when_negated] method to return a string?"
20
20
  end
21
21
 
22
22
  if actual && expected
@@ -1,7 +1,8 @@
1
1
  module RSpec
2
2
  module Expectations
3
3
 
4
- class ExpectationHandler
4
+ # @api private
5
+ class ExpectationHelper
5
6
  def self.check_message(msg)
6
7
  unless msg.nil? || msg.respond_to?(:to_str) || msg.respond_to?(:call)
7
8
  ::Kernel.warn [
@@ -11,24 +12,25 @@ module RSpec
11
12
  ].join
12
13
  end
13
14
  end
14
- end
15
15
 
16
- class PositiveExpectationHandler < ExpectationHandler
16
+ # Returns an RSpec-3+ compatible matcher, wrapping a legacy one
17
+ # in an adapter if necessary.
18
+ #
19
+ # @api private
20
+ def self.modern_matcher_from(matcher)
21
+ LegacyMacherAdapter::RSpec2.wrap(matcher) ||
22
+ LegacyMacherAdapter::RSpec1.wrap(matcher) || matcher
23
+ end
17
24
 
18
- def self.handle_matcher(actual, matcher, message=nil, &block)
25
+ def self.setup(handler, matcher, message)
19
26
  check_message(message)
20
- ::RSpec::Matchers.last_should = :should
21
- ::RSpec::Matchers.last_matcher = matcher
22
- return ::RSpec::Matchers::BuiltIn::PositiveOperatorMatcher.new(actual) if matcher.nil?
23
-
24
- match = matcher.matches?(actual, &block)
25
- return match if match
27
+ ::RSpec::Matchers.last_expectation_handler = handler
28
+ ::RSpec::Matchers.last_matcher = modern_matcher_from(matcher)
29
+ end
26
30
 
31
+ def self.handle_failure(matcher, message, failure_message_method)
27
32
  message = message.call if message.respond_to?(:call)
28
-
29
- message ||= matcher.respond_to?(:failure_message_for_should) ?
30
- matcher.failure_message_for_should :
31
- matcher.failure_message
33
+ message ||= matcher.__send__(failure_message_method)
32
34
 
33
35
  if matcher.respond_to?(:diffable?) && matcher.diffable?
34
36
  ::RSpec::Expectations.fail_with message, matcher.expected, matcher.actual
@@ -38,28 +40,123 @@ module RSpec
38
40
  end
39
41
  end
40
42
 
41
- class NegativeExpectationHandler < ExpectationHandler
42
- def self.handle_matcher(actual, matcher, message=nil, &block)
43
- check_message(message)
44
- ::RSpec::Matchers.last_should = :should_not
45
- ::RSpec::Matchers.last_matcher = matcher
46
- return ::RSpec::Matchers::BuiltIn::NegativeOperatorMatcher.new(actual) if matcher.nil?
43
+ # @api private
44
+ class PositiveExpectationHandler
45
+ def self.handle_matcher(actual, initial_matcher, message=nil, &block)
46
+ matcher = ExpectationHelper.setup(self, initial_matcher, message)
47
47
 
48
- match = matcher.respond_to?(:does_not_match?) ?
49
- !matcher.does_not_match?(actual, &block) :
50
- matcher.matches?(actual, &block)
51
- return match unless match
48
+ return ::RSpec::Matchers::BuiltIn::PositiveOperatorMatcher.new(actual) unless initial_matcher
49
+ matcher.matches?(actual, &block) or ExpectationHelper.handle_failure(matcher, message, :failure_message)
50
+ end
52
51
 
53
- message = message.call if message.respond_to?(:call)
52
+ def self.verb
53
+ "should"
54
+ end
54
55
 
55
- message ||= matcher.respond_to?(:failure_message_for_should_not) ?
56
- matcher.failure_message_for_should_not :
57
- matcher.negative_failure_message
56
+ def self.should_method
57
+ :should
58
+ end
58
59
 
59
- if matcher.respond_to?(:diffable?) && matcher.diffable?
60
- ::RSpec::Expectations.fail_with message, matcher.expected, matcher.actual
60
+ def self.opposite_should_method
61
+ :should_not
62
+ end
63
+ end
64
+
65
+ # @api private
66
+ class NegativeExpectationHandler
67
+ def self.handle_matcher(actual, initial_matcher, message=nil, &block)
68
+ matcher = ExpectationHelper.setup(self, initial_matcher, message)
69
+
70
+ return ::RSpec::Matchers::BuiltIn::NegativeOperatorMatcher.new(actual) unless initial_matcher
71
+ !(does_not_match?(matcher, actual, &block) or ExpectationHelper.handle_failure(matcher, message, :failure_message_when_negated))
72
+ end
73
+
74
+ def self.does_not_match?(matcher, actual, &block)
75
+ if matcher.respond_to?(:does_not_match?)
76
+ matcher.does_not_match?(actual, &block)
61
77
  else
62
- ::RSpec::Expectations.fail_with message
78
+ !matcher.matches?(actual, &block)
79
+ end
80
+ end
81
+
82
+ def self.verb
83
+ "should not"
84
+ end
85
+
86
+ def self.should_method
87
+ :should_not
88
+ end
89
+
90
+ def self.opposite_should_method
91
+ :should
92
+ end
93
+ end
94
+
95
+ # Wraps a matcher written against one of the legacy protocols in
96
+ # order to present the current protocol.
97
+ #
98
+ # @api private
99
+ class LegacyMacherAdapter < Matchers::MatcherDelegator
100
+ def initialize(matcher)
101
+ super
102
+ ::RSpec.warn_deprecation(<<-EOS.gsub(/^\s+\|/, ''))
103
+ |--------------------------------------------------------------------------
104
+ |#{matcher.class.name || matcher.inspect} implements a legacy RSpec matcher
105
+ |protocol. For the current protocol you should expose the failure messages
106
+ |via the `failure_message` and `failure_message_when_negated` methods.
107
+ |(Used from #{CallerFilter.first_non_rspec_line})
108
+ |--------------------------------------------------------------------------
109
+ EOS
110
+ end
111
+
112
+ def self.wrap(matcher)
113
+ new(matcher) if interface_matches?(matcher)
114
+ end
115
+
116
+ # Starting in RSpec 1.2 (and continuing through all 2.x releases),
117
+ # the failure message protocol was:
118
+ # * `failure_message_for_should`
119
+ # * `failure_message_for_should_not`
120
+ # @api private
121
+ class RSpec2 < self
122
+ def failure_message
123
+ base_matcher.failure_message_for_should
124
+ end
125
+
126
+ def failure_message_when_negated
127
+ base_matcher.failure_message_for_should_not
128
+ end
129
+
130
+ def self.interface_matches?(matcher)
131
+ (
132
+ !matcher.respond_to?(:failure_message) &&
133
+ matcher.respond_to?(:failure_message_for_should)
134
+ ) || (
135
+ !matcher.respond_to?(:failure_message_when_negated) &&
136
+ matcher.respond_to?(:failure_message_for_should_not)
137
+ )
138
+ end
139
+ end
140
+
141
+ # Before RSpec 1.2, the failure message protocol was:
142
+ # * `failure_message`
143
+ # * `negative_failure_message`
144
+ # @api private
145
+ class RSpec1 < self
146
+ def failure_message
147
+ base_matcher.failure_message
148
+ end
149
+
150
+ def failure_message_when_negated
151
+ base_matcher.negative_failure_message
152
+ end
153
+
154
+ # Note: `failure_message` is part of the RSpec 3 protocol
155
+ # (paired with `failure_message_when_negated`), so we don't check
156
+ # for `failure_message` here.
157
+ def self.interface_matches?(matcher)
158
+ !matcher.respond_to?(:failure_message_when_negated) &&
159
+ matcher.respond_to?(:negative_failure_message)
63
160
  end
64
161
  end
65
162
  end
@@ -0,0 +1,16 @@
1
+ require 'rspec/expectations'
2
+
3
+ Minitest::Test.class_eval do
4
+ include ::RSpec::Matchers
5
+
6
+ def expect(*a, &b)
7
+ assert(true) # so each expectation gets counted in minitest's assertion stats
8
+ super
9
+ end
10
+ end
11
+
12
+ module RSpec::Expectations
13
+ remove_const :ExpectationNotMetError
14
+ ExpectationNotMetError = ::Minitest::Assertion
15
+ end
16
+
@@ -4,7 +4,7 @@ module RSpec
4
4
  # Provides methods for enabling and disabling the available
5
5
  # syntaxes provided by rspec-expectations.
6
6
  module Syntax
7
- extend self
7
+ module_function
8
8
 
9
9
  # @method should
10
10
  # Passes if `matcher` returns true. Available on every `Object`.
@@ -43,11 +43,11 @@ module RSpec
43
43
  @default_should_host ||= ::Object.ancestors.last
44
44
  end
45
45
 
46
- def self.warn_about_should!
46
+ def warn_about_should!
47
47
  @warn_about_should = true
48
48
  end
49
49
 
50
- def self.warn_about_should_unless_configured(method_name)
50
+ def warn_about_should_unless_configured(method_name)
51
51
  if @warn_about_should
52
52
  RSpec.deprecate(
53
53
  "Using `#{method_name}` from rspec-expectations' old `:should` syntax without explicitly enabling the syntax",
@@ -61,7 +61,7 @@ module RSpec
61
61
  # @api private
62
62
  # Enables the `should` syntax.
63
63
  def enable_should(syntax_host = default_should_host)
64
- @warn_about_should = false
64
+ @warn_about_should = false if syntax_host == default_should_host
65
65
  return if should_enabled?(syntax_host)
66
66
 
67
67
  syntax_host.module_exec do
@@ -75,8 +75,6 @@ module RSpec
75
75
  ::RSpec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
76
76
  end
77
77
  end
78
-
79
- ::RSpec::Expectations::ExpectationTarget.enable_deprecated_should if expect_enabled?
80
78
  end
81
79
 
82
80
  # @api private
@@ -88,8 +86,6 @@ module RSpec
88
86
  undef should
89
87
  undef should_not
90
88
  end
91
-
92
- ::RSpec::Expectations::ExpectationTarget.disable_deprecated_should
93
89
  end
94
90
 
95
91
  # @api private
@@ -104,8 +100,6 @@ module RSpec
104
100
  ::RSpec::Expectations::ExpectationTarget.new(target.first)
105
101
  end
106
102
  end
107
-
108
- ::RSpec::Expectations::ExpectationTarget.enable_deprecated_should if should_enabled?
109
103
  end
110
104
 
111
105
  # @api private
@@ -116,8 +110,6 @@ module RSpec
116
110
  syntax_host.module_exec do
117
111
  undef expect
118
112
  end
119
-
120
- ::RSpec::Expectations::ExpectationTarget.disable_deprecated_should
121
113
  end
122
114
 
123
115
  # @api private
@@ -131,52 +123,6 @@ module RSpec
131
123
  def expect_enabled?(syntax_host = ::RSpec::Matchers)
132
124
  syntax_host.method_defined?(:expect)
133
125
  end
134
-
135
- # @api private
136
- # Generates a positive expectation expression.
137
- def positive_expression(target_expression, matcher_expression)
138
- expression_generator.positive_expression(target_expression, matcher_expression)
139
- end
140
-
141
- # @api private
142
- # Generates a negative expectation expression.
143
- def negative_expression(target_expression, matcher_expression)
144
- expression_generator.negative_expression(target_expression, matcher_expression)
145
- end
146
-
147
- # @api private
148
- # Selects which expression generator to use based on the configured syntax.
149
- def expression_generator
150
- if expect_enabled?
151
- ExpectExpressionGenerator
152
- else
153
- ShouldExpressionGenerator
154
- end
155
- end
156
-
157
- # @api private
158
- # Generates expectation expressions for the `should` syntax.
159
- module ShouldExpressionGenerator
160
- def self.positive_expression(target_expression, matcher_expression)
161
- "#{target_expression}.should #{matcher_expression}"
162
- end
163
-
164
- def self.negative_expression(target_expression, matcher_expression)
165
- "#{target_expression}.should_not #{matcher_expression}"
166
- end
167
- end
168
-
169
- # @api private
170
- # Generates expectation expressions for the `expect` syntax.
171
- module ExpectExpressionGenerator
172
- def self.positive_expression(target_expression, matcher_expression)
173
- "expect(#{target_expression}).to #{matcher_expression}"
174
- end
175
-
176
- def self.negative_expression(target_expression, matcher_expression)
177
- "expect(#{target_expression}).not_to #{matcher_expression}"
178
- end
179
- end
180
126
  end
181
127
  end
182
128
  end
@@ -2,7 +2,7 @@ module RSpec
2
2
  module Expectations
3
3
  # @private
4
4
  module Version
5
- STRING = '3.0.0.beta1'
5
+ STRING = '3.0.0.beta2'
6
6
  end
7
7
  end
8
8
  end