argspec 0.3.1 → 0.3.3

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: 2fa42c2bea6a6433b6a114cf621d2f47e9b22fe4
4
- data.tar.gz: e0a02ac0188c8b9b600e9b20f51009fb06de8bb7
3
+ metadata.gz: 7530a54443a31a3935f593dffe2e9db9c060e755
4
+ data.tar.gz: 0a6107f1acdea055a2e7d9c6607182b813a157ee
5
5
  SHA512:
6
- metadata.gz: 1d39fd2603deb79d5d8b07dce6db47b076fafb9847d2d85ab904ffda0d33b5332ed545ac4f5dc025ec9df01c2b47395796d06ae9ce66a4713af0c21f6e04c85f
7
- data.tar.gz: 4917375026c94b0e4655b5f515067903cf4aa623d68b9739b29c6bb637ca30d7345e8fbc26b9847755ed21db96554cf02db590cf5b39d68ef6b6568d4bda865b
6
+ metadata.gz: e57e5047bbd137788c73f328b3ecb0500665f170437d098964f167267f49b1643f5661be9d890f092b2630a0866ba4eab46916ed6048f6897881aa9f466a6ae8
7
+ data.tar.gz: 4096f8daefcee69e639386786583bebe921c8d67ff68eca21f6a068cfd109ce918c519ebf029eaad591b9aa35c634ae8c18c6d2a89b2d46c07ec8b826e379eab
@@ -27,6 +27,7 @@ module ArgumentSpecification
27
27
  #
28
28
  # Arguments:
29
29
  # matcher: (Matchers::BaseMatcher)
30
+ # block: (Block)
30
31
  #
31
32
  # Example:
32
33
  # >> should be_a(Symbol)
@@ -35,10 +36,11 @@ module ArgumentSpecification
35
36
  # Raises:
36
37
  # ArgumentError: When the argument does not match
37
38
  #
38
- def should(matcher)
39
+ def should(matcher, &block)
39
40
  return self unless matcher.is_a?(Matchers::BaseMatcher)
40
41
 
41
42
  matcher.send(:actual=, @actual)
43
+ matcher.send(:block=, block) if block_given?
42
44
 
43
45
  return self if matcher.matches?
44
46
 
@@ -49,6 +51,7 @@ module ArgumentSpecification
49
51
  #
50
52
  # Arguments:
51
53
  # matcher: (Matchers::BaseMatcher)
54
+ # block: (Block)
52
55
  #
53
56
  # Example:
54
57
  # >> should_not be_a(Symbol)
@@ -57,10 +60,11 @@ module ArgumentSpecification
57
60
  # Raises:
58
61
  # ArgumentError: When the argument matches
59
62
  #
60
- def should_not(matcher)
63
+ def should_not(matcher, &block)
61
64
  return self unless matcher.is_a?(Matchers::BaseMatcher)
62
65
 
63
66
  matcher.send(:actual=, @actual)
67
+ matcher.send(:block=, block) if block_given?
64
68
 
65
69
  return self unless matcher.matches?
66
70
 
@@ -73,8 +77,8 @@ module ArgumentSpecification
73
77
  # >> and be_a(Symbol)
74
78
  # => #<Argument:0x00000000000000 @actual=:test>
75
79
  #
76
- def and(*args)
77
- should(*args)
80
+ def and(*args, &block)
81
+ should(*args, &block)
78
82
  end
79
83
 
80
84
  # Alias for should_not
@@ -83,8 +87,8 @@ module ArgumentSpecification
83
87
  # >> and_not be_a(Symbol)
84
88
  # => #<Argument:0x00000000000000 @actual=:test>
85
89
  #
86
- def and_not(*args)
87
- should_not(*args)
90
+ def and_not(*args, &block)
91
+ should_not(*args, &block)
88
92
  end
89
93
  end
90
94
  end
@@ -1,3 +1,3 @@
1
1
  module ArgumentSpecification
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.3'
3
3
  end
@@ -18,8 +18,9 @@ module ArgumentSpecification
18
18
 
19
19
  module_eval <<-EOS
20
20
  def #{name}(*args, &block)
21
- instance = #{klass}.new(*args, &block)
21
+ instance = #{klass}.new(*args)
22
22
  instance.send(:setup, '#{name}'.to_sym, args)
23
+ instance.send(:block=, block) if block_given?
23
24
  instance
24
25
  end
25
26
  EOS
@@ -71,6 +71,7 @@ module ArgumentSpecification
71
71
  actual = @actual.is_a?(Array) ? @actual : [@actual]
72
72
  actual.each do |value|
73
73
  @expected.send(:actual=, value)
74
+ @expected.send(:block=, @block) if @block
74
75
 
75
76
  return false unless @expected.matches?
76
77
  end
@@ -22,7 +22,7 @@ module ArgumentSpecification
22
22
  end
23
23
  end
24
24
 
25
- attr_reader :actual, :metadata
25
+ attr_reader :actual, :block, :metadata
26
26
 
27
27
  # The failure message when using 'should'
28
28
  #
@@ -102,6 +102,19 @@ module ArgumentSpecification
102
102
  @actual = actual
103
103
  end
104
104
 
105
+ # Set the block
106
+ #
107
+ # Arguments:
108
+ # block: (Proc)
109
+ #
110
+ # Example:
111
+ # >> matcher.block = Proc.new {}
112
+ # => #<Proc:0x00000000000000>
113
+ #
114
+ def block=(block)
115
+ @block = block
116
+ end
117
+
105
118
  # Prettify a matcher
106
119
  #
107
120
  # Arguments:
@@ -3,21 +3,19 @@ module ArgumentSpecification
3
3
  class Satisfy < BaseMatcher
4
4
  matcher_name :satisfy
5
5
 
6
- attr_reader :description, :block
6
+ attr_reader :description
7
7
 
8
8
  # Create a new matcher instance
9
9
  #
10
10
  # Arguments:
11
11
  # description: (String)
12
- # block: (Block)
13
12
  #
14
13
  # Example:
15
- # >> ArgumentSpecification::Matchers::Satisfy.new('always pass') { true }
14
+ # >> ArgumentSpecification::Matchers::Satisfy.new('always pass')
16
15
  # => #<ArgumentSpecification::Matchers::Satisfy:0x00000000000000 @block=#<Proc:0x00000000000000>>
17
16
  #
18
- def initialize(description, &block)
17
+ def initialize(description)
19
18
  @description = description
20
- @block = block
21
19
  end
22
20
 
23
21
  # The failure message when using 'should'
@@ -59,7 +57,9 @@ module ArgumentSpecification
59
57
  # => true
60
58
  #
61
59
  def matches?
62
- @block.call(@actual)
60
+ return @block.call(@actual) if @block
61
+
62
+ false
63
63
  end
64
64
  end
65
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: argspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nialto Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-30 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler