expect 0.0.9 → 0.0.10

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: 7390ce50fc4637aebceecbab541c3fc6d4625a46
4
- data.tar.gz: 8e3b891f69b01d01354bf3550ac4d5ef63f618d7
3
+ metadata.gz: ffa099c977ed5d55292506e72d845fda55dc9bf7
4
+ data.tar.gz: 26925a6847c0ca076c42cc65eab5d6639ece5363
5
5
  SHA512:
6
- metadata.gz: ea5940e683012a0972f82aef6e124d79bfb890cfdffeddacc861888ba048bf8415b74f78138b4942d0b6bebcb740155e1c29d3d23dceb6248afebe6ef6607e44
7
- data.tar.gz: dff2a2e61bfbc4af5ec08a903283a975cdf4c475def48126a5db23a1527da4be472aefe1bbad4aeb4d861afd75cf99901bace01ea960ef2ef10b5a7e71dfa56e
6
+ metadata.gz: 0e529e8db912b1fee5713f663e44217cb0aab3cd66471c8a2aa4782a07118f237c3bd65d69103bab7cff4e9746cb78fceceafaa1c04f677b6109afd14ea37c26
7
+ data.tar.gz: 2138f50c1647baddc35fc928fdedba3c747a540e4edddd73d921a50f1b3d0ae2f2857d84fb88bc2be7f4ea2fc2c59a47a4c840f2dfd0a4fd9fb25345d7ebd486
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
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.0.10
@@ -15,9 +15,9 @@ Gem::Specification.new do |spec|
15
15
 
16
16
  spec.add_dependency 'matchi', '~> 0.0.5'
17
17
 
18
- spec.add_development_dependency 'bundler', '~> 1.8'
19
- spec.add_development_dependency 'rake', '~> 10.0'
18
+ spec.add_development_dependency 'bundler', '~> 1.9'
19
+ spec.add_development_dependency 'rake', '~> 10.4'
20
20
  spec.add_development_dependency 'yard', '~> 0.8'
21
- spec.add_development_dependency 'simplecov', '~> 0.9.1'
21
+ spec.add_development_dependency 'simplecov', '~> 0.9.2'
22
22
  spec.add_development_dependency 'rubocop', '~> 0.29'
23
23
  end
@@ -14,6 +14,8 @@ module Expect
14
14
  # @example Identity expectation
15
15
  # this { 42 }.to Equal: 42 # => true
16
16
  #
17
+ # @param input [Proc] the code to test.
18
+ #
17
19
  # @return [ExpectationTarget] the expectation target.
18
20
  def self.this(&input)
19
21
  ExpectationTarget.new(&input)
@@ -1,8 +1,8 @@
1
- require_relative File.join 'exception', 'failure'
2
- require_relative 'matcher'
1
+ require 'matchi'
3
2
 
4
3
  module Expect
5
- # Wraps the target of an expectation.
4
+ # Wraps the target of an expectation. This class is responsible for reporting
5
+ # if the expectation is true or false.
6
6
  #
7
7
  # @api private
8
8
  #
@@ -12,22 +12,24 @@ module Expect
12
12
  # Create a new expection target
13
13
  #
14
14
  # @example
15
- # ExpectationTarget.new { block of code }
15
+ # new { 42 }.to Equal: 42 # => true
16
16
  #
17
- # @yieldparam actual the value which is compared with the expected value.
17
+ # @param actual [Proc] the value which is compared with the expected value.
18
18
  def initialize(&actual)
19
19
  @actual = actual
20
20
  end
21
21
 
22
+ attr_reader :actual
23
+
22
24
  # Evaluate to a positive assertion.
23
25
  #
24
26
  # @api public
25
27
  #
26
28
  # @param [Hash, Symbol] definition
27
29
  #
28
- # @return [Boolean] pass or fail the spec
30
+ # @return [Boolean] report if the expectation is true or false
29
31
  def to(definition)
30
- match?(definition) || fail(Failure)
32
+ matcher(definition).matches?(&actual)
31
33
  end
32
34
 
33
35
  # Evaluate to a negative assertion.
@@ -36,22 +38,21 @@ module Expect
36
38
  #
37
39
  # @param [Hash, Symbol] definition
38
40
  #
39
- # @return [Boolean] pass or fail the spec
41
+ # @return [Boolean] report if the expectation is not true or not false
40
42
  def not_to(definition)
41
- match?(definition).equal?(false) || fail(Failure)
43
+ !to(definition)
42
44
  end
43
45
 
44
46
  private
45
47
 
46
- # Boolean comparison between the actual value and the expected value.
48
+ # Load the matcher.
47
49
  #
48
- # @api private
50
+ # @param [Array, Hash, Symbol] definition
49
51
  #
50
- # @param [Hash, Symbol] definition
51
- #
52
- # @return [Boolean] report if the expectation is true or false
53
- def match?(definition)
54
- Matcher.pass?(definition, &@actual)
52
+ # @return [#matches?] the matcher
53
+ def matcher(definition)
54
+ params = Array(definition).flatten(1)
55
+ Matchi.fetch(params.first, *params[1..-1])
55
56
  end
56
57
  end
57
58
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
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-12 00:00:00.000000000 Z
11
+ date: 2015-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: matchi
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.8'
33
+ version: '1.9'
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: '1.8'
40
+ version: '1.9'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '10.4'
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: '10.0'
54
+ version: '10.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yard
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.9.1
75
+ version: 0.9.2
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.9.1
82
+ version: 0.9.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -114,9 +114,7 @@ files:
114
114
  - bin/setup
115
115
  - expect.gemspec
116
116
  - lib/expect.rb
117
- - lib/expect/exception/failure.rb
118
117
  - lib/expect/expectation_target.rb
119
- - lib/expect/matcher.rb
120
118
  homepage: https://github.com/fixrb/expect
121
119
  licenses:
122
120
  - MIT
@@ -1,7 +0,0 @@
1
- module Expect
2
- # This exception is raised in order to fail a spec.
3
- #
4
- # @api private
5
- class Failure < StandardError
6
- end
7
- end
@@ -1,18 +0,0 @@
1
- require 'matchi'
2
-
3
- module Expect
4
- # This module provides matchers to define expectations.
5
- module Matcher
6
- # Evaluate the expectation with the passed block.
7
- #
8
- # @param [Array, Hash, Symbol] definition
9
- #
10
- # @return [Boolean] report if the expectation is true or false
11
- def self.pass?(definition, &actual)
12
- params = Array(definition).flatten(1)
13
- matcher = Matchi.fetch(params.first, *params[1..-1])
14
-
15
- matcher.matches?(&actual)
16
- end
17
- end
18
- end