em-spec 0.2.1 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ pkg
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in em-spec.gemspec
4
+ gemspec
@@ -0,0 +1,44 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ em-spec (0.2.4)
5
+ bacon
6
+ eventmachine
7
+ rspec (~> 2.6.0)
8
+ test-unit
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ bacon (1.1.0)
14
+ diff-lcs (1.1.2)
15
+ eventmachine (0.12.10)
16
+ growl (1.0.3)
17
+ guard (0.5.1)
18
+ thor (~> 0.14.6)
19
+ guard-bundler (0.1.3)
20
+ bundler (>= 1.0.0)
21
+ guard (>= 0.2.2)
22
+ guard-rspec (0.2.0)
23
+ guard (>= 0.2.2)
24
+ rake (0.8.7)
25
+ rspec (2.6.0)
26
+ rspec-core (~> 2.6.0)
27
+ rspec-expectations (~> 2.6.0)
28
+ rspec-mocks (~> 2.6.0)
29
+ rspec-core (2.6.4)
30
+ rspec-expectations (2.6.0)
31
+ diff-lcs (~> 1.1.2)
32
+ rspec-mocks (2.6.0)
33
+ test-unit (2.3.1)
34
+ thor (0.14.6)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ em-spec!
41
+ growl
42
+ guard-bundler
43
+ guard-rspec
44
+ rake (= 0.8.7)
@@ -0,0 +1,9 @@
1
+ guard 'bundler' do
2
+ watch(/^Gemfile/)
3
+ watch(/^.+\.gemspec/)
4
+ end
5
+
6
+ guard 'rspec', :version => 2 do
7
+ watch(/^spec\/.*_spec\.rb/)
8
+ watch(/^lib\/(.*)\.rb/)
9
+ end
data/Rakefile CHANGED
@@ -1,19 +1,7 @@
1
1
  require 'rake/testtask'
2
-
3
- begin
4
- require 'jeweler'
5
- Jeweler::Tasks.new do |s|
6
- s.name = "em-spec"
7
- s.description = s.summary = "Simple BDD API for testing asynchronous Ruby/EventMachine code"
8
- s.email = "aman@tmm1.net"
9
- s.homepage = "http://github.com/joshbuddy/em-spec"
10
- s.authors = ["Aman Gupta"]
11
- s.files = FileList["[A-Z]*", "{lib,test}/**/*"]
12
- end
13
- Jeweler::GemcutterTasks.new
14
- rescue LoadError
15
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
16
- end
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ Bundler::GemHelper.install_tasks
17
5
 
18
6
  task :default => :spec
19
7
 
@@ -27,4 +15,5 @@ task :spec do
27
15
  sh('rake test') rescue nil
28
16
  sh('bacon test/bacon_spec.rb') rescue nil
29
17
  sh 'spec -f specdoc test/rspec_spec.rb test/rspec_fail_examples.rb'
