spectus 2.0.1 → 2.0.2

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: 50aef8a671220af542bdd9f6d9d186ac3badf254
4
- data.tar.gz: eb5547363ee02f167239c9439887ea90691fb4df
3
+ metadata.gz: 0c3e542950b2210e49686b15023c8be3d160aa49
4
+ data.tar.gz: b45fe15296e94a7ae911b126172183a9149758f5
5
5
  SHA512:
6
- metadata.gz: d588c7d420a3b2630ade36ef006efa503358a3d6b95067a82b592fdd0aa961e2e8bc1ff816ea15365758881e33c2948bc1aa0450c5da4e7d65c8845e22652261
7
- data.tar.gz: f7ccb81efb0a19c78907ecab4704eaee52d2a7193d27c3c2052f1c06134eca3b5cd00bb1641025abc291e6aa370ccaae4b177ccfbfe21ab9fb40bd657eeee2c0
6
+ metadata.gz: 8ac7132ac401af9effa9b7e2613492a5fa3f4892cfdd302d22d01c500b1c3c63c30ba7e2ee1e429c8acbfaa7d2f0572c3a62926d72f33e5b50d10c51b720a407
7
+ data.tar.gz: 265522140ef91356450d32a5cf4fa16b0ffaedf9da7209ba7e66c1435e3248df0cf8ae7b56aa6676a42e653e47c2a39cc9308281a0bdd124f6f0c63f49a5b7f4
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- gem 'rubysl-irb' if RUBY_ENGINE.eql?('rbx')
data/VERSION.semver CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.0.2
data/lib/spectus.rb CHANGED
@@ -2,7 +2,10 @@ require_relative File.join 'spectus', 'expectation_target'
2
2
 
3
3
  # Namespace for the Spectus library.
4
4
  #
5
- # @api private
5
+ # @api public
6
+ #
7
+ # @example 42 MUST be equal to 42
8
+ # Spectus.this { 42 }.MUST equal: 42 # => true
6
9
  module Spectus
7
10
  # Expectations are built with this method.
8
11
  #
@@ -11,6 +14,8 @@ module Spectus
11
14
  # @example Absolute requirement definition
12
15
  # this { 42 }.MUST equal: 42 # => true
13
16
  #
17
+ # @yieldparam input the code to test.
18
+ #
14
19
  # @return [ExpectationTarget] the expectation target.
15
20
  def self.this(&input)
16
21
  ExpectationTarget.new(&input)
@@ -10,6 +10,7 @@ module Spectus
10
10
  class ExpectationTarget < BasicObject
11
11
  # Create a new expection target
12
12
  #
13
+ # @yieldparam actual the value which is compared with the expected value.
13
14
  def initialize(&actual)
14
15
  @actual = actual
15
16
  end
@@ -0,0 +1,29 @@
1
+ require_relative 'sandbox'
2
+
3
+ module Spectus
4
+ # Requirement level's base class.
5
+ #
6
+ # @api private
7
+ #
8
+ class Requirement < BasicObject
9
+ # Initialize the requirement level class.
10
+ #
11
+ # @param [Hash] definition
12
+ # @param [Boolean] negate
13
+ def initialize(definition, negate = false)
14
+ @definition = definition
15
+ @negate = negate
16
+ end
17
+
18
+ protected
19
+
20
+ # Run the actual block against the definition.
21
+ #
22
+ # @yieldparam actual the value which is compared with the expected value.
23
+ #
24
+ # @return [Boolean] report if the expectation is true or false.
25
+ def sandbox(&actual)
26
+ Sandbox.new(@definition, &actual)
27
+ end
28
+ end
29
+ end
@@ -1,36 +1,16 @@
1
- require_relative File.join '..', 'sandbox'
1
+ require_relative File.join '..', 'requirement'
2
2
 
3
3
  module Spectus
4
4
  # Contains requirement levels.
5
- #
6
5
  module RequirementLevel
7
6
  # _High_ requirement level.
8
- #
9
- class High < BasicObject
10
- # Initialize the requirement level class.
11
- #
12
- # @param [Hash] definition
13
- # @param [Boolean] negate
14
- def initialize(definition, negate = false)
15
- @definition = definition
16
- @negate = negate
17
- end
18
-
7
+ class High < Requirement
19
8
  # Evaluate the expectation with the passed block.
20
9
  #
21
10
  # @return [Boolean] report if the expectation is true or false.
22
11
  def pass?(&actual)
23
12
  sandbox(&actual).pass?(@negate)
24
13
  end
25
-
26
- protected
27
-
28
- # Run the actual block against the definition.
29
- #
30
- # @return [Boolean] report if the expectation is true or false.
31
- def sandbox(&actual)
32
- Sandbox.new(@definition, &actual)
33
- end
34
14
  end
35
15
  end
36
16
  end
@@ -1,20 +1,20 @@
1
- require_relative 'medium'
1
+ require_relative File.join '..', 'requirement'
2
2
 
3
3
  module Spectus
4
4
  # Contains requirement levels.
5
- #
6
5
  module RequirementLevel
7
6
  # _Low_ requirement level.
8
- #
9
- class Low < Medium
7
+ class Low < Requirement
10
8
  # Evaluate the expectation with the passed block.
11
9
  #
12
10
  # @return [Boolean] report if the expectation is true or false.
13
11
  def pass?(&actual)
14
- if sandbox(&actual).exception.class.equal?(::NoMethodError)
12
+ result = sandbox(&actual)
13
+
14
+ if result.exception.class.equal?(::NoMethodError)
15
15
  true
16
16
  else
17
- super
17
+ result.pass?(@negate)
18
18
  end
19
19
  end
20
20
  end
@@ -1,20 +1,20 @@
1
- require_relative 'high'
1
+ require_relative File.join '..', 'requirement'
2
2
 
3
3
  module Spectus
4
4
  # Contains requirement levels.
5
- #
6
5
  module RequirementLevel
7
6
  # _Medium_ requirement level.
8
- #
9
- class Medium < High
7
+ class Medium < Requirement
10
8
  # Evaluate the expectation with the passed block.
11
9
  #
12
10
  # @return [Boolean] report if the expectation is true or false.
13
11
  def pass?(&actual)
14
- if super
12
+ result = sandbox(&actual)
13
+
14
+ if result.pass?(@negate)
15
15
  true
16
16
  else
17
- sandbox(&actual).exception.nil?
17
+ result.exception.nil?
18
18
  end
19
19
  end
20
20
  end
@@ -3,6 +3,8 @@ require 'expect'
3
3
  module Spectus
4
4
  # This class evaluate the expectation with the passed block.
5
5
  #
6
+ # @api private
7
+ #
6
8
  class Sandbox
7
9
  attr_reader :exception, :got
8
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Wack
@@ -30,88 +30,88 @@ cert_chain:
30
30
  zeYBFLJQAl0AQPaGujsG5tssIabiNy1ryydKAjWkNDxqLgvtwST3L0Qr9UQFQgoA
31
31
  O2Rl8PjSD+2P9XE7T2x1xQ==
32
32
  -----END CERTIFICATE-----
33
- date: 2015-02-14 00:00:00.000000000 Z
33
+ date: 2015-02-19 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
- type: :runtime
37
36
  name: expect
38
- version_requirements: !ruby/object:Gem::Requirement
37
+ requirement: !ruby/object:Gem::Requirement
39
38
  requirements:
40
39
  - - "~>"
41
40
  - !ruby/object:Gem::Version
42
41
  version: 0.0.4
42
+ type: :runtime
43
43
  prerelease: false
44
- requirement: !ruby/object:Gem::Requirement
44
+ version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: 0.0.4
49
49
  - !ruby/object:Gem::Dependency
50
- type: :development
51
50
  name: bundler
52
- version_requirements: !ruby/object:Gem::Requirement
51
+ requirement: !ruby/object:Gem::Requirement
53
52
  requirements:
54
53
  - - "~>"
55
54
  - !ruby/object:Gem::Version
56
55
  version: '1.8'
56
+ type: :development
57
57
  prerelease: false
58
- requirement: !ruby/object:Gem::Requirement
58
+ version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1.8'
63
63
  - !ruby/object:Gem::Dependency
64
- type: :development
65
64
  name: rake
66
- version_requirements: !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
67
66
  requirements:
68
67
  - - "~>"
69
68
  - !ruby/object:Gem::Version
70
69
  version: '10.0'
70
+ type: :development
71
71
  prerelease: false
72
- requirement: !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
76
  version: '10.0'
77
77
  - !ruby/object:Gem::Dependency
78
- type: :development
79
78
  name: yard
80
- version_requirements: !ruby/object:Gem::Requirement
79
+ requirement: !ruby/object:Gem::Requirement
81
80
  requirements:
82
81
  - - "~>"
83
82
  - !ruby/object:Gem::Version
84
83
  version: '0.8'
84
+ type: :development
85
85
  prerelease: false
86
- requirement: !ruby/object:Gem::Requirement
86
+ version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0.8'
91
91
  - !ruby/object:Gem::Dependency
92
- type: :development
93
92
  name: simplecov
94
- version_requirements: !ruby/object:Gem::Requirement
93
+ requirement: !ruby/object:Gem::Requirement
95
94
  requirements:
96
95
  - - "~>"
97
96
  - !ruby/object:Gem::Version
98
97
  version: 0.9.1
98
+ type: :development
99
99
  prerelease: false
100
- requirement: !ruby/object:Gem::Requirement
100
+ version_requirements: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
104
  version: 0.9.1
105
105
  - !ruby/object:Gem::Dependency
106
- type: :development
107
106
  name: rubocop
108
- version_requirements: !ruby/object:Gem::Requirement
107
+ requirement: !ruby/object:Gem::Requirement
109
108
  requirements:
110
109
  - - "~>"
111
110
  - !ruby/object:Gem::Version
112
111
  version: '0.29'
112
+ type: :development
113
113
  prerelease: false
114
- requirement: !ruby/object:Gem::Requirement
114
+ version_requirements: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
@@ -137,6 +137,7 @@ files:
137
137
  - bin/setup
138
138
  - lib/spectus.rb
139
139
  - lib/spectus/expectation_target.rb
140
+ - lib/spectus/requirement.rb
140
141
  - lib/spectus/requirement_level/high.rb
141
142
  - lib/spectus/requirement_level/low.rb
142
143
  - lib/spectus/requirement_level/medium.rb
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- ���aFHYV�����/�K�/���A��T4R\1
2
- y%j� s-�Y�ì���C��@3���\r���QD�i���5ߞ@���^߁aA+#�=]08�M�?�“�}̃�����#��v���!���?1S+|�_��#o��W@��������LYr�#��t ��'��A~���r ��&� G53���3vʶU``��c3 !;���szh�OɮmC1 �'�ׁ�^���רY&��<E��.jz��yеc)�܊�cR
1
+ !�w��1)��;A�?�҇�ƍ{ַE��5?LK~�_CC�{α�����3:�VZݽQ��}J!н����
2
+ ��8�7��l'Tp�f�,�Gm���qK�������1u4xsS��R�DMG��w