rspec-expectations 2.13.0 → 2.99.0

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 (96) hide show
  1. checksums.yaml +15 -0
  2. data/Changelog.md +204 -23
  3. data/README.md +43 -87
  4. data/features/README.md +10 -10
  5. data/features/built_in_matchers/README.md +41 -41
  6. data/features/built_in_matchers/be.feature +40 -40
  7. data/features/built_in_matchers/be_within.feature +3 -3
  8. data/features/built_in_matchers/expect_change.feature +6 -6
  9. data/features/built_in_matchers/expect_error.feature +2 -2
  10. data/features/built_in_matchers/start_with.feature +1 -1
  11. data/features/built_in_matchers/throw_symbol.feature +11 -11
  12. data/features/built_in_matchers/yield.feature +18 -3
  13. data/features/custom_matchers/define_diffable_matcher.feature +1 -1
  14. data/features/custom_matchers/define_matcher_outside_rspec.feature +6 -6
  15. data/features/custom_matchers/define_matcher_with_fluent_interface.feature +1 -1
  16. data/features/customized_message.feature +1 -1
  17. data/features/diffing.feature +1 -1
  18. data/features/step_definitions/additional_cli_steps.rb +10 -0
  19. data/features/support/env.rb +10 -1
  20. data/features/support/rubinius.rb +6 -0
  21. data/features/syntax_configuration.feature +3 -0
  22. data/features/test_frameworks/test_unit.feature +55 -17
  23. data/lib/rspec/expectations/caller_filter.rb +60 -0
  24. data/lib/rspec/{matchers → expectations}/configuration.rb +5 -3
  25. data/lib/rspec/expectations/deprecation.rb +20 -31
  26. data/lib/rspec/expectations/differ.rb +48 -9
  27. data/lib/rspec/expectations/expectation_target.rb +81 -15
  28. data/lib/rspec/expectations/extensions/object.rb +2 -12
  29. data/lib/rspec/expectations/fail_with.rb +11 -1
  30. data/lib/rspec/expectations/handler.rb +16 -7
  31. data/lib/rspec/expectations/syntax.rb +5 -7
  32. data/lib/rspec/expectations/version.rb +1 -1
  33. data/lib/rspec/expectations.rb +28 -2
  34. data/lib/rspec/matchers/be_close.rb +4 -1
  35. data/lib/rspec/matchers/built_in/base_matcher.rb +17 -10
  36. data/lib/rspec/matchers/built_in/be.rb +69 -32
  37. data/lib/rspec/matchers/built_in/be_within.rb +9 -3
  38. data/lib/rspec/matchers/built_in/change.rb +49 -3
  39. data/lib/rspec/matchers/built_in/has.rb +40 -7
  40. data/lib/rspec/matchers/built_in/have.rb +170 -5
  41. data/lib/rspec/matchers/built_in/include.rb +3 -11
  42. data/lib/rspec/matchers/built_in/match.rb +5 -0
  43. data/lib/rspec/matchers/built_in/match_array.rb +1 -1
  44. data/lib/rspec/matchers/built_in/raise_error.rb +34 -8
  45. data/lib/rspec/matchers/built_in/respond_to.rb +7 -1
  46. data/lib/rspec/matchers/built_in/satisfy.rb +7 -1
  47. data/lib/rspec/matchers/built_in/throw_symbol.rb +10 -2
  48. data/lib/rspec/matchers/built_in/yield.rb +102 -5
  49. data/lib/rspec/matchers/built_in.rb +2 -2
  50. data/lib/rspec/matchers/differentiate_block_method_types.rb +55 -0
  51. data/lib/rspec/matchers/dsl.rb +2 -1
  52. data/lib/rspec/matchers/match_aliases.rb +22 -0
  53. data/lib/rspec/matchers/matcher.rb +131 -10
  54. data/lib/rspec/matchers/operator_matcher.rb +70 -66
  55. data/lib/rspec/matchers/pretty.rb +11 -1
  56. data/lib/rspec/matchers/test_unit_integration.rb +28 -0
  57. data/lib/rspec/matchers.rb +175 -146
  58. data/lib/rspec-expectations.rb +5 -0
  59. data/spec/rspec/{matchers → expectations}/configuration_spec.rb +78 -91
  60. data/spec/rspec/expectations/differ_spec.rb +65 -6
  61. data/spec/rspec/expectations/expectation_target_spec.rb +72 -3
  62. data/spec/rspec/expectations/extensions/kernel_spec.rb +9 -5
  63. data/spec/rspec/expectations/fail_with_spec.rb +19 -0
  64. data/spec/rspec/expectations/handler_spec.rb +43 -22
  65. data/spec/rspec/expectations/syntax_spec.rb +51 -9
  66. data/spec/rspec/expectations_spec.rb +71 -0
  67. data/spec/rspec/matchers/base_matcher_spec.rb +33 -18
  68. data/spec/rspec/matchers/be_close_spec.rb +9 -6
  69. data/spec/rspec/matchers/be_spec.rb +146 -45
  70. data/spec/rspec/matchers/be_within_spec.rb +8 -0
  71. data/spec/rspec/matchers/change_spec.rb +107 -7
  72. data/spec/rspec/matchers/description_generation_spec.rb +38 -20
  73. data/spec/rspec/matchers/differentiate_block_method_types_spec.rb +39 -0
  74. data/spec/rspec/matchers/eq_spec.rb +1 -1
  75. data/spec/rspec/matchers/equal_spec.rb +26 -0
  76. data/spec/rspec/matchers/exist_spec.rb +9 -9
  77. data/spec/rspec/matchers/has_spec.rb +25 -1
  78. data/spec/rspec/matchers/have_spec.rb +411 -3
  79. data/spec/rspec/matchers/include_matcher_integration_spec.rb +2 -2
  80. data/spec/rspec/matchers/include_spec.rb +4 -4
  81. data/spec/rspec/matchers/match_array_spec.rb +1 -1
  82. data/spec/rspec/matchers/match_spec.rb +14 -1
  83. data/spec/rspec/matchers/matcher_spec.rb +213 -24
  84. data/spec/rspec/matchers/operator_matcher_spec.rb +56 -8
  85. data/spec/rspec/matchers/pretty_spec.rb +23 -0
  86. data/spec/rspec/matchers/raise_error_spec.rb +242 -102
  87. data/spec/rspec/matchers/respond_to_spec.rb +4 -4
  88. data/spec/rspec/matchers/satisfy_spec.rb +1 -1
  89. data/spec/rspec/matchers/start_with_end_with_spec.rb +2 -2
  90. data/spec/rspec/matchers/throw_symbol_spec.rb +14 -14
  91. data/spec/rspec/matchers/yield_spec.rb +81 -4
  92. data/spec/spec_helper.rb +5 -3
  93. data/spec/support/helper_methods.rb +42 -0
  94. data/spec/support/shared_examples.rb +42 -0
  95. metadata +40 -44
  96. data/spec/rspec/matchers/matchers_spec.rb +0 -37
