rspec-expectations 3.0.0.beta2 → 3.0.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 (135) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -2
  4. data/.yardopts +0 -1
  5. data/Changelog.md +115 -35
  6. data/README.md +2 -2
  7. data/lib/rspec/expectations.rb +13 -8
  8. data/lib/rspec/{matchers → expectations}/configuration.rb +38 -13
  9. data/lib/rspec/expectations/expectation_target.rb +72 -8
  10. data/lib/rspec/expectations/fail_with.rb +10 -52
  11. data/lib/rspec/expectations/handler.rb +9 -11
  12. data/lib/rspec/expectations/syntax.rb +37 -35
  13. data/lib/rspec/expectations/version.rb +1 -1
  14. data/lib/rspec/matchers.rb +60 -9
  15. data/lib/rspec/matchers/aliased_matcher.rb +6 -0
  16. data/lib/rspec/matchers/built_in.rb +9 -1
  17. data/lib/rspec/matchers/built_in/all.rb +78 -0
  18. data/lib/rspec/matchers/built_in/base_matcher.rb +39 -1
  19. data/lib/rspec/matchers/built_in/be.rb +117 -42
  20. data/lib/rspec/matchers/built_in/be_between.rb +22 -0
  21. data/lib/rspec/matchers/built_in/be_instance_of.rb +11 -3
  22. data/lib/rspec/matchers/built_in/be_kind_of.rb +5 -0
  23. data/lib/rspec/matchers/built_in/be_within.rb +26 -6
  24. data/lib/rspec/matchers/built_in/change.rb +89 -13
  25. data/lib/rspec/matchers/built_in/compound.rb +19 -3
  26. data/lib/rspec/matchers/built_in/contain_exactly.rb +17 -6
  27. data/lib/rspec/matchers/built_in/cover.rb +3 -0
  28. data/lib/rspec/matchers/built_in/eq.rb +20 -5
  29. data/lib/rspec/matchers/built_in/eql.rb +15 -3
  30. data/lib/rspec/matchers/built_in/equal.rb +23 -6
  31. data/lib/rspec/matchers/built_in/exist.rb +74 -10
  32. data/lib/rspec/matchers/built_in/has.rb +58 -3
  33. data/lib/rspec/matchers/built_in/include.rb +16 -1
  34. data/lib/rspec/matchers/built_in/match.rb +14 -4
  35. data/lib/rspec/matchers/built_in/operators.rb +16 -0
  36. data/lib/rspec/matchers/built_in/output.rb +47 -5
  37. data/lib/rspec/matchers/built_in/raise_error.rb +40 -23
  38. data/lib/rspec/matchers/built_in/respond_to.rb +37 -16
  39. data/lib/rspec/matchers/built_in/satisfy.rb +15 -0
  40. data/lib/rspec/matchers/built_in/start_and_end_with.rb +29 -14
  41. data/lib/rspec/matchers/built_in/throw_symbol.rb +32 -3
  42. data/lib/rspec/matchers/built_in/yield.rb +148 -44
  43. data/lib/rspec/matchers/composable.rb +48 -7
  44. data/lib/rspec/matchers/dsl.rb +45 -17
  45. data/lib/rspec/matchers/generated_descriptions.rb +7 -0
  46. data/lib/rspec/matchers/matcher_delegator.rb +6 -2
  47. data/lib/rspec/matchers/pretty.rb +15 -19
  48. metadata +33 -236
  49. metadata.gz.sig +0 -0
  50. data/features/README.md +0 -48
  51. data/features/Upgrade.md +0 -53
  52. data/features/built_in_matchers/README.md +0 -96
  53. data/features/built_in_matchers/be.feature +0 -175
  54. data/features/built_in_matchers/be_within.feature +0 -48
  55. data/features/built_in_matchers/comparisons.feature +0 -97
  56. data/features/built_in_matchers/contain_exactly.feature +0 -46
  57. data/features/built_in_matchers/cover.feature +0 -47
  58. data/features/built_in_matchers/end_with.feature +0 -48
  59. data/features/built_in_matchers/equality.feature +0 -136
  60. data/features/built_in_matchers/exist.feature +0 -45
  61. data/features/built_in_matchers/expect_change.feature +0 -59
  62. data/features/built_in_matchers/expect_error.feature +0 -144
  63. data/features/built_in_matchers/include.feature +0 -126
  64. data/features/built_in_matchers/match.feature +0 -51
  65. data/features/built_in_matchers/output.feature +0 -70
  66. data/features/built_in_matchers/predicates.feature +0 -161
  67. data/features/built_in_matchers/respond_to.feature +0 -84
  68. data/features/built_in_matchers/satisfy.feature +0 -33
  69. data/features/built_in_matchers/start_with.feature +0 -48
  70. data/features/built_in_matchers/throw_symbol.feature +0 -91
  71. data/features/built_in_matchers/types.feature +0 -116
  72. data/features/built_in_matchers/yield.feature +0 -161
  73. data/features/composing_matchers.feature +0 -250
  74. data/features/compound_expectations.feature +0 -45
  75. data/features/custom_matchers/access_running_example.feature +0 -53
  76. data/features/custom_matchers/define_diffable_matcher.feature +0 -27
  77. data/features/custom_matchers/define_matcher.feature +0 -340
  78. data/features/custom_matchers/define_matcher_outside_rspec.feature +0 -34
  79. data/features/custom_matchers/define_matcher_with_fluent_interface.feature +0 -24
  80. data/features/customized_message.feature +0 -39
  81. data/features/diffing.feature +0 -85
  82. data/features/implicit_docstrings.feature +0 -52
  83. data/features/step_definitions/additional_cli_steps.rb +0 -22
  84. data/features/support/env.rb +0 -21
  85. data/features/support/rubinius.rb +0 -6
  86. data/features/syntax_configuration.feature +0 -71
  87. data/features/test_frameworks/minitest.feature +0 -44
  88. data/lib/rspec-expectations.rb +0 -1
  89. data/lib/rspec/expectations/diff_presenter.rb +0 -141
  90. data/lib/rspec/expectations/differ.rb +0 -44
  91. data/lib/rspec/expectations/encoded_string.rb +0 -56
  92. data/spec/rspec/expectations/diff_presenter_spec.rb +0 -249
  93. data/spec/rspec/expectations/encoded_string_spec.rb +0 -74
  94. data/spec/rspec/expectations/expectation_target_spec.rb +0 -82
  95. data/spec/rspec/expectations/extensions/kernel_spec.rb +0 -67
  96. data/spec/rspec/expectations/fail_with_spec.rb +0 -114
  97. data/spec/rspec/expectations/handler_spec.rb +0 -205
  98. data/spec/rspec/expectations/minitest_integration_spec.rb +0 -27
  99. data/spec/rspec/expectations/syntax_spec.rb +0 -89
  100. data/spec/rspec/expectations_spec.rb +0 -12
  101. data/spec/rspec/matchers/aliased_matcher_spec.rb +0 -48
  102. data/spec/rspec/matchers/aliases_spec.rb +0 -449
  103. data/spec/rspec/matchers/built_in/base_matcher_spec.rb +0 -83
  104. data/spec/rspec/matchers/built_in/be_between_spec.rb +0 -159
  105. data/spec/rspec/matchers/built_in/be_instance_of_spec.rb +0 -63
  106. data/spec/rspec/matchers/built_in/be_kind_of_spec.rb +0 -41
  107. data/spec/rspec/matchers/built_in/be_spec.rb +0 -592
  108. data/spec/rspec/matchers/built_in/be_within_spec.rb +0 -141
  109. data/spec/rspec/matchers/built_in/change_spec.rb +0 -808
  110. data/spec/rspec/matchers/built_in/compound_spec.rb +0 -292
  111. data/spec/rspec/matchers/built_in/contain_exactly_spec.rb +0 -441
  112. data/spec/rspec/matchers/built_in/cover_spec.rb +0 -69
  113. data/spec/rspec/matchers/built_in/eq_spec.rb +0 -156
  114. data/spec/rspec/matchers/built_in/eql_spec.rb +0 -41
  115. data/spec/rspec/matchers/built_in/equal_spec.rb +0 -106
  116. data/spec/rspec/matchers/built_in/exist_spec.rb +0 -124
  117. data/spec/rspec/matchers/built_in/has_spec.rb +0 -161
  118. data/spec/rspec/matchers/built_in/include_spec.rb +0 -540
  119. data/spec/rspec/matchers/built_in/match_spec.rb +0 -102
  120. data/spec/rspec/matchers/built_in/operators_spec.rb +0 -252
  121. data/spec/rspec/matchers/built_in/output_spec.rb +0 -165
  122. data/spec/rspec/matchers/built_in/raise_error_spec.rb +0 -461
  123. data/spec/rspec/matchers/built_in/respond_to_spec.rb +0 -292
  124. data/spec/rspec/matchers/built_in/satisfy_spec.rb +0 -44
  125. data/spec/rspec/matchers/built_in/start_and_end_with_spec.rb +0 -253
  126. data/spec/rspec/matchers/built_in/throw_symbol_spec.rb +0 -135
  127. data/spec/rspec/matchers/built_in/yield_spec.rb +0 -627
  128. data/spec/rspec/matchers/configuration_spec.rb +0 -213
  129. data/spec/rspec/matchers/description_generation_spec.rb +0 -191
  130. data/spec/rspec/matchers/dsl_spec.rb +0 -895
  131. data/spec/rspec/matchers/legacy_spec.rb +0 -101
  132. data/spec/rspec/matchers_spec.rb +0 -74
  133. data/spec/spec_helper.rb +0 -85
  134. data/spec/support/matchers.rb +0 -22
  135. data/spec/support/shared_examples.rb +0 -35
