rspec-expectations 2.6.0.rc4 → 2.6.0.rc6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,10 @@
1
- default: --require features --tags ~@wip --format progress
2
- wip: --require features --tags @wip:3 --wip features
1
+ <%
2
+ def tags(tag)
3
+ tags = [tag]
4
+ tags << "~@ruby-1.9" if RUBY_VERSION.to_f < 1.9
5
+ tags.join(" --tags ")
6
+ end
7
+ %>
3
8
 
9
+ default: --require features --tags <%= tags("~@wip") %> --format progress
10
+ wip: --require features --tags <%= tags("@wip:3") --wip features
@@ -1,7 +1,16 @@
1
+ ### 2.6.0.rc6 / 2011-05-06
2
+
3
+ [full changelog](http://github.com/rspec/rspec-expectations/compare/v2.6.0.rc4...v2.6.0.rc6)
4
+
5
+ No changes this release (releasing to align with rc5 of other rspec gems).
6
+
1
7
  ### 2.6.0.rc4 / 2011-05-01
2
8
 
3
9
  [full changelog](http://github.com/rspec/rspec-expectations/compare/v2.6.0.rc2...v2.6.0.rc4)
4
10
 
11
+ * Enhancements
12
+ * range.should cover(*values) (Anders Furseth)
13
+
5
14
  ### 2.6.0.rc2 / 2011-04-18
6
15
 
7
16
  [full changelog](http://github.com/rspec/rspec-expectations/compare/v2.5.0...v2.6.0.rc2)
@@ -65,3 +65,7 @@
65
65
  [1,2,3].should include(1, 2)
66
66
  {:a => 'b'}.should include(:a => 'b')
67
67
  "this string".should include("is str")
68
+
69
+ ## Ranges (1.9 only)
70
+
71
+ (1..10).should cover(3)
@@ -0,0 +1,45 @@
1
+ @ruby-1.9
2
+ Feature: cover matcher
3
+
4
+ Use the cover matcher to specify that a range covers one or more
5
+ expected objects. This works on any object that responds to #cover? (such
6
+ as a Range):
7
+
8
+ (1..10).should cover(5)
9
+ (1..10).should cover(4, 6)
10
+ (1..10).should_not cover(11)
11
+
12
+ Scenario: range usage
13
+ Given a file named "range_cover_matcher_spec.rb" with:
14
+ """
15
+ describe (1..10) do
16
+ it { should cover(4) }
17
+ it { should cover(6) }
18
+ it { should cover(8) }
19
+ it { should cover(4, 6) }
20
+ it { should cover(4, 6, 8) }
21
+ it { should_not cover(11) }
22
+ it { should_not cover(11, 12) }
23
+
24
+ # deliberate failures
25
+ it { should cover(11) }
26
+ it { should_not cover(4) }
27
+ it { should_not cover(6) }
28
+ it { should_not cover(8) }
29
+ it { should_not cover(4, 6, 8) }
30
+
31
+ # both of these should fail since it covers 1 but not 9
32
+ it { should cover(5, 11) }
33
+ it { should_not cover(5, 11) }
34
+ end
35
+ """
36
+ When I run `rspec range_cover_matcher_spec.rb`
37
+ Then the output should contain all of these:
38
+ | 14 examples, 7 failures |
39
+ | expected 1..10 to cover 11 |
40
+ | expected 1..10 not to cover 4 |
41
+ | expected 1..10 not to cover 6 |
42
+ | expected 1..10 not to cover 8 |
43
+ | expected 1..10 not to cover 4, 6, and 8 |
44
+ | expected 1..10 to cover 5 and 11 |
45
+ | expected 1..10 not to cover 5 and 11 |
@@ -1,7 +1,7 @@
1
1
  module RSpec # :nodoc:
2
2
  module Expectations # :nodoc:
3
3
  module Version # :nodoc:
4
- STRING = '2.6.0.rc4'
4
+ STRING = '2.6.0.rc6'
5
5
  end
6
6
  end
7
7
  end
@@ -181,6 +181,7 @@ require 'rspec/matchers/be_kind_of'
181
181
  require 'rspec/matchers/be_within'
182
182
  require 'rspec/matchers/block_aliases'
183
183
  require 'rspec/matchers/change'
184
+ require 'rspec/matchers/cover' if (1..2).respond_to? :cover?
184
185
  require 'rspec/matchers/eq'
185
186
  require 'rspec/matchers/eql'
186
187
  require 'rspec/matchers/equal'
@@ -0,0 +1,35 @@
1
+ module RSpec
2
+ module Matchers
3
+ # :call-seq:
4
+ # should cover(expected)
5
+ # should_not cover(expected)
6
+ #
7
+ # Passes if actual covers expected. This works for
8
+ # Ranges. You can also pass in multiple args
9
+ # and it will only pass if all args are found in Range.
10
+ #
11
+ # == Examples
12
+ # (1..10).should cover(5)
13
+ # (1..10).should cover(4, 6)
14
+ # (1..10).should cover(4, 6, 11) # will fail
15
+ # (1..10).should_not cover(11)
16
+ # (1..10).should_not cover(5) # will fail
17
+ #
18
+ # == Warning: Ruby >= 1.9 only
19
+ def cover(*expected_values)
20
+ Matcher.new :cover, *expected_values do |*_expected_values|
21
+ match_for_should do |actual|
22
+ _expected_values.all? &cover_value
23
+ end
24
+
25
+ match_for_should_not do |actual|
26
+ _expected_values.none? &cover_value
27
+ end
28
+
29
+ def cover_value
30
+ lambda {|value| actual.cover?(value)}
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe "should cover(expected)", :if => RSpec::Matchers.respond_to?(:cover) do
4
+ context "for a range target" do
5
+ it "passes if target covers expected" do
6
+ (1..10).should cover(5)
7
+ end
8
+
9
+ it "fails if target does not cover expected" do
10
+ lambda {
11
+ (1..10).should cover(11)
12
+ }.should fail_with("expected 1..10 to cover 11")
13
+ end
14
+ end
15
+ end
16
+
17
+ describe "should cover(with, multiple, args)", :if => RSpec::Matchers.respond_to?(:cover) do
18
+ context "for a range target" do
19
+ it "passes if target covers all items" do
20
+ (1..10).should cover(4, 6)
21
+ end
22
+
23
+ it "fails if target does not cover any one of the items" do
24
+ lambda {
25
+ (1..10).should cover(4, 6, 11)
26
+ }.should fail_with("expected 1..10 to cover 4, 6, and 11")
27
+ end
28
+ end
29
+ end
30
+
31
+ describe "should_not cover(expected)", :if => RSpec::Matchers.respond_to?(:cover) do
32
+ context "for a range target" do
33
+ it "passes if target does not cover expected" do
34
+ (1..10).should_not cover(11)
35
+ end
36
+
37
+ it "fails if target covers expected" do
38
+ lambda {
39
+ (1..10).should_not cover(5)
40
+ }.should fail_with("expected 1..10 not to cover 5")
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "should_not cover(with, multiple, args)", :if => RSpec::Matchers.respond_to?(:cover) do
46
+ context "for a range target" do
47
+ it "passes if the target does not cover any of the expected" do
48
+ (1..10).should_not include(11, 12, 13)
49
+ end
50
+
51
+ it "fails if the target covers all of the expected" do
52
+ expect {
53
+ (1..10).should_not include(4, 6)
54
+ }.to fail_with("expected 1..10 not to include 4 and 6")
55
+ end
56
+
57
+ it "fails if the target covers some (but not all) of the expected" do
58
+ expect {
59
+ (1..10).should_not include(5, 11)
60
+ }.to fail_with("expected 1..10 not to include 5 and 11")
61
+ end
62
+ end
63
+ end
64
+
65
+
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-expectations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424061
4
+ hash: 15424057
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 2
8
8
  - 6
9
9
  - 0
10
10
  - rc
11
- - 4
12
- version: 2.6.0.rc4
11
+ - 6
12
+ version: 2.6.0.rc6
13
13
  platform: ruby
14
14
  authors:
15
15
  - David Chelimsky
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-05-01 00:00:00 -04:00
21
+ date: 2011-05-06 00:00:00 -05:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -62,6 +62,7 @@ files:
62
62
  - features/built_in_matchers/README.md
63
63
  - features/built_in_matchers/be.feature
64
64
  - features/built_in_matchers/be_within.feature
65
+ - features/built_in_matchers/cover.feature
65
66
  - features/built_in_matchers/equality.feature
66
67
  - features/built_in_matchers/exist.feature
67
68
  - features/built_in_matchers/expect_change.feature
@@ -107,6 +108,7 @@ files:
107
108
  - lib/rspec/matchers/block_aliases.rb
108
109
  - lib/rspec/matchers/change.rb
109
110
  - lib/rspec/matchers/compatibility.rb
111
+ - lib/rspec/matchers/cover.rb
110
112
  - lib/rspec/matchers/dsl.rb
111
113
  - lib/rspec/matchers/eq.rb
112
114
  - lib/rspec/matchers/eql.rb
@@ -140,6 +142,7 @@ files:
140
142
  - spec/rspec/matchers/be_within_spec.rb
141
143
  - spec/rspec/matchers/change_spec.rb
142
144
  - spec/rspec/matchers/compatibility_spec.rb
145
+ - spec/rspec/matchers/cover_spec.rb
143
146
  - spec/rspec/matchers/description_generation_spec.rb
144
147
  - spec/rspec/matchers/dsl_spec.rb
145
148
  - spec/rspec/matchers/eq_spec.rb
@@ -199,7 +202,7 @@ rubyforge_project: rspec
199
202
  rubygems_version: 1.6.2
200
203
  signing_key:
201
204
  specification_version: 3
202
- summary: rspec-expectations-2.6.0.rc4
205
+ summary: rspec-expectations-2.6.0.rc6
203
206
  test_files:
204
207
  - features/Changelog.md
205
208
  - features/README.markdown
@@ -207,6 +210,7 @@ test_files:
207
210
  - features/built_in_matchers/README.md
208
211
  - features/built_in_matchers/be.feature
209
212
  - features/built_in_matchers/be_within.feature
213
+ - features/built_in_matchers/cover.feature
210
214
  - features/built_in_matchers/equality.feature
211
215
  - features/built_in_matchers/exist.feature
212
216
  - features/built_in_matchers/expect_change.feature
@@ -242,6 +246,7 @@ test_files:
242
246
  - spec/rspec/matchers/be_within_spec.rb
243
247
  - spec/rspec/matchers/change_spec.rb
244
248
  - spec/rspec/matchers/compatibility_spec.rb
249
+ - spec/rspec/matchers/cover_spec.rb
245
250
  - spec/rspec/matchers/description_generation_spec.rb
246
251
  - spec/rspec/matchers/dsl_spec.rb
247
252
  - spec/rspec/matchers/eq_spec.rb