limit_detectors 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +8 -6
- data/Gemfile +2 -1
- data/README.md +8 -7
- data/lib/limit_detectors/version.rb +1 -1
- data/lib/limit_detectors.rb +1 -1
- data/limit_detectors.gemspec +4 -4
- data/spec/limit_detectors_spec.rb +22 -22
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bfeb23a1532e16e237e63c348f1daccf83dde17
|
4
|
+
data.tar.gz: bcf2d367841832e8517250a85992cfaa7583ba2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 484a1bb78bf51122fe69ff9867fecf5e3c2623e81c3b8d6690543f3c7e64cb0789770661ed1371c93496cba161017be762d5190b67b87b2f789280555279a0dc
|
7
|
+
data.tar.gz: 45d8da7f52c723f25d502f67382279b9f141915fbe2f2045580d146b3ee4428a754789f24a1a4330eb75e84e84ccd51a9d14c808682248d653955adcb1d38057
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -48,13 +48,14 @@ may not be compatible with the current version.
|
|
48
48
|
|
49
49
|
This gem is tested with these (MRI) Ruby versions:
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
51
|
+
- 1.9.3
|
52
|
+
- 1.8.7
|
53
|
+
- 2.0
|
54
|
+
- 2.1
|
55
|
+
- 2.2.2
|
56
|
+
- jruby
|
57
|
+
|
58
|
+
as well as a current version of JRuby.
|
58
59
|
|
59
60
|
## Contributing
|
60
61
|
|
data/lib/limit_detectors.rb
CHANGED
data/limit_detectors.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'limit_detectors/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'limit_detectors'
|
8
8
|
spec.version = LimitDetectors::VERSION
|
9
|
-
spec.authors = ['Stephan
|
9
|
+
spec.authors = ['Stephan Kämper']
|
10
10
|
spec.email = ['the.tester@seasidetesting.com']
|
11
11
|
spec.summary = %q{Detect certain conditions of elements of an Enumerable object}
|
12
12
|
spec.description = %q{Some methods to detect whether an Enumerable object contains a constrained number of elements that match a given condition.}
|
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency 'bundler'
|
22
|
-
spec.add_development_dependency 'rake'
|
23
|
-
spec.add_development_dependency 'rspec'
|
24
|
-
spec.add_development_dependency 'pry'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.4'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
24
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
25
25
|
spec.add_development_dependency 'pry-doc'
|
26
26
|
end
|
@@ -7,14 +7,14 @@ describe '#at_most' do
|
|
7
7
|
|
8
8
|
it 'is true for an empty Array' do
|
9
9
|
expect(Kernel).to_not receive(:warn)
|
10
|
-
expect([].at_most?(5){ true }).to
|
11
|
-
expect([].at_most?(0){ true }).to
|
12
|
-
expect([].at_most?(1){ true }).to
|
13
|
-
expect([].at_most?(5){ :foo }).to
|
10
|
+
expect([].at_most?(5){ true }).to be_truthy
|
11
|
+
expect([].at_most?(0){ true }).to be_truthy
|
12
|
+
expect([].at_most?(1){ true }).to be_truthy
|
13
|
+
expect([].at_most?(5){ :foo }).to be_truthy
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'is true if the criterion is met once' do
|
17
|
-
expect(["it's there"].at_most?(1){ |el| el == "it's there"}).to
|
17
|
+
expect(["it's there"].at_most?(1){ |el| el == "it's there"}).to be_truthy
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'is true if all elements meet the criterion and the size is the given maximum number' do
|
@@ -22,19 +22,19 @@ describe '#at_most' do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'is false if not enough elements meet the criterion' do
|
25
|
-
expect([1, 2, 4].at_most?(1){|e| e.even?}).to
|
25
|
+
expect([1, 2, 4].at_most?(1){|e| e.even?}).to be_falsey
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'is true if 0 elements are expected to match' do
|
29
29
|
r = Array.new(10){rand}
|
30
|
-
expect(r.at_most?(0){ |i| i > 2 }).to
|
30
|
+
expect(r.at_most?(0){ |i| i > 2 }).to be_truthy
|
31
31
|
end
|
32
32
|
|
33
33
|
describe 'Hash#at_most' do
|
34
34
|
Hash.send :include, LimitDetectors
|
35
35
|
it 'detects a condition based on key as well as value properties' do
|
36
36
|
h = { 'foo' => 1, 'bar' => 4, 'baz' => 5, 'bum' => 1, 'fum' => 0}
|
37
|
-
expect( h.at_most?(3){|ky,vl| ky.match(/^b/) || vl > 1 }).to
|
37
|
+
expect( h.at_most?(3){|ky,vl| ky.match(/^b/) || vl > 1 }).to be_truthy
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -44,47 +44,47 @@ describe '#at_least' do
|
|
44
44
|
|
45
45
|
it 'is false for an empty Array, if at least one is expected' do
|
46
46
|
expect(Kernel).to_not receive(:warn)
|
47
|
-
expect([].at_least?(1){ true }).to
|
47
|
+
expect([].at_least?(1){ true }).to be_falsey
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'is true if the expected number is 0 and Array is empty' do
|
51
|
-
expect([].at_least?(0){ true }).to
|
52
|
-
expect({}.at_least?(0){ false }).to
|
51
|
+
expect([].at_least?(0){ true }).to be_truthy
|
52
|
+
expect({}.at_least?(0){ false }).to be_truthy
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'is false if the container ist smaller than the expected number' do
|
56
56
|
size = 10
|
57
|
-
expect(Array.new(10).at_least?(size + 1){true}).to
|
57
|
+
expect(Array.new(10).at_least?(size + 1){true}).to be_falsey
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'is true if the criterion is met and expected once' do
|
61
|
-
expect(["it's there"].at_least?(1){ |el| el == "it's there"}).to
|
61
|
+
expect(["it's there"].at_least?(1){ |el| el == "it's there"}).to be_truthy
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'is false for an empty Array if you expect at leat 1' do
|
65
|
-
expect([].at_least?(1){ true }).to
|
65
|
+
expect([].at_least?(1){ true }).to be_falsey
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'is true for an empty Array if you expect at leat 0' do
|
69
|
-
expect([].at_least?(0){ }).to
|
69
|
+
expect([].at_least?(0){ }).to be_truthy
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'is true if the criterion is met once' do
|
73
|
-
expect(["it's there"].at_least?(1){ |el| el == "it's there"}).to
|
73
|
+
expect(["it's there"].at_least?(1){ |el| el == "it's there"}).to be_truthy
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'is true if all elements meet the criterion and the size is the given minimum number' do
|
77
|
-
expect([1,1,1].at_least?(3){|e| e == 1}).to
|
77
|
+
expect([1,1,1].at_least?(3){|e| e == 1}).to be_truthy
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'is true if enough elements meet the criterion' do
|
81
|
-
expect([1, 2, 4, 8].at_least?(2){|e| e.even?}).to
|
81
|
+
expect([1, 2, 4, 8].at_least?(2){|e| e.even?}).to be_truthy
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'is true if there are enough elements to match' do
|
85
85
|
r = Array.new(10){|i|i}
|
86
|
-
expect(r.at_least?(7){ |i| i > 2 }).to
|
87
|
-
expect(r.at_least?(8){ |i| i > 2 }).to
|
86
|
+
expect(r.at_least?(7){ |i| i > 2 }).to be_truthy
|
87
|
+
expect(r.at_least?(8){ |i| i > 2 }).to be_falsey
|
88
88
|
end
|
89
89
|
|
90
90
|
end
|
@@ -112,10 +112,10 @@ describe '#ocurrences_of' do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
|
115
|
-
describe 'Using an object that doesn\'t respond to #inject
|
115
|
+
describe 'Using an object that doesn\'t respond to #inject' do
|
116
116
|
object = Object.new
|
117
117
|
object.extend LimitDetectors
|
118
|
-
it 'will raise an exception, if it\'s sent #
|
118
|
+
it 'will raise an exception, if it\'s sent #at_most' do
|
119
119
|
expect{ object.at_most?(1){ |el| el.condition? } }.to raise_exception(NoMethodError, /undefined method .inject./)
|
120
120
|
end
|
121
121
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: limit_detectors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Stephan
|
7
|
+
- Stephan Kämper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,44 +28,44 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '10.4'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '10.4'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '3.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '0.10'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '0.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry-doc
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.4.8
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Detect certain conditions of elements of an Enumerable object
|