matchi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ee2069fb33d2e5c786aeb935509d74fe06bd36aa
4
+ data.tar.gz: c6b0a6e51939ce2ec05fcde85c69ccb1402c6c05
5
+ SHA512:
6
+ metadata.gz: 40bc336f4b873d366d15b3c38056db15cbb60ba72c3a15e90b37abea3138edd4d43eb538a6423c76e141161101668a9bd9e05551a0d971882010577c85a05b56
7
+ data.tar.gz: 9309449b4039798687500770e399ac9a3935628ef4534af87a43bfb5f3d5fdbde7a79b9a3dba33bb6e5ef9fe0468bfd2358ceb974e3a1450e5746274f971cdcc
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,19 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+ script: 'bundle exec rake test:coverage --trace'
5
+ before_install:
6
+ - gem install bundler
7
+ rvm:
8
+ - ree
9
+ - 1.8.7
10
+ - 1.9.2
11
+ - 1.9.3
12
+ - 2.0
13
+ - 2.1
14
+ - 2.2
15
+ - ruby-head
16
+ - jruby-18mode
17
+ - jruby
18
+ - jruby-head
19
+ - rbx-2
@@ -0,0 +1 @@
1
+ - README.md
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rubysl-irb' if RUBY_ENGINE.eql?('rbx')
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Cyril Wack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,137 @@
1
+ # Matchi
2
+
3
+ [![Build Status](https://travis-ci.org/fixrb/matchi.svg?branch=master)](https://travis-ci.org/fixrb/matchi)
4
+ [![Coverage Status](http://img.shields.io/coveralls/fixrb/matchi.svg?branch=master)](https://coveralls.io/r/fixrb/matchi)
5
+ [![Dependency Status](https://gemnasium.com/fixrb/matchi.svg)](https://gemnasium.com/fixrb/matchi)
6
+ [![Gem Version](http://img.shields.io/gem/v/matchi.svg)](https://rubygems.org/gems/matchi)
7
+ [![Inline docs](http://inch-ci.org/github/fixrb/matchi.svg?branch=master)](http://inch-ci.org/github/fixrb/matchi)
8
+ [![Documentation](http://img.shields.io/:yard-docs-38c800.svg)](http://rubydoc.info/gems/matchi/frames)
9
+
10
+ > Collection of expectation matchers for Ruby.
11
+
12
+ ## Contact
13
+
14
+ * Home page: https://github.com/fixrb/matchi
15
+ * Bugs/issues: https://github.com/fixrb/matchi/issues
16
+ * Support: https://stackoverflow.com/questions/tagged/matchi
17
+
18
+ ## Rubies
19
+
20
+ * [MRI](https://www.ruby-lang.org/)
21
+ * [Rubinius](http://rubini.us/)
22
+ * [JRuby](http://jruby.org/)
23
+
24
+ ## Installation
25
+
26
+ Add this line to your application's Gemfile:
27
+
28
+ ```ruby
29
+ gem 'matchi'
30
+ ```
31
+
32
+ And then execute:
33
+
34
+ $ bundle
35
+
36
+ Or install it yourself as:
37
+
38
+ $ gem install matchi
39
+
40
+ ## Usage
41
+
42
+ ### Built-in matchers
43
+
44
+ **Equivalence** matcher:
45
+
46
+ ```ruby
47
+ eql = Matchi::Eql.new('foo')
48
+ eql.matches? { 'foo' } # => true
49
+ ```
50
+
51
+ **Identity** matcher:
52
+
53
+ ```ruby
54
+ equal = Matchi::Equal.new(:foo)
55
+ equal.matches? { :foo } # => true
56
+ ```
57
+
58
+ **Regular expressions** matcher:
59
+
60
+ ```ruby
61
+ match = Matchi::Match.new(/^foo$/)
62
+ match.matches? { 'foo' } # => true
63
+ ```
64
+
65
+ **Expecting errors** matcher:
66
+
67
+ ```ruby
68
+ raise_exception = Matchi::RaiseException.new(NameError)
69
+ raise_exception.matches? { Boom } # => true
70
+ ```
71
+
72
+ ### Custom matchers
73
+
74
+ Custom matchers can easily be defined for expressing expectations.
75
+
76
+ **Be the answer** matcher:
77
+
78
+ ```ruby
79
+ module Matchi
80
+ class BeTheAnswer
81
+ def matches?
82
+ 42.equal? yield
83
+ end
84
+ end
85
+ end
86
+
87
+ be_the_answer = Matchi::BeTheAnswer.new
88
+ be_the_answer.matches? { 42 } # => true
89
+ ```
90
+
91
+ **Be prime** matcher:
92
+
93
+ ```ruby
94
+ require 'prime'
95
+
96
+ module Matchi
97
+ class BePrime
98
+ def matches?
99
+ Prime.prime? yield
100
+ end
101
+ end
102
+ end
103
+
104
+ be_prime = Matchi::BePrime.new
105
+ be_prime.matches? { 42 } # => false
106
+ ```
107
+
108
+ **Start with** matcher:
109
+
110
+ ```ruby
111
+ module Matchi
112
+ class StartWith
113
+ def initialize expected
114
+ @expected = expected
115
+ end
116
+
117
+ def matches?
118
+ !Regexp.new("^#{@expected}").match(yield).nil?
119
+ end
120
+ end
121
+ end
122
+
123
+ start_with = Matchi::StartWith.new('foo')
124
+ start_with.matches? { 'foobar' } # => true
125
+ ```
126
+
127
+ ## Versioning
128
+
129
+ __Matchi__ follows [Semantic Versioning 2.0](http://semver.org/).
130
+
131
+ ## Contributing
132
+
133
+ 1. [Fork it](https://github.com/fixrb/matchi/fork)
134
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
135
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
136
+ 4. Push to the branch (`git push origin my-new-feature`)
137
+ 5. Create a new Pull Request
@@ -0,0 +1,18 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = File.join 'test', '**', 'test_*.rb'
6
+ t.verbose = true
7
+ t.warning = true
8
+ end
9
+
10
+ namespace :test do
11
+ task :coverage do
12
+ ENV['COVERAGE'] = 'true'
13
+ Rake::Task['test'].invoke
14
+ end
15
+ end
16
+
17
+ task(:doc_stats) { ruby '-S yard stats' }
18
+ task default: [:test, :doc_stats]
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'matchi'
5
+
6
+ require 'irb'
7
+ IRB.start
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
@@ -0,0 +1,10 @@
1
+ require_relative File.join 'matchi', 'eql'
2
+ require_relative File.join 'matchi', 'equal'
3
+ require_relative File.join 'matchi', 'match'
4
+ require_relative File.join 'matchi', 'raise_exception'
5
+
6
+ # Namespace for the Matchi library.
7
+ #
8
+ # @api private
9
+ module Matchi
10
+ end
@@ -0,0 +1,13 @@
1
+ module Matchi
2
+ # **Equivalence** matcher.
3
+ class Eql < BasicObject
4
+ def initialize(expected)
5
+ @expected = expected
6
+ end
7
+
8
+ # @return [Boolean] Comparison between actual and expected values.
9
+ def matches?
10
+ @expected.eql?(yield)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Matchi
2
+ # **Identity** matcher.
3
+ class Equal < BasicObject
4
+ def initialize(expected)
5
+ @expected = expected
6
+ end
7
+
8
+ # @return [Boolean] Comparison between actual and expected values.
9
+ def matches?
10
+ @expected.equal?(yield)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Matchi
2
+ # **Regular expressions** matcher.
3
+ class Match < BasicObject
4
+ def initialize(expected)
5
+ @expected = expected
6
+ end
7
+
8
+ # @return [Boolean] Comparison between actual and expected values.
9
+ def matches?
10
+ @expected.match(yield).nil?.equal?(false)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ module Matchi
2
+ # **Expecting errors** matcher.
3
+ class RaiseException < BasicObject
4
+ def initialize(expected)
5
+ @expected = expected
6
+ end
7
+
8
+ # @return [Boolean] Comparison between actual and expected values.
9
+ def matches?
10
+ yield
11
+ rescue @expected
12
+ true
13
+ else
14
+ false
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'matchi'
3
+ spec.version = File.read('VERSION.semver')
4
+ spec.authors = ['Cyril Wack']
5
+ spec.email = ['contact@cyril.email']
6
+
7
+ spec.summary = 'Collection of matchers.'
8
+ spec.description = 'Collection of expectation matchers for Ruby.'
9
+ spec.homepage = 'https://github.com/fixrb/matchi'
10
+ spec.license = 'MIT'
11
+
12
+ spec.files = `git ls-files -z`.split("\x0")
13
+ .reject { |f| f.match(/^test\//) }
14
+ spec.executables = spec.files.grep(/^exe\//) { |f| File.basename(f) }
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.add_development_dependency 'bundler', '~> 1.8'
18
+ spec.add_development_dependency 'rake', '~> 10.0'
19
+ spec.add_development_dependency 'yard', '~> 0.8'
20
+ spec.add_development_dependency 'coveralls', '~> 0.7'
21
+ spec.add_development_dependency 'rubocop', '~> 0.29'
22
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: matchi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Cyril Wack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.29'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.29'
83
+ description: Collection of expectation matchers for Ruby.
84
+ email:
85
+ - contact@cyril.email
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".coveralls.yml"
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - ".yardopts"
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE.md
97
+ - README.md
98
+ - Rakefile
99
+ - VERSION.semver
100
+ - bin/console
101
+ - bin/setup
102
+ - lib/matchi.rb
103
+ - lib/matchi/eql.rb
104
+ - lib/matchi/equal.rb
105
+ - lib/matchi/match.rb
106
+ - lib/matchi/raise_exception.rb
107
+ - matchi.gemspec
108
+ homepage: https://github.com/fixrb/matchi
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.4.5
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Collection of matchers.
132
+ test_files: []
133
+ has_rdoc: