minispec 0.0.1 → 0.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
- ---
2
- SHA1:
3
- metadata.gz: 2973847800ef2aac6fb86844541a766d114aa04c
4
- data.tar.gz: 3674b9c2392225cdd50768fd13de39563534c583
5
- SHA512:
6
- metadata.gz: 6eb0c4d0ca16fff824fa9d249baf8a9cf14c166dee42955a3bc9242b5843922d2ee9547eda4a40781dead96775f51223f1f939fac9d01abda2f0a2b94fe97bf9
7
- data.tar.gz: 610910d94d916f251c542c2f470e6b3c52650a913311cf6d5f79285350c1083b60ce083bdab08991b63e5ab7e4a1feed54b91f12bb98738416bc4d921086a90f
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d04713dc3775ca118faf19307f4e56509aa582ea
4
+ data.tar.gz: acda21895ad4ab6241996d0b4d85d53896bcd5e2
5
+ SHA512:
6
+ metadata.gz: feb5d79a7238d01431fa4c407e15b56749240d12252c5d1a75c863abf524ed054cce57644c6089e33c54133e9a17026c737693a3b5f6d80212b523a87d1dc6db
7
+ data.tar.gz: 4c82e730248e7a7084ea8d37e9d9712a7e6118b1a2ad7c9ba5349cdf012695cc3ff9a6be16c2a6a97db9f7a12114c1928ddf2a535b64a9911dcde569edccd5f6
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.1.0
5
+ - jruby-19mode
6
+ # - rbx-2 excluding until find a way to make it use Minispec 5 over 4
7
+ - ruby-head
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Build Status](https://travis-ci.org/sleewoo/minispec.svg?branch=master)](https://travis-ci.org/sleewoo/minispec)
1
2
 
2
3
  ### Minispec
3
4
 
@@ -11,21 +12,22 @@
11
12
 
12
13
  ## What and Why
13
14
 
14
- Simply i tired of syntax like `assert_equal(b, a)`, `a.should == b` and `expect(a).to eq(b)` etc.
15
+ Simply, I'm tired of syntax like `assert_equal(b, a)`, `a.should == b`, `expect(a).to eq(b)` etc.
15
16
 
16
- `is(a) == b` is all i want to type.
17
+ Something closer to `a == b` would make more sense.
17
18
 
18
- Also i tired to learn framework specific techniques. I want simply to use Ruby's native methods:
19
+ And I'm tired of learning framework specific techniques.<br>
20
+ I want simply to use **Ruby's native methods**:
19
21
 
20
22
  ```ruby
21
- is(a) == b
23
+ assert(a) == b
22
24
  does(a).include?(b)
23
25
  is(a).empty?
24
26
  ```
25
27
 
26
28
  `==`, `include?`, `empty?` are all Ruby methods called on `a`.
27
29
 
28
- What you see around `a` is a simple wrapper that passes messages to `a` and mark the assertion as passed or failed, depending on returned value.
30
+ What you see around `a` is a simple wrapper that passes messages to `a` and marks the assertion as passed or failed, depending on returned value.
29
31
 
30
32
 
31
33
  ## Install
@@ -163,9 +165,9 @@ end
163
165
 
164
166
  ### &#8627; Nested Specs
165
167
 
166
- Minispec allows to define unlimitedly nested specs using same `describe`/`context`/`section` DSL:
168
+ Minispec allows you to nest specs using the same `describe`/`context`/`section` DSL:
167
169
 
168
- Nested specs are akin of valve, they inherits everything(except tests) from parent spec but share nothing with it and does not change parent state in any way:
170
+ Nested specs inherit everything (except tests) from parent spec, but do not change any parent specs state in any way:
169
171
 
170
172
  ```ruby
171
173
  describe :A do
@@ -274,7 +276,7 @@ If you need all assertions to be evaluated regardless failures use `continue_on_
274
276
 
275
277
  ## Shared examples and setups
276
278
 
277
- Often you need to share some setups and tests(a.k.a examples) between various specs.
279
+ Often you need to share some setups and tests (a.k.a examples) between various specs.
278
280
 
279
281
  To define shared setups/examples simply define a module that includes `Minispec`.
280
282
 
@@ -350,7 +352,7 @@ end
350
352
 
351
353
  ## Local variables and subject
352
354
 
353
- Minispec provides `let` method as a clean way to define local variables. Its block are executed only once per test, when given variable used for first time.
355
+ Minispec provide a `let` method as a clean way to define local variables. Its block are executed only once per test, when given variable used for first time.
354
356
 
355
357
  ```ruby
356
358
  describe Array do
@@ -362,7 +364,7 @@ describe Array do
362
364
  end
363
365
  ```
364
366
 
365
- `subject` allow to test some object without repeatedly typing it. It is automatically set when a spec defined using Minispec's DSL:
367
+ `subject` allows testing some object without repeatedly typing it. It is automatically set when a spec is defined using Minispec's DSL:
366
368
 
367
369
  ```ruby
368
370
  describe Hash do
@@ -84,7 +84,7 @@ MiniSpec::SPEC_WRAPPERS.each do |meth|
84
84
  # # some another tests
85
85
  # end
86
86
  #
87
- define_method meth do |subject, &proc|
87
+ Object.send :define_method, meth do |subject, &proc|
88
88
  spec_name = subject.to_s.freeze
89
89
  spec = Class.new do
90
90
  include Minispec
@@ -187,10 +187,14 @@ module MiniSpec
187
187
  return self == nil if method_name == :nil?
188
188
  return unless method
189
189
 
190
- proc = block ? Proc.new do |*a,&b|
191
- message[:yielded] = a
192
- block.call(*a,&b)
193
- end : nil
190
+ proc = if block
191
+ Proc.new do |*a,&b|
192
+ message[:yielded] = a
193
+ block.call(*a,&b)
194
+ end
195
+ else
196
+ nil
197
+ end
194
198
 
195
199
  begin
196
200
  message[:returned] = method.bind(self).call(*args, &proc)
@@ -227,10 +231,14 @@ module MiniSpec
227
231
  message = {object: object, method: meth, arguments: args}
228
232
  messages.push(message)
229
233
 
230
- proc = block ? Proc.new do |*a,&b|
231
- message[:yielded] = a
232
- block.call(*a,&b)
233
- end : nil
234
+ proc = if block
235
+ Proc.new do |*a,&b|
236
+ message[:yielded] = a
237
+ block.call(*a,&b)
238
+ end
239
+ else
240
+ nil
241
+ end
234
242
 
235
243
  begin
236
244
  message[:returned] = method.bind(self).call(meth, *args, &proc)
@@ -134,10 +134,14 @@ module MiniSpec
134
134
 
135
135
  method = base.most_relevant_block_for(args)
136
136
 
137
- proc = block ? Proc.new do |*a,&b|
138
- message[:yielded] = a
139
- block.call(*a, &b)
140
- end : nil
137
+ proc = if block
138
+ Proc.new do |*a,&b|
139
+ message[:yielded] = a
140
+ block.call(*a, &b)
141
+ end
142
+ else
143
+ nil
144
+ end
141
145
 
142
146
  begin
143
147
  message[:returned] = method.call(original, *args, &proc)
@@ -84,10 +84,10 @@ module MiniSpec
84
84
  def totals__tests
85
85
  print(info(' Tests: '))
86
86
  print(send(@failed_tests.any? ? :info : :success, Minispec.tests))
87
- failed = error('%s failed' % @failed_tests.values.map(&:size).reduce(:+)) if @failed_tests.any?
88
- skipped = warn('%s skipped' % @skipped_tests.size) if @skipped_tests.any?
87
+ failed = error(' (%s failed)' % @failed_tests.values.map(&:size).reduce(:+)) if @failed_tests.any?
88
+ skipped = warn(' (%s skipped)' % @skipped_tests.size) if @skipped_tests.any?
89
89
  report = [failed, skipped].compact.join(', ')
90
- puts(report.empty? ? report : ' (%s)' % report)
90
+ puts(report)
91
91
  end
92
92
 
93
93
  def totals__assertions
@@ -149,8 +149,13 @@ module MiniSpec
149
149
  def print(*args); @stdout.print(*indent_lines(*args)) end
150
150
  def puts(*args); @stdout.puts(*indent_lines(*args)) end
151
151
 
152
- {success: 32, info: 34, warn: 35, error: 31}.each_pair do |m,c|
153
- define_method(m) {|s| "\e[%im%s\e[0m" % [c, s]}
152
+ {
153
+ success: [1, 32],
154
+ info: [0, 36],
155
+ warn: [0, 35],
156
+ error: [0, 31]
157
+ }.each_pair do |m,(esc,color)|
158
+ define_method(m) {|str| "\e[%i;%im%s\e[0m" % [esc, color, str]}
154
159
  end
155
160
 
156
161
  def failures?
@@ -7,12 +7,6 @@ module MiniSpec
7
7
  object.instance_eval('undef :%s' % method)
8
8
  end
9
9
 
10
- def method_defined? object, method
11
- object.respond_to?(method) ||
12
- object.protected_methods.include?(method) ||
13
- object.private_methods.include?(method)
14
- end
15
-
16
10
  # @api private
17
11
  # checking whether correct arguments passed to proxy methods.
18
12
  #
@@ -68,10 +62,18 @@ module MiniSpec
68
62
  protected: :protected_methods,
69
63
  private: :private_methods
70
64
  }.each_pair do |v,m|
71
- return v if object.send(m).include?(method)
65
+ if v == :public
66
+ # in case public_methods overridden to include method
67
+ # but method in fact does not exists,
68
+ # most notable ActiveRecord::Base#find which rely on method_missing
69
+ return v if object.respond_to?(method)
70
+ else
71
+ return v if object.send(m).include?(method)
72
+ end
72
73
  end
73
74
  nil
74
75
  end
76
+ alias method_defined? method_visibility
75
77
 
76
78
  def array_elements_map array
77
79
  # borrowed from thoughtbot/shoulda
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- name, version = 'minispec 0.0.1'.split
3
+ name, version = 'minispec 0.0.2'.split
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = name
6
6
  spec.version = version
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.required_ruby_version = '>= 1.9.2'
20
20
 
21
- spec.add_dependency 'diff-lcs', '~> 1.2'
22
- spec.add_dependency 'coderay', '~> 1.1'
21
+ spec.add_dependency 'diff-lcs', '~> 1'
22
+ spec.add_dependency 'coderay', '~> 1'
23
23
 
24
- spec.add_development_dependency 'minitest'
24
+ spec.add_development_dependency 'minitest', '~> 5'
25
25
  spec.add_development_dependency 'bundler'
26
26
  spec.add_development_dependency 'rake'
27
27
  end
@@ -54,7 +54,7 @@ class MinispecTest::Expectations::Unit
54
54
 
55
55
  should 'raise when arity not respected and lambda used' do
56
56
  expect(o).to_receive(:y)
57
- does { o.y(&lambda {|a|}) }.raise? ArgumentError, /2 for 1/
57
+ does { o.y(&lambda {|a|}) }.raise? ArgumentError, /2.+1/
58
58
  end
59
59
 
60
60
  should 'use same expectation for all messages' do
@@ -70,26 +70,28 @@ class MinispecTest
70
70
  assert(o.send(:a)) == :b
71
71
  end
72
72
 
73
- it 'keeps the visibility of existing methods' do
74
- o = Class.new do
75
- def a; end
76
- protected
77
- def b; p :blah; end
78
- private
79
- def c; end
80
- end.new
81
-
82
- mock(o, :a)
83
- o.send(:a)
84
- does(o.public_methods).include?(:a)
85
-
86
- mock(o, :b)
87
- o.send(:b)
88
- does(o.protected_methods).include?(:b)
89
-
90
- mock(o, :c)
91
- o.send(:c)
92
- does(o.private_methods).include?(:c)
73
+ if RUBY_VERSION.to_f >= 2
74
+ it 'keeps the visibility of existing methods' do
75
+ o = Class.new do
76
+ def a; end
77
+ protected
78
+ def b; p :blah; end
79
+ private
80
+ def c; end
81
+ end.new
82
+
83
+ mock(o, :a)
84
+ o.send(:a)
85
+ does(o.public_methods).include?(:a)
86
+
87
+ mock(o, :b)
88
+ o.send(:b)
89
+ does(o.protected_methods).include?(:b)
90
+
91
+ mock(o, :c)
92
+ o.send(:c)
93
+ does(o.private_methods).include?(:c)
94
+ end
93
95
  end
94
96
 
95
97
  it 'uses `with_any` with a block to define a catchall return' do
@@ -162,23 +162,25 @@ class MinispecTest
162
162
  assert(o.send(:a, 1)) == :one
163
163
  end
164
164
 
165
- it 'keeps the visibility of existing methods' do
166
- o = Class.new do
167
- def a; end
168
- protected
169
- def b; end
170
- private
171
- def c; end
172
- end.new
173
-
174
- stub(o, :a)
175
- does(o.public_methods).include?(:a)
176
-
177
- stub(o, :b)
178
- does(o.protected_methods).include?(:b)
179
-
180
- stub(o, :c)
181
- does(o.private_methods).include?(:c)
165
+ if RUBY_VERSION.to_f >= 2
166
+ it 'keeps the visibility of existing methods' do
167
+ o = Class.new do
168
+ def a; end
169
+ protected
170
+ def b; end
171
+ private
172
+ def c; end
173
+ end.new
174
+
175
+ stub(o, :a)
176
+ does(o.public_methods).include?(:a)
177
+
178
+ stub(o, :b)
179
+ does(o.protected_methods).include?(:b)
180
+
181
+ stub(o, :c)
182
+ does(o.private_methods).include?(:c)
183
+ end
182
184
  end
183
185
 
184
186
  it 'enforces public visibility on protected methods' do
@@ -334,26 +336,28 @@ class MinispecTest
334
336
  assert { o.a }.raise NoMethodError
335
337
  end
336
338
 
337
- it 'undefines early unexisting protected methods' do
338
- assert(o.protected_methods).does_not.include? :a
339
+ unless RUBY_ENGINE == 'rbx'
340
+ it 'undefines early unexisting protected methods' do
341
+ assert(o.protected_methods).does_not.include? :a
339
342
 
340
- protected_stub(o, :a) {:a}
341
- does(o.protected_methods).include? :a
343
+ protected_stub(o, :a) {:a}
344
+ does(o.protected_methods).include? :a
342
345
 
343
- restore_originals
346
+ restore_originals
344
347
 
345
- assert(o.protected_methods).does_not.include? :a
346
- end
348
+ assert(o.protected_methods).does_not.include? :a
349
+ end
347
350
 
348
- it 'undefines early unexisting private methods' do
349
- assert(o.private_methods).does_not.include? :a
351
+ it 'undefines early unexisting private methods' do
352
+ assert(o.private_methods).does_not.include? :a
350
353
 
351
- private_stub(o, :a) {:a}
352
- does(o.private_methods).include? :a
354
+ private_stub(o, :a) {:a}
355
+ does(o.private_methods).include? :a
353
356
 
354
- restore_originals
357
+ restore_originals
355
358
 
356
- assert(o.private_methods).does_not.include? :a
359
+ assert(o.private_methods).does_not.include? :a
360
+ end
357
361
  end
358
362
 
359
363
  it 'uses `returns` with a block to define a catchall return' do
@@ -43,7 +43,10 @@ class MinispecTest
43
43
 
44
44
  begin # error message as first argument
45
45
  should 'pass when raised error message is equal to expected one' do
46
- does { Blah }.raise_error? 'uninitialized constant MinispecTest::Raise::Unit::Blah'
46
+ message = RUBY_ENGINE == 'rbx' ?
47
+ 'Missing or uninitialized constant: MinispecTest::Raise::Unit::Blah' :
48
+ 'uninitialized constant MinispecTest::Raise::Unit::Blah'
49
+ does { Blah }.raise_error? message
47
50
  end
48
51
 
49
52
  should ':fail when raised error message is NOT equal to expected one' do
metadata CHANGED
@@ -1,94 +1,77 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: minispec
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Slee Woo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-24 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
11
+
12
+ date: 2014-12-08 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
14
15
  name: diff-lcs
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.2'
20
- type: :runtime
21
16
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.2'
27
- - !ruby/object:Gem::Dependency
28
- name: coderay
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.1'
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: "1"
34
22
  type: :runtime
23
+ version_requirements: *id001
24
+ - !ruby/object:Gem::Dependency
25
+ name: coderay
35
26
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.1'
41
- - !ruby/object:Gem::Dependency
27
+ requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: "1"
32
+ type: :runtime
33
+ version_requirements: *id002
34
+ - !ruby/object:Gem::Dependency
42
35
  name: minitest
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
36
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
37
+ requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: "5"
62
42
  type: :development
43
+ version_requirements: *id003
44
+ - !ruby/object:Gem::Dependency
45
+ name: bundler
63
46
  prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
47
+ requirement: &id004 !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - &id005
50
+ - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
76
53
  type: :development
54
+ version_requirements: *id004
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
77
57
  prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
58
+ requirement: &id006 !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - *id005
61
+ type: :development
62
+ version_requirements: *id006
83
63
  description: Simple, Intuitive, Full-featured Testing Framework
84
- email:
64
+ email:
85
65
  - mail@sleewoo.com
86
- executables:
66
+ executables:
87
67
  - minispec
88
68
  extensions: []
69
+
89
70
  extra_rdoc_files: []
90
- files:
91
- - ".pryrc"
71
+
72
+ files:
73
+ - .pryrc
74
+ - .travis.yml
92
75
  - Gemfile
93
76
  - LICENSE
94
77
  - README.md
@@ -170,27 +153,29 @@ files:
170
153
  - test/test__skip.rb
171
154
  - test/test__throw.rb
172
155
  homepage: https://github.com/sleewoo/minispec
173
- licenses:
156
+ licenses:
174
157
  - MIT
175
158
  metadata: {}
159
+
176
160
  post_install_message:
177
161
  rdoc_options: []
178
- require_paths:
162
+
163
+ require_paths:
179
164
  - lib
180
- required_ruby_version: !ruby/object:Gem::Requirement
181
- requirements:
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ requirements:
182
167
  - - ">="
183
- - !ruby/object:Gem::Version
168
+ - !ruby/object:Gem::Version
184
169
  version: 1.9.2
185
- required_rubygems_version: !ruby/object:Gem::Requirement
186
- requirements:
187
- - - ">="
188
- - !ruby/object:Gem::Version
189
- version: '0'
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - *id005
190
173
  requirements: []
174
+
191
175
  rubyforge_project:
192
176
  rubygems_version: 2.2.2
193
177
  signing_key:
194
178
  specification_version: 4
195
- summary: minispec-0.0.1
179
+ summary: minispec-0.0.2
196
180
  test_files: []
181
+