metadata.gz.sig CHANGED
Binary file
@@ -1,48 +0,0 @@
1
- rspec-expectations is used to define expected outcomes.
2
-
3
- describe Account do
4
- it "has a balance of zero when first created" do
5
- expect(Account.new.balance).to eq(Money.new(0))
6
- end
7
- end
8
-
9
- ## Basic structure
10
-
11
- The basic structure of an rspec expectation is:
12
-
13
- expect(actual).to matcher(expected)
14
- expect(actual).not_to matcher(expected)
15
-
16
- Note: You can also use `expect(..).to_not` instead of `expect(..).not_to`.
17
- One is an alias to the other, so you can use whichever reads better to you.
18
-
19
- #### Examples
20
-
21
- expect(5).to eq(5)
22
- expect(5).not_to eq(4)
23
-
24
- ## What is a matcher?
25
-
26
- A Matcher is any object that responds to the following methods:
27
-
28
- matches?(actual)
29
- failure_message
30
-
31
- These methods are also part of the matcher protocol, but are optional:
32
-
33
- does_not_match?(actual)
34
- failure_message_when_negated
35
- description
36
-
37
- RSpec ships with a number of built-in matchers and a DSL for writing custom
38
- matchers.
39
-
40
- ## Issues
41
-
42
- The documentation for rspec-expectations is a work in progress. We'll be adding
43
- Cucumber features over time, and clarifying existing ones. If you have
44
- specific features you'd like to see added, find the existing documentation
45
- incomplete or confusing, or, better yet, wish to write a missing Cucumber
46
- feature yourself, please [submit an
47
- issue](http://github.com/rspec/rspec-expectations/issues) or a [pull
48
- request](http://github.com/rspec/rspec-expectations).
@@ -1,53 +0,0 @@
1
- # Upgrade to rspec-expectations-2.0
2
-
3
- ## What's new
4
-
5
- ### New `eq` matcher.
6
-
7
- `RSpec::Matchers` now offers you two approaches to differentiating between
8
- object identity. You can use the rspec-1 approach:
9
-
10
- actual.should == expected # object equality
11
- actual.should equal(expected) # object identity
12
-
13
- ... or, if you prefer:
14
-
15
- actual.should eq(expected) # object equality
16
- actual.should be(expected) # object identity
17
-
18
- ## What's been removed
19
-
20
- ### simple_matcher
21
-
22
- Use RSpec::Matchers.define instead. For example, if you had:
23
-
24
- def eat_cheese
25
- simple_matcher("eat cheese") do |actual|
26
- actual.eat?(:cheese)
27
- end
28
- end
29
-
30
- Change it to:
31
-
32
- RSpec::Matchers.define :eat_cheese do
33
- match do |actual|
34
- actual.eat?(:cheese)
35
- end
36
- end
37
-
38
- ### wrap_expectation
39
-
40
- Use RSpec::Matchers.define instead.
41
-
42
- RSpec::Matchers.define :eat_cheese do
43
- match do |actual|
44
- actual.should eat?(:cheese)
45
- end
46
- end
47
-
48
- RSpec::Matchers.define :eat_cheese do
49
- include MyCheesyAssertions
50
- match_unless_raises Test::Unit::AssertionFailedError do |actual|
51
- assert_eats_chesse actual
52
- end
53
- end
@@ -1,96 +0,0 @@
1
- # Built-in Matchers
2
-
3
- rspec-expectations ships with a number of built-in matchers.
4
- Each matcher can be used with `expect(..).to` or `expect(..).not_to` to define
5
- positive and negative expectations respectively on an object. Most matchers can
6
- also be accessed using the `(...).should` and `(...).should_not` syntax, see
7
- [using should syntax](https://github.com/rspec/rspec-expectations/blob/master/Should.md)
8
- for why we recommend using `expect`.
9
-
10
- e.g.
11
-
12
- expect(result).to eq(3)
13
- expect(list).not_to be_empty
14
- pi.should be > 3
15
-
16
- ## Object identity
17
-
18
- expect(actual).to be(expected) # passes if actual.equal?(expected)
19
-
20
- ## Object equivalence
21
-
22
- expect(actual).to eq(expected) # passes if actual == expected
23
-
24
- ## Optional APIs for identity/equivalence
25
-
26
- expect(actual).to eql(expected) # passes if actual.eql?(expected)
27
- expect(actual).to equal(expected) # passes if actual.equal?(expected)
28
-
29
- # NOTE: `expect` does not support `==` matcher.
30
-
31
- ## Comparisons
32
-
33
- expect(actual).to be > expected
34
- expect(actual).to be >= expected
35
- expect(actual).to be <= expected
36
- expect(actual).to be < expected
37
- expect(actual).to match(/expression/)
38
- expect(actual).to be_within(delta).of(expected)
39
-
40
- # NOTE: `expect` does not support `=~` matcher.
41
-
42
- ## Types/classes
43
-
44
- expect(actual).to be_instance_of(expected)
45
- expect(actual).to be_kind_of(expected)
46
-
47
- ## Truthiness and existentialism
48
-
49
- expect(actual).to be_truthy # passes if actual is truthy (not nil or false)
50
- expect(actual).to be true # passes if actual == true
51
- expect(actual).to be_falsey # passes if actual is falsy (nil or false)
52
- expect(actual).to be false # passes if actual == false
53
- expect(actual).to be_nil # passes if actual is nil
54
-
55
- ## Expecting errors
56
-
57
- expect { ... }.to raise_error
58
- expect { ... }.to raise_error(ErrorClass)
59
- expect { ... }.to raise_error("message")
60
- expect { ... }.to raise_error(ErrorClass, "message")
61
-
62
- ## Expecting throws
63
-
64
- expect { ... }.to throw_symbol
65
- expect { ... }.to throw_symbol(:symbol)
66
- expect { ... }.to throw_symbol(:symbol, 'value')
67
-
68
- ## Predicate matchers
69
-
70
- expect(actual).to be_xxx # passes if actual.xxx?
71
- expect(actual).to have_xxx(:arg) # passes if actual.has_xxx?(:arg)
72
-
73
- ### Examples
74
-
75
- expect([]).to be_empty
76
- expect(:a => 1).to have_key(:a)
77
-
78
- ## Collection membership
79
-
80
- expect(actual).to include(expected)
81
- expect(array).to match_array(expected_array)
82
- # ...which is the same as:
83
- expect(array).to contain_exactly(individual, elements)
84
-
85
- ### Examples
86
-
87
- expect([1, 2, 3]).to include(1)
88
- expect([1, 2, 3]).to include(1, 2)
89
- expect(:a => 'b').to include(:a => 'b')
90
- expect("this string").to include("is str")
91
- expect([1, 2, 3]).to contain_exactly(2, 1, 3)
92
- expect([1, 2, 3]).to match_array([3, 2, 1])
93
-
94
- ## Ranges (1.9 only)
95
-
96
- expect(1..10).to cover(3)
@@ -1,175 +0,0 @@
1
- Feature: "be" matchers
2
-
3
- There are several related "be" matchers:
4
-
5
- ```ruby
6
- expect(obj).to be_truthy # passes if obj is truthy (not nil or false)
7
- expect(obj).to be_falsey # passes if obj is falsy (nil or false)
8
- expect(obj).to be_nil # passes if obj is nil
9
- expect(obj).to be # passes if obj is truthy (not nil or false)
10
- ```
11
-
12
- Scenario: be_truthy matcher
13
- Given a file named "be_truthy_spec.rb" with:
14
- """ruby
15
- describe "be_truthy matcher" do
16
- specify { expect(true).to be_truthy }
17
- specify { expect(7).to be_truthy }
18
- specify { expect("foo").to be_truthy }
19
- specify { expect(nil).not_to be_truthy }
20
- specify { expect(false).not_to be_truthy }
21
-
22
- # deliberate failures
23
- specify { expect(true).not_to be_truthy }
24
- specify { expect(7).not_to be_truthy }
25
- specify { expect("foo").not_to be_truthy }
26
- specify { expect(nil).to be_truthy }
27
- specify { expect(false).to be_truthy }
28
- end
29
- """
30
- When I run `rspec be_truthy_spec.rb`
31
- Then the output should contain "10 examples, 5 failures"
32
- And the output should contain:
33
- """
34
- expected: falsey value
35
- got: true
36
- """
37
- And the output should contain:
38
- """
39
- expected: falsey value
40
- got: 7
41
- """
42
- And the output should contain:
43
- """
44
- expected: falsey value
45
- got: "foo"
46
- """
47
- And the output should contain:
48
- """
49
- expected: truthy value
50
- got: nil
51
- """
52
- And the output should contain:
53
- """
54
- expected: truthy value
55
- got: false
56
- """
57
-
58
- Scenario: be_falsey matcher
59
- Given a file named "be_falsey_spec.rb" with:
60
- """ruby
61
- describe "be_falsey matcher" do
62
- specify { expect(nil).to be_falsey }
63
- specify { expect(false).to be_falsey }
64
- specify { expect(true).not_to be_falsey }
65
- specify { expect(7).not_to be_falsey }
66
- specify { expect("foo").not_to be_falsey }
67
-
68
- # deliberate failures
69
- specify { expect(nil).not_to be_falsey }
70
- specify { expect(false).not_to be_falsey }
71
- specify { expect(true).to be_falsey }
72
- specify { expect(7).to be_falsey }
73
- specify { expect("foo").to be_falsey }
74
- end
75
- """
76
- When I run `rspec be_falsey_spec.rb`
77
- Then the output should contain "10 examples, 5 failures"
78
- And the output should contain:
79
- """
80
- expected: truthy value
81
- got: nil
82
- """
83
- And the output should contain:
84
- """
85
- expected: truthy value
86
- got: false
87
- """
88
- And the output should contain:
89
- """
90
- expected: falsey value
91
- got: true
92
- """
93
- And the output should contain:
94
- """
95
- expected: falsey value
96
- got: 7
97
- """
98
- And the output should contain:
99
- """
100
- expected: falsey value
101
- got: "foo"
102
- """
103
-
104
- Scenario: be_nil matcher
105
- Given a file named "be_nil_spec.rb" with:
106
- """ruby
107
- describe "be_nil matcher" do
108
- specify { expect(nil).to be_nil }
109
- specify { expect(false).not_to be_nil }
110
- specify { expect(true).not_to be_nil }
111
- specify { expect(7).not_to be_nil }
112
- specify { expect("foo").not_to be_nil }
113
-
114
- # deliberate failures
115
- specify { expect(nil).not_to be_nil }
116
- specify { expect(false).to be_nil }
117
- specify { expect(true).to be_nil }
118
- specify { expect(7).to be_nil }
119
- specify { expect("foo").to be_nil }
120
- end
121
- """
122
- When I run `rspec be_nil_spec.rb`
123
- Then the output should contain "10 examples, 5 failures"
124
- And the output should contain:
125
- """
126
- expected: not nil
127
- got: nil
128
- """
129
- And the output should contain:
130
- """
131
- expected: nil
132
- got: false
133
- """
134
- And the output should contain:
135
- """
136
- expected: nil
137
- got: true
138
- """
139
- And the output should contain:
140
- """
141
- expected: nil
142
- got: 7
143
- """
144
- And the output should contain:
145
- """
146
- expected: nil
147
- got: "foo"
148
- """
149
-
150
- Scenario: be matcher
151
- Given a file named "be_spec.rb" with:
152
- """ruby
153
- describe "be_matcher" do
154
- specify { expect(true).to be }
155
- specify { expect(7).to be }
156
- specify { expect("foo").to be }
157
- specify { expect(nil).not_to be }
158
- specify { expect(false).not_to be }
159
-
160
- # deliberate failures
161
- specify { expect(true).not_to be }
162
- specify { expect(7).not_to be }
163
- specify { expect("foo").not_to be }
164
- specify { expect(nil).to be }
165
- specify { expect(false).to be }
166
- end
167
- """
168
- When I run `rspec be_spec.rb`
169
- Then the output should contain all of these:
170
- | 10 examples, 5 failures |
171
- | expected true to evaluate to false |
172
- | expected 7 to evaluate to false |
173
- | expected "foo" to evaluate to false |
174
- | expected nil to evaluate to true |
175
- | expected false to evaluate to true |
@@ -1,48 +0,0 @@
1
- Feature: be_within matcher
2
-
3
- Normal equality expectations do not work well for floating point values.
4
- Consider this irb session:
5
-
6
- > radius = 3
7
- => 3
8
- > area_of_circle = radius * radius * Math::PI
9
- => 28.2743338823081
10
- > area_of_circle == 28.2743338823081
11
- => false
12
-
13
- Instead, you should use the be_within matcher to check that the value
14
- is within a delta of your expected value:
15
-
16
- ```ruby
17
- expect(area_of_circle).to be_within(0.1).of(28.3)
18
- ```
19
-
20
- Note that the difference between the actual and expected values must be
21
- smaller than your delta; if it is equal, the matcher will fail.
22
-
23
- Scenario: basic usage
24
- Given a file named "be_within_matcher_spec.rb" with:
25
- """ruby
26
- describe 27.5 do
27
- it { should be_within(0.5).of(27.9) }
28
- it { should be_within(0.5).of(28.0) }
29
- it { should be_within(0.5).of(27.1) }
30
- it { should be_within(0.5).of(27.0) }
31
-
32
- it { should_not be_within(0.5).of(28.1) }
33
- it { should_not be_within(0.5).of(26.9) }
34
-
35
- # deliberate failures
36
- it { should_not be_within(0.5).of(28) }
37
- it { should_not be_within(0.5).of(27) }
38
- it { should be_within(0.5).of(28.1) }
39
- it { should be_within(0.5).of(26.9) }
40
- end
41
- """
42
- When I run `rspec be_within_matcher_spec.rb`
43
- Then the output should contain all of these:
44
- | 10 examples, 4 failures |
45
- | expected 27.5 not to be within 0.5 of 28 |
46
- | expected 27.5 not to be within 0.5 of 27 |
47
- | expected 27.5 to be within 0.5 of 28.1 |
48
- | expected 27.5 to be within 0.5 of 26.9 |
@@ -1,97 +0,0 @@
1
- Feature: comparison matchers
2
-
3
- RSpec provides a number of matchers that are based on Ruby's built-in
4
- operators. These can be used for generalized comparison of values. E.g.
5
-
6
- ```ruby
7
- expect(9).to be > 6
8
- expect(3).to be <= 3
9
- expect(1).to be < 6
10
- ```
11
-
12
-
13
- Scenario: numeric operator matchers
14
- Given a file named "numeric_operator_matchers_spec.rb" with:
15
- """ruby
16
- describe do
17
- example { expect(18).to be < 20 }
18
- example { expect(18).to be > 15 }
19
- example { expect(18).to be <= 19 }
20
- example { expect(18).to be >= 17 }
21
-
22
- # deliberate failures
23
- example { expect(18).to be < 15 }
24
- example { expect(18).to be > 20 }
25
- example { expect(18).to be <= 17 }
26
- example { expect(18).to be >= 19 }
27
- end
28
- """
29
- When I run `rspec numeric_operator_matchers_spec.rb`
30
- Then the output should contain "8 examples, 4 failures"
31
- And the output should contain:
32
- """
33
- Failure/Error: example { expect(18).to be < 15 }
34
- expected: < 15
35
- got: 18
36
- """
37
- And the output should contain:
38
- """
39
- Failure/Error: example { expect(18).to be > 20 }
40
- expected: > 20
41
- got: 18
42
- """
43
- And the output should contain:
44
- """
45
- Failure/Error: example { expect(18).to be <= 17 }
46
- expected: <= 17
47
- got: 18
48
- """
49
- And the output should contain:
50
- """
51
- Failure/Error: example { expect(18).to be >= 19 }
52
- expected: >= 19
53
- got: 18
54
- """
55
-
56
- Scenario: string operator matchers
57
- Given a file named "string_operator_matchers_spec.rb" with:
58
- """ruby
59
- describe do
60
- example { expect("Strawberry").to be < "Tomato" }
61
- example { expect("Strawberry").to be > "Apple" }
62
- example { expect("Strawberry").to be <= "Turnip" }
63
- example { expect("Strawberry").to be >= "Banana" }
64
-
65
- # deliberate failures
66
- example { expect("Strawberry").to be < "Cranberry" }
67
- example { expect("Strawberry").to be > "Zuchini" }
68
- example { expect("Strawberry").to be <= "Potato" }
69
- example { expect("Strawberry").to be >= "Tomato" }
70
- end
71
- """
72
- When I run `rspec string_operator_matchers_spec.rb`
73
- Then the output should contain "8 examples, 4 failures"
74
- And the output should contain:
75
- """
76
- Failure/Error: example { expect("Strawberry").to be < "Cranberry" }
77
- expected: < "Cranberry"
78
- got: "Strawberry"
79
- """
80
- And the output should contain:
81
- """
82
- Failure/Error: example { expect("Strawberry").to be > "Zuchini" }
83
- expected: > "Zuchini"
84
- got: "Strawberry"
85
- """
86
- And the output should contain:
87
- """
88
- Failure/Error: example { expect("Strawberry").to be <= "Potato" }
89
- expected: <= "Potato"
90
- got: "Strawberry"
91
- """
92
- And the output should contain:
93
- """
94
- Failure/Error: example { expect("Strawberry").to be >= "Tomato" }
95
- expected: >= "Tomato"
96
- got: "Strawberry"
97
- """