30
- end
18
+ end
19
+
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.join(File.dirname(__FILE__), 'lib', 'em-spec', 'version')
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'em-spec'
7
+ s.version = EventMachine::Spec::VERSION
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
+ s.authors = ["Aman Gupta"]
10
+ s.summary = "Simple BDD API for testing asynchronous Ruby/EventMachine code"
11
+ s.description = "Simple BDD API for testing asynchronous Ruby/EventMachine code"
12
+ s.email = %q{aman@tmm1.net}
13
+ s.extra_rdoc_files = ['README.rdoc']
14
+ s.files = `git ls-files`.split("\n")
15
+ s.homepage = %q{http://github.com/joshbuddy/em-spec}
16
+ s.rdoc_options = ["--charset=UTF-8"]
17
+ s.require_paths = ["lib"]
18
+ s.rubygems_version = %q{1.3.7}
19
+ s.test_files = `git ls-files`.split("\n").select{|f| f =~ /^test/}
20
+ s.rubyforge_project = 'em-spec'
21
+
22
+ # dependencies
23
+ s.add_dependency 'rspec', '~> 2.6.0'
24
+ s.add_dependency 'bacon'
25
+ s.add_dependency 'test-unit'
26
+ s.add_dependency 'eventmachine'
27
+
28
+ if RUBY_PLATFORM.downcase.include?("darwin")
29
+ # also install growlnotify from the
30
+ # Extras/growlnotify/growlnotify.pkg in Growl disk image
31
+ s.add_development_dependency 'growl'
32
+ end
33
+
34
+ s.add_development_dependency 'guard-rspec'
35
+ s.add_development_dependency 'guard-bundler'
36
+ s.add_development_dependency 'rake', '= 0.8.7'
37
+
38
+ end
39
+
@@ -7,7 +7,7 @@ module EventMachine
7
7
  SpecTimeoutExceededError = Class.new(RuntimeError)
8
8
 
9
9
  def self.included(cls)
10
- ::Spec::Example::ExampleGroup.instance_eval "
10
+ ::RSpec::Core::ExampleGroup.instance_eval "
11
11
  @@_em_default_time_to_finish = nil
12
12
  def self.default_timeout(timeout)
13
13
  @@_em_default_time_to_finish = timeout
@@ -5,52 +5,61 @@ module EventMachine
5
5
  TestTimeoutExceededError = Class.new(RuntimeError)
6
6
 
7
7
  module TestHelper
8
-
8
+
9
9
  def self.included(cls)
10
10
  cls.class_eval(<<-HERE_DOC, __FILE__, __LINE__)
11
11
  DefaultTimeout = nil unless const_defined?(:DefaultTimeout)
12
-
12
+
13
13
  def self.default_timeout(timeout)
14
- self.send(:remove_const, :DefaultTimeout)
15
- self.send(:const_set, :DefaultTimeout, timeout)
14
+
15
+ if self.const_defined? :DefaultTimeout
16
+ self.ancestors.each do |cls|
17
+ begin
18
+ cls.send(:remove_const, :DefaultTimeout)
19
+ cls.send(:const_set, :DefaultTimeout, timeout)
20
+ break
21
+ rescue
22
+ end
23
+ end
24
+ else
25
+ self.send(:const_set, :DefaultTimeout, timeout)
26
+ end
16
27
  end
17
-
28
+
18
29
  def current_default_timeout
19
30
  DefaultTimeout
20
31
  end
21
32
  HERE_DOC
22
-
23
33
  end
24
-
25
-
34
+
26
35
  def timeout(time_to_run)
27
36
  EM.cancel_timer(@_em_timer) if @_em_timer
28
37
  @_em_timer = EM.add_timer(time_to_run) { done('timeout exceeded') }
29
38
  end
30
-
39
+
31
40
  def em(time_to_run = current_default_timeout, &block)
32
41
  @flunk_test = nil
33
42
  EM.run do
34
43
  timeout(time_to_run) if time_to_run
35
44
  em_spec_exception = nil
36
45
  @_em_spec_fiber = Fiber.new do
37
- begin
46
+ @_output = begin
38
47
  block.call
39
48
  rescue Exception => em_spec_exception
40
49
  done
41
50
  end
42
51
  Fiber.yield
43
52
  end
44
-
45
53
  @_em_spec_fiber.resume
46
-
54
+
47
55
  raise em_spec_exception if em_spec_exception
48
- end
49
- raise(@flunk_test) if @flunk_test
56
+ end
57
+ raise(@flunk_test) if @flunk_test
58
+ @_output
50
59
  end
51
60
 
52
61
  def done(flunk_reason = nil)
53
- EM.next_tick{
62
+ EM.next_tick {
54
63
  @flunk_test = flunk_reason
55
64
  finish_em_spec_fiber
56
65
  }
@@ -62,31 +71,29 @@ module EventMachine
62
71
  EM.stop_event_loop if EM.reactor_running?
63
72
  @_em_spec_fiber.resume if @_em_spec_fiber.alive?
64
73
  end
65
-
74
+
66
75
  end
67
-
76
+
68
77
  module Test
69
-
78
+
70
79
  def self.included(cls)
71
80
  cls.class_eval(<<-HERE_DOC, __FILE__, __LINE__)
72
- def self.default_timeout(timeout)
73
- self.send(:remove_const, :DefaultTimeout)
74
- self.send(:const_set, :DefaultTimeout, timeout)
75
- end
76
-
77
81
  include TestHelper
78
82
 
79
83
  alias_method :run_without_em, :run
80
84
  def run(result, &block)
81
85
  em(DefaultTimeout) { run_without_em(result, &block) }
82
- rescue Exception
83
- add_error($!)
86
+ rescue Exception => e
87
+ if RUBY_VERSION >= "1.9.1"
88
+ result.puke(self.class, @name, e)
89
+ else
90
+ add_error($!)
91
+ end
84
92
  end
85
-
93
+
86
94
  HERE_DOC
87
-
88
95
  end
89
-
96
+
90
97
  end
91
-
92
- end
98
+
99
+ end
@@ -0,0 +1,5 @@
1
+ module EventMachine
2
+ module Spec
3
+ VERSION = '0.2.4'
4
+ end
5
+ end
File without changes
@@ -17,8 +17,8 @@ describe EventMachine, "when testing with EM::SpecHelper" do
17
17
  em do
18
18
  start = Time.now
19
19
 
20
- EM.add_timer(0.5){
21
- (Time.now-start).should be_close( 0.5, 0.1 )
20
+ EM.add_timer(0.5) {
21
+ (Time.now - start).should be_within(0.1).of(0.5)
22
22
  done
23
23
  }
24
24
  end
@@ -35,8 +35,8 @@ describe EventMachine, "when testing with EM::Spec" do
35
35
  it 'should have timers' do
36
36
  start = Time.now
37
37
 
38
- EM.add_timer(0.5){
39
- (Time.now-start).should be_close( 0.5, 0.1 )
38
+ EM.add_timer(0.5) {
39
+ (Time.now - start).should be_within(0.5).of(0.5)
40
40
  done
41
41
  }
42
42
  end
@@ -45,9 +45,9 @@ describe EventMachine, "when testing with EM::Spec" do
45
45
  num = 0
46
46
  start = Time.now
47
47
 
48
- timer = EM.add_periodic_timer(0.5){
48
+ timer = EM.add_periodic_timer(0.5) {
49
49
  if (num += 1) == 2
50
- (Time.now-start).should be_close( 1.0, 0.1 )
50
+ (Time.now - start).should be_within(1).of(0.5)
51
51
  EM.__send__ :cancel_timer, timer
52
52
  done
53
53
  end
@@ -68,7 +68,7 @@ describe EventMachine, "when testing with EM::Spec with a maximum execution time
68
68
 
69
69
  include EM::Spec
70
70
 
71
- default_timeout 2
71
+ default_timeout 4
72
72
 
73
73
  it 'should timeout before reaching done' do
74
74
  EM.add_timer(3) {
@@ -1,7 +1,9 @@
1
+ $LOAD_PATH.unshift "lib"
2
+
1
3
  require 'test/unit'
2
4
  require 'rubygems'
3
5
  require 'eventmachine'
4
- require 'lib/em-spec/test'
6
+ require 'em-spec/test'
5
7
 
6
8
  class NormalTest < Test::Unit::TestCase
7
9
  def test_trivial
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ hash: 31
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 4
10
+ version: 0.2.4
5
11
  platform: ruby
6
12
  authors:
7
13
  - Aman Gupta
@@ -9,10 +15,125 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-01-16 00:00:00 -05:00
18
+ date: 2011-08-07 00:00:00 -07:00
13
19
  default_executable:
14
- dependencies: []
15
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 23
29
+ segments:
30
+ - 2
31
+ - 6
32
+ - 0
33
+ version: 2.6.0
34
+ requirement: *id001
35
+ name: rspec
36
+ type: :runtime
37
+ - !ruby/object:Gem::Dependency
38
+ prerelease: false
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ requirement: *id002
49
+ name: bacon
50
+ type: :runtime
51
+ - !ruby/object:Gem::Dependency
52
+ prerelease: false
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirement: *id003
63
+ name: test-unit
64
+ type: :runtime
65
+ - !ruby/object:Gem::Dependency
66
+ prerelease: false
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ requirement: *id004
77
+ name: eventmachine
78
+ type: :runtime
79
+ - !ruby/object:Gem::Dependency
80
+ prerelease: false
81
+ version_requirements: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ requirement: *id005
91
+ name: growl
92
+ type: :development
93
+ - !ruby/object:Gem::Dependency
94
+ prerelease: false
95
+ version_requirements: &id006 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ requirement: *id006
105
+ name: guard-rspec
106
+ type: :development
107
+ - !ruby/object:Gem::Dependency
108
+ prerelease: false
109
+ version_requirements: &id007 !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 0
117
+ version: "0"
118
+ requirement: *id007
119
+ name: guard-bundler
120
+ type: :development
121
+ - !ruby/object:Gem::Dependency
122
+ prerelease: false
123
+ version_requirements: &id008 !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - "="
127
+ - !ruby/object:Gem::Version
128
+ hash: 49
129
+ segments:
130
+ - 0
131
+ - 8
132
+ - 7
133
+ version: 0.8.7
134
+ requirement: *id008
135
+ name: rake
136
+ type: :development
16
137
  description: Simple BDD API for testing asynchronous Ruby/EventMachine code
17
138
  email: aman@tmm1.net
18
139
  executables: []
@@ -22,16 +143,22 @@ extensions: []
22
143
  extra_rdoc_files:
23
144
  - README.rdoc
24
145
  files:
146
+ - .gitignore
147
+ - .rspec
148
+ - Gemfile
149
+ - Gemfile.lock
150
+ - Guardfile
25
151
  - README.rdoc
26
152
  - Rakefile
27
- - VERSION
153
+ - em-spec.gemspec
28
154
  - lib/em-spec/bacon.rb
29
155
  - lib/em-spec/rspec.rb
30
156
  - lib/em-spec/test.rb
157
+ - lib/em-spec/version.rb
31
158
  - lib/ext/fiber18.rb
159
+ - spec/rspec_fail_examples.rb
160
+ - spec/rspec_spec.rb
32
161
  - test/bacon_spec.rb
33
- - test/rspec_fail_examples.rb
34
- - test/rspec_spec.rb
35
162
  - test/test_spec.rb
36
163
  has_rdoc: true
37
164
  homepage: http://github.com/joshbuddy/em-spec
@@ -43,26 +170,30 @@ rdoc_options:
43
170
  require_paths:
44
171
  - lib
45
172
  required_ruby_version: !ruby/object:Gem::Requirement
173
+ none: false
46
174
  requirements:
47
175
  - - ">="
48
176
  - !ruby/object:Gem::Version
177
+ hash: 3
178
+ segments:
179
+ - 0
49
180
  version: "0"
50
- version:
51
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
+ none: false
52
183
  requirements:
53
184
  - - ">="
54
185
  - !ruby/object:Gem::Version
186
+ hash: 3
187
+ segments:
188
+ - 0
55
189
  version: "0"
56
- version:
57
190
  requirements: []
58
191
 
59
- rubyforge_project:
60
- rubygems_version: 1.3.5
192
+ rubyforge_project: em-spec
193
+ rubygems_version: 1.6.2
61
194
  signing_key:
62
195
  specification_version: 3
63
196
  summary: Simple BDD API for testing asynchronous Ruby/EventMachine code
64
197
  test_files:
65
198
  - test/bacon_spec.rb
66
- - test/rspec_fail_examples.rb
67
- - test/rspec_spec.rb
68
199
  - test/test_spec.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.1