@@ -1,55 +1,55 @@
1
1
  # Built-in Matchers
2
2
 
3
- Here is a list of matchers that ship with rspec-expectations. Each matcher
4
- can be used with `should` or `should_not` e.g.
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`.
5
9
 
6
- result.should eq(3)
7
- list.should_not be_empty
10
+ e.g.
11
+
12
+ expect(result).to eq(3)
13
+ expect(list).not_to be_empty
14
+ pi.should be > 3
8
15
 
9
16
  ## Object identity
10
17
 
11
- actual.should be(expected) # passes if actual.equal?(expected)
12
-
18
+ expect(actual).to be(expected) # passes if actual.equal?(expected)
19
+
13
20
  ## Object equivalence
14
21
 
15
- actual.should eq(expected) # passes if actual == expected
22
+ expect(actual).to eq(expected) # passes if actual == expected
16
23
 
17
24
  ## Optional APIs for identity/equivalence
18
25
 
19
- actual.should == expected # passes if actual == expected
20
- actual.should eql(expected) # passes if actual.eql?(expected)
21
- actual.should equal(expected) # passes if actual.equal?(expected)
26
+ expect(actual).to eql(expected) # passes if actual.eql?(expected)
27
+ expect(actual).to equal(expected) # passes if actual.equal?(expected)
22
28
 
23
- # NOTE: this can't work in Ruby 1.8, so we don't support it at all:
24
- # actual.should != expected
25
- # The reason is that Ruby 1.8 parses it as:
26
- # !(actual.should.==(expected)),
27
- # so by the time RSpec sees it it has no way to know that it's
28
- # been negated. Use either of these instead:
29
- # actual.should_not eq(expected)
30
- # actual.should_not == expected
29
+ # NOTE: `expect` does not support `==` matcher.
31
30
 
32
31
  ## Comparisons
33
32
 
34
- actual.should be > expected
35
- actual.should be >= expected
36
- actual.should be <= expected
37
- actual.should be < expected
38
- actual.should =~ /expression/
39
- actual.should match(/expression/)
40
- actual.should be_within(delta).of(expected)
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
41
 
42
42
  ## Types/classes
43
43
 
44
- actual.should be_instance_of(expected)
45
- actual.should be_kind_of(expected)
44
+ expect(actual).to be_instance_of(expected)
45
+ expect(actual).to be_kind_of(expected)
46
46
 
47
47
  ## Truthiness and existentialism
48
48
 
49
- actual.should be_true # passes if actual is truthy (not nil or false)
50
- actual.should be_false # passes if actual is falsy (nil or false)
51
- actual.should be_nil # passes if actual is nil
52
- actual.should be # passes if actual is truthy (not nil or false)
49
+ expect(actual).to be_true # passes if actual is truthy (not nil or false)
50
+ expect(actual).to be_false # passes if actual is falsy (nil or false)
51
+ expect(actual).to be_nil # passes if actual is nil
52
+ expect(actual).to be # passes if actual is truthy (not nil or false)
53
53
 
54
54
  ## Expecting errors
55
55
 
@@ -66,25 +66,25 @@ can be used with `should` or `should_not` e.g.
66
66
 
67
67
  ## Predicate matchers
68
68
 
69
- actual.should be_xxx # passes if actual.xxx?
70
- actual.should have_xxx(:arg) # passes if actual.has_xxx?(:arg)
69
+ expect(actual).to be_xxx # passes if actual.xxx?
70
+ expect(actual).to have_xxx(:arg) # passes if actual.has_xxx?(:arg)
71
71
 
72
72
  ### Examples
73
73
 
74
- [].should be_empty # passes because [].empty? returns true
75
- { :a => 1 }.should have_key(:a) # passes because the hash has the key :a
74
+ expect([]).to be_empty
75
+ expect(:a => 1).to have_key(:a)
76
76
 
77
77
  ## Collection membership
78
78
 
79
- actual.should include(expected)
79
+ expect(actual).to include(expected)
80
80
 
81
81
  ### Examples
82
82
 
83
- [1,2,3].should include(1)
84
- [1,2,3].should include(1, 2)
85
- {:a => 'b'}.should include(:a => 'b')
86
- "this string".should include("is str")
83
+ expect([1,2,3]).to include(1)
84
+ expect([1,2,3]).to include(1, 2)
85
+ expect(:a => 'b').to include(:a => 'b')
86
+ expect("this string").to include("is str")
87
87
 
88
88
  ## Ranges (1.9 only)
89
89
 
90
- (1..10).should cover(3)
90
+ expect(1..10).to cover(3)
@@ -3,101 +3,101 @@ Feature: "be" matchers
3
3
  There are several related "be" matchers:
4
4
 
5
5
  ```ruby
6
- obj.should be_true # passes if obj is truthy (not nil or false)
7
- obj.should be_false # passes if obj is falsy (nil or false)
6
+ obj.should be_truthy # passes if obj is truthy (not nil or false)
7
+ obj.should be_falsey # passes if obj is falsy (nil or false)
8
8
  obj.should be_nil # passes if obj is nil
9
9
  obj.should be # passes if obj is truthy (not nil or false)
10
10
  ```
11
11
 
12
- Scenario: be_true matcher
13
- Given a file named "be_true_spec.rb" with:
12
+ Scenario: be_truthy matcher
13
+ Given a file named "be_truthy_spec.rb" with:
14
14
  """ruby
15
- describe "be_true matcher" do
16
- specify { true.should be_true }
17
- specify { 7.should be_true }
18
- specify { "foo".should be_true }
19
- specify { nil.should_not be_true }
20
- specify { false.should_not be_true }
15
+ describe "be_truthy matcher" do
16
+ specify { true.should be_truthy }
17
+ specify { 7.should be_truthy }
18
+ specify { "foo".should be_truthy }
19
+ specify { nil.should_not be_truthy }
20
+ specify { false.should_not be_truthy }
21
21
 
22
22
  # deliberate failures
23
- specify { true.should_not be_true }
24
- specify { 7.should_not be_true }
25
- specify { "foo".should_not be_true }
26
- specify { nil.should be_true }
27
- specify { false.should be_true }
23
+ specify { true.should_not be_truthy }
24
+ specify { 7.should_not be_truthy }
25
+ specify { "foo".should_not be_truthy }
26
+ specify { nil.should be_truthy }
27
+ specify { false.should be_truthy }
28
28
  end
29
29
  """
30
- When I run `rspec be_true_spec.rb`
30
+ When I run `rspec be_truthy_spec.rb`
31
31
  Then the output should contain "10 examples, 5 failures"
32
32
  And the output should contain:
33
33
  """
34
- expected: non-true value
34
+ expected: falsey value
35
35
  got: true
36
36
  """
37
37
  And the output should contain:
38
38
  """
39
- expected: non-true value
39
+ expected: falsey value
40
40
  got: 7
41
41
  """
42
42
  And the output should contain:
43
43
  """
44
- expected: non-true value
44
+ expected: falsey value
45
45
  got: "foo"
46
46
  """
47
47
  And the output should contain:
48
48
  """
49
- expected: true value
49
+ expected: truthy value
50
50
  got: nil
51
51
  """
52
52
  And the output should contain:
53
53
  """
54
- expected: true value
54
+ expected: truthy value
55
55
  got: false
56
56
  """
57
57
 
58
- Scenario: be_false matcher
59
- Given a file named "be_false_spec.rb" with:
58
+ Scenario: be_falsey matcher
59
+ Given a file named "be_falsey_spec.rb" with:
60
60
  """ruby
61
- describe "be_false matcher" do
62
- specify { nil.should be_false }
63
- specify { false.should be_false }
64
- specify { true.should_not be_false }
65
- specify { 7.should_not be_false }
66
- specify { "foo".should_not be_false }
61
+ describe "be_falsey matcher" do
62
+ specify { nil.should be_falsey }
63
+ specify { false.should be_falsey }
64
+ specify { true.should_not be_falsey }
65
+ specify { 7.should_not be_falsey }
66
+ specify { "foo".should_not be_falsey }
67
67
 
68
68
  # deliberate failures
69
- specify { nil.should_not be_false }
70
- specify { false.should_not be_false }
71
- specify { true.should be_false }
72
- specify { 7.should be_false }
73
- specify { "foo".should be_false }
69
+ specify { nil.should_not be_falsey }
70
+ specify { false.should_not be_falsey }
71
+ specify { true.should be_falsey }
72
+ specify { 7.should be_falsey }
73
+ specify { "foo".should be_falsey }
74
74
  end
75
75
  """
76
- When I run `rspec be_false_spec.rb`
76
+ When I run `rspec be_falsey_spec.rb`
77
77
  Then the output should contain "10 examples, 5 failures"
78
78
  And the output should contain:
79
79
  """
80
- expected: non-false value
80
+ expected: truthy value
81
81
  got: nil
82
82
  """
83
83
  And the output should contain:
84
84
  """
85
- expected: non-false value
85
+ expected: truthy value
86
86
  got: false
87
87
  """
88
88
  And the output should contain:
89
89
  """
90
- expected: false value
90
+ expected: falsey value
91
91
  got: true
92
92
  """
93
93
  And the output should contain:
94
94
  """
95
- expected: false value
95
+ expected: falsey value
96
96
  got: 7
97
97
  """
98
98
  And the output should contain:
99
99
  """
100
- expected: false value
100
+ expected: falsey value
101
101
  got: "foo"
102
102
  """
103
103
 
@@ -4,11 +4,11 @@ Feature: be_within matcher
4
4
  Consider this irb session:
5
5
 
6
6
  > radius = 3
7
- => 3
7
+ => 3
8
8
  > area_of_circle = radius * radius * Math::PI
9
- => 28.2743338823081
9
+ => 28.2743338823081
10
10
  > area_of_circle == 28.2743338823081
11
- => false
11
+ => false
12
12
 
13
13
  Instead, you should use the be_within matcher to check that the value
14
14
  is within a delta of your expected value:
@@ -11,14 +11,14 @@ Feature: expect change
11
11
  @count ||= 0
12
12
  @count += 1
13
13
  end
14
-
14
+
15
15
  def count
16
16
  @count ||= 0
17
17
  end
18
18
  end
19
19
  end
20
20
  """
21
-
21
+
22
22
  Scenario: expect change
23
23
  Given a file named "spec/example_spec.rb" with:
24
24
  """ruby
@@ -45,13 +45,13 @@ Feature: expect change
45
45
  require "counter"
46
46
 
47
47
  describe Counter, "#increment" do
48
- it "should not increment the count by 1 (using to_not)" do
49
- expect { Counter.increment }.to_not change{Counter.count}
50
- end
51
-
52
48
  it "should not increment the count by 1 (using not_to)" do
53
49
  expect { Counter.increment }.not_to change{Counter.count}
54
50
  end
51
+
52
+ it "should not increment the count by 1 (using to_not)" do
53
+ expect { Counter.increment }.to_not change{Counter.count}
54
+ end
55
55
  end
56
56
  """
57
57
  When I run `rspec spec/example_spec.rb`
@@ -124,7 +124,7 @@ Feature: raise_error matcher
124
124
  describe Object, "#public_instance_methods" do
125
125
  it "does not raise" do
126
126
  expect { Object.public_instance_methods }.
127
- to_not raise_error(NameError)
127
+ not_to raise_error(NameError)
128
128
  end
129
129
  end
130
130
  """
@@ -136,7 +136,7 @@ Feature: raise_error matcher
136
136
  """
137
137
  describe "#to_s" do
138
138
  it "does not raise" do
139
- expect { Object.new.to_s }.to_not raise_error
139
+ expect { Object.new.to_s }.not_to raise_error
140
140
  end
141
141
  end
142
142
  """
@@ -1,6 +1,6 @@
1
1
  Feature: start_with matcher
2
2
 
3
- Use the `start_with` matcher to specify that a string or array starts with
3
+ Use the `start_with` matcher to specify that a string or array starts with
4
4
  the expected characters or elements.
5
5
 
6
6
  ```ruby
@@ -26,11 +26,11 @@ Feature: throw_symbol matcher
26
26
  describe "throw" do
27
27
  specify { expect { throw :foo }.to throw_symbol }
28
28
  specify { expect { throw :bar, 7 }.to throw_symbol }
29
- specify { expect { 5 + 5 }.to_not throw_symbol }
29
+ specify { expect { 5 + 5 }.not_to throw_symbol }
30
30
 
31
31
  # deliberate failures
32
- specify { expect { throw :foo }.to_not throw_symbol }
33
- specify { expect { throw :bar, 7 }.to_not throw_symbol }
32
+ specify { expect { throw :foo }.not_to throw_symbol }
33
+ specify { expect { throw :bar, 7 }.not_to throw_symbol }
34
34
  specify { expect { 5 + 5 }.to throw_symbol }
35
35
  end
36
36
  """
@@ -47,12 +47,12 @@ Feature: throw_symbol matcher
47
47
  describe "throw symbol" do
48
48
  specify { expect { throw :foo }.to throw_symbol(:foo) }
49
49
  specify { expect { throw :foo, 7 }.to throw_symbol(:foo) }
50
- specify { expect { 5 + 5 }.to_not throw_symbol(:foo) }
51
- specify { expect { throw :bar }.to_not throw_symbol(:foo) }
50
+ specify { expect { 5 + 5 }.not_to throw_symbol(:foo) }
51
+ specify { expect { throw :bar }.not_to throw_symbol(:foo) }
52
52
 
53
53
  # deliberate failures
54
- specify { expect { throw :foo }.to_not throw_symbol(:foo) }
55
- specify { expect { throw :foo, 7 }.to_not throw_symbol(:foo) }
54
+ specify { expect { throw :foo }.not_to throw_symbol(:foo) }
55
+ specify { expect { throw :foo, 7 }.not_to throw_symbol(:foo) }
56
56
  specify { expect { 5 + 5 }.to throw_symbol(:foo) }
57
57
  specify { expect { throw :bar }.to throw_symbol(:foo) }
58
58
  end
@@ -70,12 +70,12 @@ Feature: throw_symbol matcher
70
70
  """ruby
