matchi 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2112c16da9d008dbe0c5ff3b62756b0fdebd2b4
4
- data.tar.gz: 91fcdf7bac95139ea1c5ae149c54e12902c85fe5
3
+ metadata.gz: 5226fc19f2e63316899fb88819e4a2b676706067
4
+ data.tar.gz: e384838e1758ff5ea04813a13c860fdbabcbd6e8
5
5
  SHA512:
6
- metadata.gz: 492a24a9cf62fd1ddbcd50dfec9e9ec304c75dc0aee3eec40324a890b42491b9c0448aa07c2287c9fbcb4685be6b05bd24d0305ae15b68f5030d0d243ead6ee9
7
- data.tar.gz: a46f7f36dc216905c76048d03cdd2a01ac1151fd26ee592e62b691ab3c07c2c55a6cac86304975588f00f6d6c6d7b15f613f62a6d1c86b6a409199aa8d9bf6be
6
+ metadata.gz: 0f768ac33f6d8cd00f7bcca104463f7ea377a4291300971d96b79bb1e1fb40421c267aa497c07dd74d98cbc5ccb144a8f6a4dca76f7f587549411434e30af329
7
+ data.tar.gz: 912d5c53cc20d09270bdd928d67251e744983ce4d69c2b88eff996b1d179c622fd2be84344a688c0a9e6e6434479a1b92fb108e1e12cf3214516507447d77294
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /.ruby-version
2
3
  /.yardoc
3
4
  /Gemfile.lock
4
5
  /_yardoc/
data/README.md CHANGED
@@ -38,7 +38,7 @@ Or install it yourself as:
38
38
 
39
39
  ## Usage
40
40
 
41
- List all available matchers:
41
+ ### List all matchers
42
42
 
