rspec-collection_matchers 0.0.1.pre → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -15
- data/.rspec +2 -0
- data/.travis.yml +17 -0
- data/Gemfile +15 -1
- data/LICENSE.txt +7 -2
- data/README.md +49 -11
- data/Rakefile +18 -1
- data/features/have.feature +113 -0
- data/features/support/env.rb +21 -0
- data/lib/rspec/collection_matchers.rb +3 -0
- data/lib/rspec/collection_matchers/have.rb +122 -0
- data/lib/rspec/collection_matchers/matchers.rb +62 -0
- data/lib/rspec/collection_matchers/version.rb +5 -0
- data/rspec-collection_matchers.gemspec +19 -14
- data/script/test_all +21 -0
- data/spec/rspec/collection_matchers/have_spec.rb +487 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/classes.rb +56 -0
- data/spec/support/matchers.rb +23 -0
- data/spec/support/shared_examples.rb +12 -0
- metadata +66 -21
- data/lib/rspec-collection_matchers.rb +0 -7
- data/lib/rspec-collection_matchers/version.rb +0 -5
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rspec/collection_matchers'
|
2
|
+
|
3
|
+
Dir['./spec/support/**/*'].each {|f| require f}
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
7
|
+
config.run_all_when_everything_filtered = true
|
8
|
+
config.filter_run :focus
|
9
|
+
|
10
|
+
config.order = 'random'
|
11
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# various classes used by the specs
|
2
|
+
module RSpec
|
3
|
+
module Expectations
|
4
|
+
module Helper
|
5
|
+
class CollectionWithSizeMethod
|
6
|
+
def initialize; @list = []; end
|
7
|
+
def size; @list.size; end
|
8
|
+
def push(item); @list.push(item); end
|
9
|
+
end
|
10
|
+
|
11
|
+
class CollectionWithLengthMethod
|
12
|
+
def initialize; @list = []; end
|
13
|
+
def length; @list.size; end
|
14
|
+
def push(item); @list.push(item); end
|
15
|
+
end
|
16
|
+
|
17
|
+
class CollectionWithCountMethod
|
18
|
+
def initialize; @list = []; end
|
19
|
+
def count; @list.count; end
|
20
|
+
def push(item); @list.push(item); end
|
21
|
+
end
|
22
|
+
|
23
|
+
class CollectionOwner
|
24
|
+
attr_reader :items_in_collection_with_size_method, :items_in_collection_with_length_method, :items_in_collection_with_count_method
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@items_in_collection_with_size_method = CollectionWithSizeMethod.new
|
28
|
+
@items_in_collection_with_length_method = CollectionWithLengthMethod.new
|
29
|
+
@items_in_collection_with_count_method = CollectionWithCountMethod.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_to_collection_with_size_method(item)
|
33
|
+
@items_in_collection_with_size_method.push(item)
|
34
|
+
end
|
35
|
+
|
36
|
+
def add_to_collection_with_length_method(item)
|
37
|
+
@items_in_collection_with_length_method.push(item)
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_to_collection_with_count_method(item)
|
41
|
+
@items_in_collection_with_count_method.push(item)
|
42
|
+
end
|
43
|
+
|
44
|
+
def items_for(arg)
|
45
|
+
return [1, 2, 3] if arg == 'a'
|
46
|
+
[1]
|
47
|
+
end
|
48
|
+
|
49
|
+
def items
|
50
|
+
@items_in_collection_with_size_method
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rspec-expectations'
|
2
|
+
|
3
|
+
RSpec::Matchers.define :include_method do |expected|
|
4
|
+
match do |actual|
|
5
|
+
actual.map { |m| m.to_s }.include?(expected.to_s)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module RSpec
|
10
|
+
module Matchers
|
11
|
+
def fail
|
12
|
+
raise_error(RSpec::Expectations::ExpectationNotMetError)
|
13
|
+
end
|
14
|
+
|
15
|
+
def fail_with(message)
|
16
|
+
raise_error(RSpec::Expectations::ExpectationNotMetError, message)
|
17
|
+
end
|
18
|
+
|
19
|
+
def fail_matching(message)
|
20
|
+
raise_error(RSpec::Expectations::ExpectationNotMetError, /#{Regexp.escape(message)}/)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
shared_examples_for "an RSpec matcher" do |options|
|
2
|
+
let(:valid_value) { options.fetch(:valid_value) }
|
3
|
+
let(:invalid_value) { options.fetch(:invalid_value) }
|
4
|
+
|
5
|
+
it 'matches a valid value when using #== so it can be composed' do
|
6
|
+
expect(matcher).to eq(valid_value)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'does not match an invalid value when using #== so it can be composed' do
|
10
|
+
expect(matcher).not_to eq(invalid_value)
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,54 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-collection_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
5
|
-
prerelease: 6
|
4
|
+
version: 0.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
|
-
-
|
7
|
+
- Hugo Baraúna
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-07
|
13
|
-
dependencies:
|
14
|
-
|
11
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec-expectations
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.99.0.pre
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.99.0.pre
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
description: Collection cardinality matchers, extracted from rspec-expectations
|
15
42
|
email:
|
16
|
-
-
|
43
|
+
- hugo.barauna@plataformatec.com.br
|
17
44
|
executables: []
|
18
45
|
extensions: []
|
19
46
|
extra_rdoc_files: []
|
20
47
|
files:
|
21
48
|
- .gitignore
|
49
|
+
- .rspec
|
50
|
+
- .travis.yml
|
22
51
|
- Gemfile
|
23
52
|
- LICENSE.txt
|
24
53
|
- README.md
|
25
54
|
- Rakefile
|
26
|
-
-
|
27
|
-
-
|
55
|
+
- features/have.feature
|
56
|
+
- features/support/env.rb
|
57
|
+
- lib/rspec/collection_matchers.rb
|
58
|
+
- lib/rspec/collection_matchers/have.rb
|
59
|
+
- lib/rspec/collection_matchers/matchers.rb
|
60
|
+
- lib/rspec/collection_matchers/version.rb
|
28
61
|
- rspec-collection_matchers.gemspec
|
29
|
-
|
30
|
-
|
62
|
+
- script/test_all
|
63
|
+
- spec/rspec/collection_matchers/have_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
- spec/support/classes.rb
|
66
|
+
- spec/support/matchers.rb
|
67
|
+
- spec/support/shared_examples.rb
|
68
|
+
homepage: https://github.com/rspec/rspec-collection_matchers
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
31
72
|
post_install_message:
|
32
73
|
rdoc_options: []
|
33
74
|
require_paths:
|
34
75
|
- lib
|
35
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
36
77
|
requirements:
|
37
|
-
- -
|
78
|
+
- - '>='
|
38
79
|
- !ruby/object:Gem::Version
|
39
80
|
version: '0'
|
40
|
-
none: false
|
41
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
82
|
requirements:
|
43
|
-
- -
|
83
|
+
- - '>='
|
44
84
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
46
|
-
none: false
|
85
|
+
version: '0'
|
47
86
|
requirements: []
|
48
87
|
rubyforge_project:
|
49
|
-
rubygems_version:
|
88
|
+
rubygems_version: 2.0.3
|
50
89
|
signing_key:
|
51
|
-
specification_version:
|
52
|
-
summary:
|
53
|
-
test_files:
|
54
|
-
|
90
|
+
specification_version: 4
|
91
|
+
summary: rspec-collection_matchers-0.0.1
|
92
|
+
test_files:
|
93
|
+
- features/have.feature
|
94
|
+
- features/support/env.rb
|
95
|
+
- spec/rspec/collection_matchers/have_spec.rb
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
- spec/support/classes.rb
|
98
|
+
- spec/support/matchers.rb
|
99
|
+
- spec/support/shared_examples.rb
|