rspec-collection_matchers 0.0.1.pre → 0.0.1

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.
@@ -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.pre
5
- prerelease: 6
4
+ version: 0.0.1
6
5
  platform: ruby
7
6
  authors:
8
- - Myron Marston
7
+ - Hugo Baraúna
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-15 00:00:00.000000000 Z
13
- dependencies: []
14
- description: ''
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
- - myron.marston@gmail.com
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
- - lib/rspec-collection_matchers.rb
27
- - lib/rspec-collection_matchers/version.rb
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
- homepage: ''
30
- licenses: []
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: 1.3.1
46
- none: false
85
+ version: '0'
47
86
  requirements: []
48
87
  rubyforge_project:
49
- rubygems_version: 1.8.24
88
+ rubygems_version: 2.0.3
50
89
  signing_key:
51
- specification_version: 3
52
- summary: Collection cardinality matchers, extracted from rspec-expectations
53
- test_files: []
54
- has_rdoc:
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
@@ -1,7 +0,0 @@
1
- require "rspec-collection_matchers/version"
2
-
3
- module Rspec
4
- module CollectionMatchers
5
- # Your code goes here...
6
- end
7
- end
@@ -1,5 +0,0 @@
1
- module Rspec
2
- module CollectionMatchers
3
- VERSION = "0.0.1.pre"
4
- end
5
- end