71
71
  describe "throw symbol with argument" do
72
72
  specify { expect { throw :foo, 7 }.to throw_symbol(:foo, 7) }
73
- specify { expect { throw :foo, 8 }.to_not throw_symbol(:foo, 7) }
74
- specify { expect { throw :bar, 7 }.to_not throw_symbol(:foo, 7) }
75
- specify { expect { throw :foo }.to_not throw_symbol(:foo, 7) }
73
+ specify { expect { throw :foo, 8 }.not_to throw_symbol(:foo, 7) }
74
+ specify { expect { throw :bar, 7 }.not_to throw_symbol(:foo, 7) }
75
+ specify { expect { throw :foo }.not_to throw_symbol(:foo, 7) }
76
76
 
77
77
  # deliberate failures
78
- specify { expect { throw :foo, 7 }.to_not throw_symbol(:foo, 7) }
78
+ specify { expect { throw :foo, 7 }.not_to throw_symbol(:foo, 7) }
79
79
  specify { expect { throw :foo, 8 }.to throw_symbol(:foo, 7) }
80
80
  specify { expect { throw :bar, 7 }.to throw_symbol(:foo, 7) }
81
81
  specify { expect { throw :foo }.to throw_symbol(:foo, 7) }
@@ -30,6 +30,10 @@ Feature: yield matchers
30
30
  yield *args
31
31
  end
32
32
 
33
+ def self.yield_twice_with(*args)
34
+ 2.times { yield *args }
35
+ end
36
+
33
37
  def self.raw_yield
34
38
  yield
35
39
  end
@@ -47,17 +51,28 @@ Feature: yield matchers
47
51
  describe "yield_control matcher" do
48
52
  specify { expect { |b| MyClass.yield_once_with(1, &b) }.to yield_control }
49
53
  specify { expect { |b| MyClass.dont_yield(&b) }.not_to yield_control }
54
+ specify { expect { |b| MyClass.yield_twice_with(1, &b) }.to yield_control.twice }
55
+ specify { expect { |b| MyClass.yield_twice_with(1, &b) }.to yield_control.exactly(2).times }
56
+ specify { expect { |b| MyClass.yield_twice_with(1, &b) }.to yield_control.at_least(1) }
57
+ specify { expect { |b| MyClass.yield_twice_with(1, &b) }.to yield_control.at_most(3).times }
50
58
 
51
59
  # deliberate failures
52
60
  specify { expect { |b| MyClass.yield_once_with(1, &b) }.not_to yield_control }
53
61
  specify { expect { |b| MyClass.dont_yield(&b) }.to yield_control }
62
+ specify { expect { |b| MyClass.yield_once_with(1, &b) }.to yield_control.at_least(2).times }
63
+ specify { expect { |b| MyClass.yield_twice_with(1, &b) }.not_to yield_control.twice }
64
+ specify { expect { |b| MyClass.yield_twice_with(1, &b) }.not_to yield_control.at_least(2).times }
65
+ specify { expect { |b| MyClass.yield_twice_with(1, &b) }.not_to yield_control.at_least(1) }
66
+ specify { expect { |b| MyClass.yield_twice_with(1, &b) }.not_to yield_control.at_most(3).times }
54
67
  end
55
68
  """
56
69
  When I run `rspec yield_control_spec.rb`
57
70
  Then the output should contain all of these:
58
- | 4 examples, 2 failures |
59
- | expected given block to yield control |
60
- | expected given block not to yield control |
71
+ | 13 examples, 7 failures |
72
+ | expected given block to yield control |
73
+ | expected given block not to yield control |
74
+ | expected given block not to yield control at least twice |
75
+ | expected given block not to yield control at most 3 times |
61
76
 
62
77
  Scenario: yield_with_args matcher
63
78
  Given a file named "yield_with_args_spec.rb" with:
@@ -12,7 +12,7 @@ Feature: define diffable matcher
12
12
  match do |actual|
13
13
  actual == expected
14
14
  end
15
-
15
+
16
16
  diffable
17
17
  end
18
18
 
@@ -9,19 +9,19 @@ Feature: define matcher outside rspec
9
9
  """ruby
