etest-unit 0.7.6 → 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module EtestUnit
2
- VERSION = "0.7.6"
2
+ VERSION = "0.7.7"
3
3
  end
data/lib/module_ext.rb CHANGED
@@ -7,19 +7,46 @@ module Kernel
7
7
  end
8
8
  end
9
9
 
10
+ module EtestReloader
11
+ extend self
12
+
13
+ def reload(module_name)
14
+ reload_file("#{module_name.underscore}.rb") || begin
15
+ STDERR.puts("Warning: Cannot reload module #{module_name}")
16
+ false
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def reload_file(file)
23
+ begin
24
+ load(file) && file
25
+ rescue LoadError
26
+ nfile = file.gsub(/\/[^\/]+\.rb/, ".rb")
27
+ nfile != file && reload_file(nfile)
28
+ end
29
+ end
30
+ end
31
+
10
32
  #
11
33
  # TDD helpers for modules.
12
34
  class Module
13
35
  #
14
36
  # reloads the module, and runs the module's etests.
15
37
  def etest(*args)
16
- reload if respond_to?(:reload)
17
- etests = const_get("Etest")
18
- etests.reload if etests.respond_to?(:reload)
19
-
38
+ EtestReloader.reload(name)
39
+ if etests = const_get("Etest")
40
+ EtestReloader.reload(etests.name)
41
+ end
42
+
20
43
  ::EtestUnit.run etests, *args
21
44
  end
22
-
45
+
46
+ def reload
47
+ EtestReloader.reload(name)
48
+ end
49
+
23
50
  #
24
51
  # returns all instances of a module
25
52
  def instances #:nodoc:
@@ -38,31 +65,4 @@ class Module
38
65
  rescue NameError, LoadError
39
66
  nil
40
67
  end
41
-
42
- #
43
- # tries to reload the source file for this module. THIS IS A DEVELOPMENT
44
- # helper, don't try to use it in production mode!
45
- #
46
- # Limitations:
47
- #
48
- # To reload a module with a name of "X::Y" we try to load (in that order)
49
- # "x/y.rb", "x.rb"
50
- #
51
- def reload
52
- Module::Reloader.reload_file("#{to_s.underscore}.rb") || begin
53
- STDERR.puts("Warning: Cannot reload module #{self}")
54
- false
55
- end
56
- end
57
-
58
- module Reloader #:nodoc:
59
- def self.reload_file(file)
60
- begin
61
- load(file) && file
62
- rescue LoadError
63
- nfile = file.gsub(/\/[^\/]+\.rb/, ".rb")
64
- nfile != file && reload_file(nfile)
65
- end
66
- end
67
- end
68
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etest-unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-10 00:00:00.000000000 Z
12
+ date: 2013-07-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit
@@ -53,7 +53,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
53
  version: '0'
54
54
  segments:
55
55
  - 0
56
- hash: 2695061674860442636
56
+ hash: -4234680264188978204
57
57
  required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  none: false
59
59
  requirements: