em-minitest 1.0.1 → 2.0.0

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: 5e07ff5851b835079091613300f0ac736a561ddc
4
- data.tar.gz: b39db6b9fbb63a50a04f2e0646cf10eae4191811
3
+ metadata.gz: d75d6d679f0d4e08a539f79270e565202342a5b8
4
+ data.tar.gz: 9904aa351fcfa9efdc14ec3d97b2af8ce92163e8
5
5
  SHA512:
6
- metadata.gz: 7d3b78307bf31c9c2a4989c2dc1f3751fbd4dccb6a076fefeb89bf1fc78cb30d38aeab8937ff734d29418188c913186affecd382dc3ce8ed1d447479d991e3d3
7
- data.tar.gz: 0a7fb9bec784134eb83b9511279406bf7a2ba0aedf03251c0f22aefe2e02072e72359e532ca42a80ed1c988b9dff944d041327cc5aa806a7a9da60890943615c
6
+ metadata.gz: 35c239f26df081607dcd55e7ad37596e3090dc1188cbaaee363c616a38e64a090e1e420b4cfce3493877134548331d88c337f962b7fab455a3b56f9c23c25f78
7
+ data.tar.gz: 476b1892ecfd19000eb56bfc647488d558eb28800aeaa385c3d9c63c28c11c3bbf4b3842521c004e5346832d4926acbcb6eaa808b82e85c3b8abbb3f41070e7f
@@ -0,0 +1,7 @@
1
+
2
+ ## ChangeLog
3
+
4
+ # 1.1.0
5
+
6
+ * Get rid of Synchrony dependency
7
+ * Add tests
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'shoulda'
4
+
5
+ gemspec
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ em-minitest (2.0.0)
5
+ eventmachine
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (4.0.0)
11
+ i18n (~> 0.6, >= 0.6.4)
12
+ minitest (~> 4.2)
13
+ multi_json (~> 1.3)
14
+ thread_safe (~> 0.1)
15
+ tzinfo (~> 0.3.37)
16
+ atomic (1.1.14)
17
+ eventmachine (1.0.3)
18
+ i18n (0.6.5)
19
+ minitest (4.7.5)
20
+ multi_json (1.8.1)
21
+ shoulda (3.5.0)
22
+ shoulda-context (~> 1.0, >= 1.0.1)
23
+ shoulda-matchers (>= 1.4.1, < 3.0)
24
+ shoulda-context (1.1.5)
25
+ shoulda-matchers (2.4.0)
26
+ activesupport (>= 3.0.0)
27
+ thread_safe (0.1.3)
28
+ atomic
29
+ tzinfo (0.3.37)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ em-minitest!
36
+ shoulda
data/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org/>
@@ -0,0 +1,4 @@
1
+ em-minitest
2
+ ===========
3
+
4
+ Monkey-patch MiniTest to run each test inside the EventMachine reactor
@@ -12,5 +12,6 @@ Gem::Specification.new do |gem|
12
12
  gem.test_files = gem.files.grep(%r{^(test|features)/})
13
13
  gem.name = "em-minitest"
14
14
  gem.require_paths = ["lib"]
15
- gem.version = '1.0.1'
15
+ gem.version = '2.0.0'
16
+ gem.add_dependency 'eventmachine'
16
17
  end
@@ -1,4 +1,39 @@
1
1
  require 'eventmachine'
2
+ require 'fiber'
3
+
4
+ # Excerpt from em-synchrony gem, see https://github.com/igrigorik/em-synchrony for credit and license
5
+ ##
6
+
7
+ module EventMachine
8
+
9
+ # A convenience method for wrapping a given block within
10
+ # a Ruby Fiber such that async operations can be transparently
11
+ # paused and resumed based on IO scheduling.
12
+ # It detects whether EM is running or not.
13
+ def self.synchrony(blk=nil, tail=nil)
14
+ # EM already running.
15
+ if reactor_running?
16
+ if block_given?
17
+ Fiber.new { yield }.resume
18
+ else
19
+ Fiber.new { blk.call }.resume
20
+ end
21
+ tail && add_shutdown_hook(tail)
22
+
23
+ # EM not running.
24
+ else
25
+ if block_given?
26
+ run(nil, tail) { Fiber.new { yield }.resume }
27
+ else
28
+ run(Proc.new { Fiber.new { blk.call }.resume }, tail)
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+
35
+ ##
36
+ ## end excerpt
2
37
 
3
38
  # Monkey patch MiniTest to use EM::Synchrony
4
39
  if defined? MiniTest::Unit
@@ -7,6 +42,7 @@ if defined? MiniTest::Unit
7
42
 
8
43
  def run(args = [])
9
44
  result = nil
45
+
10
46
  EM.synchrony do
11
47
  result = run_alias args
12
48
  EM.stop
@@ -0,0 +1,37 @@
1
+ $: << 'lib'
2
+
3
+ require 'bundler/setup'
4
+ require 'shoulda'
5
+ require 'test/unit'
6
+ require 'em-minitest'
7
+
8
+ class EmMinitestTest < Test::Unit::TestCase
9
+
10
+ context 'run inside reactor and in its own fiber' do
11
+
12
+ setup do
13
+ @count = 0
14
+ fiber = Fiber.current
15
+ EventMachine.add_timer(0.1) do
16
+ fiber.resume
17
+ end
18
+
19
+ Fiber.yield
20
+
21
+ @count += 1
22
+ end
23
+
24
+ should 'run two tests without problem' do
25
+ fiber = Fiber.current
26
+ EventMachine.add_timer(0.1) do
27
+ fiber.resume
28
+ end
29
+
30
+ Fiber.yield
31
+
32
+ @count += 1
33
+
34
+ assert_equal 2, @count
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Wikman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-04 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2013-10-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: eventmachine
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: ''
14
28
  email:
15
29
  - mikael@wikman.me
@@ -17,8 +31,14 @@ executables: []
17
31
  extensions: []
18
32
  extra_rdoc_files: []
19
33
  files:
34
+ - CHANGELOG.mdown
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - LICENSE
38
+ - README.md
20
39
  - app.gemspec
21
40
  - lib/em-minitest.rb
41
+ - test/em_minitest_test.rb
22
42
  homepage: https://github.com/mikaelwikman/em-minitest
23
43
  licenses: []
24
44
  metadata: {}
@@ -42,4 +62,5 @@ rubygems_version: 2.0.3
42
62
  signing_key:
43
63
  specification_version: 4
44
64
  summary: Monkey-patch MiniTest to run each test within EventMachine reactor
45
- test_files: []
65
+ test_files:
66
+ - test/em_minitest_test.rb