10
10
  require "rspec/expectations"
11
11
  require "test/unit"
12
-
12
+
13
13
  RSpec::Matchers.define :be_a_multiple_of do |expected|
14
14
  match do |actual|
15
15
  actual % expected == 0
16
16
  end
17
17
  end
18
-
18
+
19
19
  class Test::Unit::TestCase
20
20
  include RSpec::Matchers
21
21
  end
22
-
22
+
23
23
  class TestMultiples < Test::Unit::TestCase
24
-
24
+
25
25
  def test_9_should_be_a_multiple_of_3
26
26
  9.should be_a_multiple_of(3)
27
27
  end
@@ -29,10 +29,10 @@ Feature: define matcher outside rspec
29
29
  def test_9_should_be_a_multiple_of_4
30
30
  9.should be_a_multiple_of(4)
31
31
  end
32
-
32
+
33
33
  end
34
34
  """
35
35
  When I run `ruby test_multiples.rb`
36
- Then the exit status should not be 0
36
+ Then the exit status should not be 0
37
37
  And the output should contain "expected 9 to be a multiple of 4"
38
38
  And the output should contain "2 tests, 0 assertions, 0 failures, 1 errors"
@@ -1,7 +1,7 @@
1
1
  Feature: define matcher with fluent interface
2
2
 
3
3
  Use the chain() method to define matchers with a fluent interface.
4
-
4
+
5
5
  Scenario: chained method with argumetn
6
6
  Given a file named "between_spec.rb" with:
7
7
  """ruby
@@ -3,7 +3,7 @@ Feature: customized message
3
3
  RSpec tries to provide useful failure messages, but for cases in which you
4
4
  want more specific information, you can define your own message right in the
5
5
  example. This works for any matcher _other than the operator matchers_.
6
-
6
+
7
7
  Scenario: customize failure message
8
8
  Given a file named "example_spec.rb" with:
9
9
  """ruby
@@ -43,7 +43,7 @@ Feature: diffing
43
43
  actual
44
44
  string
45
45
  ACTUAL
46
- actual.should =~ expected
46
+ expect(actual).to match expected
47
47
  end
48
48
  end
49
49
  """
@@ -20,3 +20,13 @@ Then /^the example should fail$/ do
20
20
  step %q{the output should contain "1 failure"}
21
21
  step %q{the exit status should not be 0}
22
22
  end
23
+
24
+ deprecation_message = /rspec-expectations' built-in integration with (Test::Unit|minitest < 5.x) is deprecated/
25
+
26
+ Then /^the output should contain a deprecation warning about rspec\-expecations' built\-in integration$/ do
27
+ expect(all_output).to match(deprecation_message)
28
+ end
29
+
30
+ Then /^the output should not contain a deprecation warning about rspec\-expecations' built\-in integration$/ do
31
+ expect(all_output).not_to match(deprecation_message)
32
+ end
@@ -1,5 +1,14 @@
1
1
  require 'aruba/cucumber'
2
2
 
3
+ timeouts = { 'java' => 60 }
4
+
3
5
  Before do
4
- @aruba_timeout_seconds = 15
6
+ @aruba_timeout_seconds = timeouts.fetch(RUBY_PLATFORM) { 15 }
5
7
  end
8
+
9
+ Aruba.configure do |config|
10
+ config.before_cmd do |cmd|
11
+ set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}") # disable JIT since these processes are so short lived
12
+ end
13
+ end if RUBY_PLATFORM == 'java'
14
+
@@ -0,0 +1,6 @@
1
+ # Required until https://github.com/rubinius/rubinius/issues/2430 is resolved
2
+ ENV['RBXOPT'] = "#{ENV["RBXOPT"]} -Xcompiler.no_rbc"
3
+
4
+ Around "@unsupported-on-rbx" do |scenario, block|
5
+ block.call unless defined?(Rubinius)
6
+ end
@@ -47,6 +47,9 @@ Feature: Syntax Configuration
47
47
  config.expect_with :rspec do |c|
48
48
  c.syntax = :should
49
49
  end
50
+ config.mock_with :rspec do |c|
51
+ c.syntax = :should
52
+ end
50
53
  end
51
54
  """
52
55
  When I run `rspec disable_expect_syntax.rb syntaxes_spec.rb`