43
43
  ```ruby
44
44
  Matchi.constants # => [:BeFalse, :BeNil, :BeTrue, :Eql, :Equal, :Match, :RaiseException]
@@ -161,3 +161,7 @@ __Matchi__ follows [Semantic Versioning 2.0](http://semver.org/).
161
161
  3. Commit your changes (`git commit -am 'Add some feature'`)
162
162
  4. Push to the branch (`git push origin my-new-feature`)
163
163
  5. Create a new Pull Request
164
+
165
+ ## License
166
+
167
+ See `LICENSE.md` file.
data/Rakefile CHANGED
@@ -2,7 +2,6 @@ require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new do |t|
5
- t.pattern = File.join 'test', '**', 'test_*.rb'
6
5
  t.verbose = true
7
6
  t.warning = true
8
7
  end
data/VERSION.semver CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
data/lib/matchi.rb CHANGED
@@ -12,8 +12,8 @@ end
12
12
  module Matchi
13
13
  # Select a matcher from those available.
14
14
  #
15
- # @param [Symbol] matcher_id the name of the constant of the matcher to fetch
16
- # @param [Array] args parameters to initialize the class of the matcher
15
+ # @param matcher_id [Symbol] The name of the constant of the matcher to fetch.
16
+ # @param args [Array] Parameters to initialize the class of the matcher.
17
17
  #
18
18
  # @return [#matches?] the matcher
19
19
  def self.fetch(matcher_id, *args)
@@ -5,6 +5,8 @@ module Matchi
5
5
  # be_false = Matchi::BeFalse.new
6
6
  # be_false.matches? { false } # => true
7
7
  #
8
+ # @yieldreturn [#object_id] the actual value to compare to the expected one.
9
+ #
8
10
  # @return [Boolean] Comparison between actual and expected values.
9
11
  def matches?
10
12
  false.equal?(yield)
data/lib/matchi/be_nil.rb CHANGED
@@ -5,6 +5,8 @@ module Matchi
5
5
  # be_nil = Matchi::BeNil.new
6
6
  # be_nil.matches? { nil } # => true
7
7
  #
8
+ # @yieldreturn [#object_id] the actual value to compare to the expected one.
9
+ #
8
10
  # @return [Boolean] Comparison between actual and expected values.
9
11
  def matches?
10
12
  nil.equal?(yield)
@@ -5,6 +5,8 @@ module Matchi
5
5
  # be_true = Matchi::BeTrue.new
6
6
  # be_true.matches? { true } # => true
7
7
  #
8
+ # @yieldreturn [#object_id] the actual value to compare to the expected one.
9
+ #
8
10
  # @return [Boolean] Comparison between actual and expected values.
9
11
  def matches?
10
12
  true.equal?(yield)
data/lib/matchi/eql.rb CHANGED
@@ -6,7 +6,7 @@ module Matchi
6
6
  # @example The string 'foo' matcher
7
7
  # Matchi::Eql.new('foo')
8
8
  #
9
- # @param [#eql?] expected an expected equivalent object
9
+ # @param expected [#eql?] An expected equivalent object.
10
10
  def initialize(expected)
11
11
  @expected = expected
12
12
  end
@@ -15,6 +15,8 @@ module Matchi
15
15
  # eql = Matchi::Eql.new('foo')
16
16
  # eql.matches? { 'foo' } # => true
17
17
  #
18
+ # @yieldreturn [#object_id] the actual value to compare to the expected one.
19
+ #
18
20
  # @return [Boolean] Comparison between actual and expected values.
19
21
  def matches?
20
22
  @expected.eql?(yield)
data/lib/matchi/equal.rb CHANGED
@@ -6,7 +6,7 @@ module Matchi
6
6
  # @example The number 42 matcher
7
7
  # Matchi::Equal.new(42)
8
8
  #
9
- # @param [#equal?] expected an expected object
9
+ # @param expected [#equal?] An expected object.
10
10
  def initialize(expected)
11
11
  @expected = expected
12
12
  end
@@ -15,6 +15,8 @@ module Matchi
15
15
  # equal = Matchi::Equal.new(:foo)
16
16
  # equal.matches? { :foo } # => true
17
17
  #
18
+ # @yieldreturn [#object_id] the actual value to compare to the expected one.
19
+ #
18
20
  # @return [Boolean] Comparison between actual and expected values.
19
21
  def matches?
20
22
  @expected.equal?(yield)
data/lib/matchi/match.rb CHANGED
@@ -6,7 +6,7 @@ module Matchi
6
6
  # @example Username matcher
7
7
  # Matchi::Match.new(/^[a-z0-9_-]{3,16}$/)
8
8
  #
9
- # @param [#match] expected a regular expression
9
+ # @param expected [#match] A regular expression.
10
10
  def initialize(expected)
11
11
  @expected = expected
12
12
  end
@@ -15,6 +15,8 @@ module Matchi
15
15
  # match = Matchi::Match.new(/^foo$/)
16
16
  # match.matches? { 'foo' } # => true
17
17
  #
18
+ # @yieldreturn [#object_id] the actual value to compare to the expected one.
19
+ #
18
20
  # @return [Boolean] Comparison between actual and expected values.
19
21
  def matches?
20
22
  @expected.match(yield).nil?.equal?(false)
@@ -6,7 +6,7 @@ module Matchi
6
6
  # @example Divided by 0 matcher
7
7
  # Matchi::RaiseException.new(ZeroDivisionError)
8
8
  #
9
- # @param [.exception] expected the class of the expected exception
9
+ # @param expected [.exception] The class of the expected exception.
10
10
  def initialize(expected)
11
11
  @expected = expected
12
12
  end
@@ -15,6 +15,8 @@ module Matchi
15
15
  # raise_exception = Matchi::RaiseException.new(NameError)
16
16
  # raise_exception.matches? { Boom } # => true
17
17
  #
18
+ # @yieldreturn [#object_id] the actual value to compare to the expected one.
19
+ #
18
20
  # @return [Boolean] Comparison between actual and expected values.
19
21
  def matches?
20
22
  yield
data/matchi.gemspec CHANGED
@@ -9,13 +9,14 @@ Gem::Specification.new do |spec|
9
9
  spec.homepage = 'https://github.com/fixrb/matchi'
10
10
  spec.license = 'MIT'
11
11
 
12
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^test\//) }
13
- spec.executables = spec.files.grep(/^exe\//) { |f| File.basename(f) }
12
+ spec.files =
13
+ `git ls-files -z`.split("\x0").reject { |f| f.match(/%r{^test}/) }
14
+ spec.executables = spec.files.grep(/%r{^exe}/) { |f| File.basename(f) }
14
15
  spec.require_paths = ['lib']
15
16
 
16
- spec.add_development_dependency 'bundler', '~> 1.8'
17
- spec.add_development_dependency 'rake', '~> 10.0'
17
+ spec.add_development_dependency 'bundler', '~> 1.9'
18
+ spec.add_development_dependency 'rake', '~> 10.4'
18
19
  spec.add_development_dependency 'yard', '~> 0.8'
19
- spec.add_development_dependency 'simplecov', '~> 0.9.1'
20
- spec.add_development_dependency 'rubocop', '~> 0.29'
20
+ spec.add_development_dependency 'simplecov', '~> 0.10'
21
+ spec.add_development_dependency 'rubocop', '~> 0.31'
21
22
  end
@@ -0,0 +1,3 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start
@@ -0,0 +1,8 @@
1
+ require_relative File.join 'support', 'coverage'
2
+ require_relative File.join '..', 'lib', 'matchi'
3
+
4
+ # It is expected to be true
5
+ fail unless Matchi.fetch(:BeFalse).matches? { false }
6
+
7
+ # It is expected to be false
8
+ fail if Matchi.fetch(:BeFalse).matches? { 'foo' }
@@ -0,0 +1,8 @@
1
+ require_relative File.join 'support', 'coverage'
2
+ require_relative File.join '..', 'lib', 'matchi'
3
+
4
+ # It is expected to be true
5
+ fail unless Matchi.fetch(:BeNil).matches? { nil }
6
+
7
+ # It is expected to be false
8
+ fail if Matchi.fetch(:BeNil).matches? { 'foo' }
@@ -0,0 +1,25 @@
1
+ require_relative File.join 'support', 'coverage'
2
+ require_relative File.join '..', 'lib', 'matchi'
3
+
4
+ module Matchi
5
+ # **Answer to the Ultimate Question of Life, The Universe, and Everything**
6
+ # matcher.
7
+ class BeTheAnswer
8
+ # @example Is it 42?
9
+ # be_the_answer = Matchi::BeTheAnswer.new
10
+ # be_the_answer.matches? { 42 } # => true
11
+ #
12
+ # @yieldreturn [#object_id] the actual value to compare to the expected one.
13
+ #
14
+ # @return [Boolean] Comparison between actual and expected values.
15
+ def matches?
16
+ 42.equal? yield
17
+ end
18
+ end
19
+ end
20
+
21
+ # It is expected to be true
22
+ fail unless Matchi.fetch(:BeTheAnswer).matches? { 42 }
23
+
24
+ # It is expected to be false
25
+ fail if Matchi.fetch(:BeTheAnswer).matches? { 4 }
@@ -0,0 +1,8 @@
1
+ require_relative File.join 'support', 'coverage'
2
+ require_relative File.join '..', 'lib', 'matchi'
3
+
4
+ # It is expected to be true
5
+ fail unless Matchi.fetch(:BeTrue).matches? { true }
6
+
7
+ # It is expected to be false
8
+ fail if Matchi.fetch(:BeTrue).matches? { 'foo' }
@@ -0,0 +1,11 @@
1
+ require_relative File.join 'support', 'coverage'
2
+ require_relative File.join '..', 'lib', 'matchi'
3
+
4
+ # It is expected to be true
5
+ module Matchi
6
+ class Foo; end
7
+ end
8
+
9
+ fail unless Matchi.constants.to_set.superset? [
10
+ :BeFalse, :BeNil, :BeTrue, :Eql, :Equal, :Match, :RaiseException
11
+ ].to_set
data/test/test_eql.rb ADDED
@@ -0,0 +1,8 @@
1
+ require_relative File.join 'support', 'coverage'
2
+ require_relative File.join '..', 'lib', 'matchi'
3
+
4
+ # It is expected to be true
5
+ fail unless Matchi.fetch(:Eql, 'foo').matches? { 'foo' }
6
+
7
+ # It is expected to be false
8
+ fail if Matchi.fetch(:Eql, 'foo').matches? { 'bar' }
@@ -0,0 +1,8 @@
1
+ require_relative File.join 'support', 'coverage'
2
+ require_relative File.join '..', 'lib', 'matchi'
3
+
4
+ # It is expected to be true
5
+ fail unless Matchi.fetch(:Equal, :foo).matches? { :foo }
6
+
7
+ # It is expected to be false
8
+ fail if Matchi.fetch(:Equal, :foo).matches? { :bar }
@@ -0,0 +1,8 @@
1
+ require_relative File.join 'support', 'coverage'
2
+ require_relative File.join '..', 'lib', 'matchi'
3
+
4
+ # It is expected to be true
5
+ fail unless Matchi.fetch(:Match, /^foo/).matches? { 'foobar' }
6
+
7
+ # It is expected to be false
8
+ fail if Matchi.fetch(:Match, /^foo/).matches? { 'bar' }
@@ -0,0 +1,15 @@
1
+ require_relative File.join 'support', 'coverage'
2
+ require_relative File.join '..', 'lib', 'matchi'
3
+
4
+ # It is expected to be true
5
+ fail unless Matchi.fetch(:RaiseException, ZeroDivisionError).matches? { 0 / 0 }
6
+
7
+ # It is expected to be false
8
+ fail if Matchi.fetch(:RaiseException, ZeroDivisionError).matches? { 'bar' }
9
+
10
+ # It is expected to raise
11
+ begin
12
+ Matchi.fetch(:RaiseException, ZeroDivisionError).matches? { BOOM }
13
+ rescue NameError
14
+ true
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matchi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Wack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-10 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '1.9'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.8'
26
+ version: '1.9'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
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: '10.0'
40
+ version: '10.4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: yard
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.9.1
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.9.1
68
+ version: '0.10'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.29'
75
+ version: '0.31'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.29'
82
+ version: '0.31'
83
83
  description: Collection of expectation matchers for Ruby.
84
84
  email:
85
85
  - contact@cyril.email
@@ -107,6 +107,16 @@ files:
107
107
  - lib/matchi/match.rb
108
108
  - lib/matchi/raise_exception.rb
109
109
  - matchi.gemspec
110
+ - test/support/coverage.rb
111
+ - test/test_be_false.rb
112
+ - test/test_be_nil.rb
113
+ - test/test_be_the_answer.rb
114
+ - test/test_be_true.rb
115
+ - test/test_constants.rb
116
+ - test/test_eql.rb
117
+ - test/test_equal.rb
118
+ - test/test_match.rb
119
+ - test/test_raise_exception.rb
110
120
  homepage: https://github.com/fixrb/matchi
111
121
  licenses:
112
122
  - MIT