etest-unit 0.9.1 → 0.10.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: 745dc1a9f7cead3a0e68b343e0d78a3f2b2cbee4
4
- data.tar.gz: 1063ea79bc5898059e9445d1a2a411f877e18519
3
+ metadata.gz: 49dfedc6f41677d57a5ce8e51e96e2e0fe49aa8e
4
+ data.tar.gz: ab68e4038e4073c622b70c2199ab88cbf6deddea
5
5
  SHA512:
6
- metadata.gz: 41d0fdde8e558a673d66a9d5baf2b7d94469289fc8c8a38faa1bc856a7cd66b1b7cae780b240deab5259c496f5dce2899ee7022a22ccb52c71e294126957b439
7
- data.tar.gz: 49ac104c599a0e2e9f5dbb3fe45d2c95ef601e27ac95c2f381c9c900be0fed24e1b32a0a736442e17d0e4467ee871b81e533feca8b6edd38a7dd8464b09cbc93
6
+ metadata.gz: 908583233e0479c17aea478dc9a2f984b710e87794e0c837044cbf8f89f81151041ccb228bdc43f1962415d92d9e75c49c4e85ac815a80035d138fe868cd0f60
7
+ data.tar.gz: bbc9b111a7407bb1818f59f40d614b983734bfa57b3df649acc0e5336b3f3fe11dda3ede23bdb486bbf9408aea9ca1f1c68476632cf268837f378495633f19c1
@@ -1,3 +1,3 @@
1
1
  module EtestUnit
2
- VERSION = "0.9.1"
2
+ VERSION = "0.10.0"
3
3
  end
data/lib/module_ext.rb CHANGED
@@ -7,50 +7,57 @@ 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
- if load(file)
25
- STDERR.puts("Loaded #{file}")
26
- file
27
- end
28
- rescue LoadError
29
- nfile = file.gsub(/\/[^\/]+\.rb/, ".rb")
30
- nfile != file && reload_file(nfile)
31
- end
32
- end
33
- end
34
-
35
10
  #
36
11
  # TDD helpers for modules.
37
12
  class Module
38
13
  #
39
14
  # reloads the module, and runs the module's etests.
40
15
  def etest(*args)
41
- EtestReloader.reload(name)
42
- if etests = const_get("Etest")
43
- EtestReloader.reload(etests.name)
44
- end
45
-
16
+ etests = const_get("Etest")
17
+ modules = [ self, etests ]
18
+ Reloader.reload *modules
46
19
  ::EtestUnit.run etests, *args
47
20
  end
48
21
 
22
+ module Reloader
23
+ def self.reload(*mods)
24
+ source_files = mods.map(&:source_files).flatten.uniq
25
+
26
+ # Skip files that live in .gem and .rvm directories.
27
+ source_files.reject! do |source_file|
28
+ source_file =~ /\/\.gem\// ||
29
+ source_file =~ /\/\.rvm\//
30
+ end
31
+
32
+ source_files.each do |source_file|
33
+ reload_file(source_file)
34
+ end
35
+ end
36
+
37
+ def self.reload_file(file)
38
+ r = load(file)
39
+ STDERR.puts("load #{file.inspect}: #{r ? "OK" : r.inspect}")
40
+ !!r
41
+ rescue LoadError
42
+ STDERR.puts "load #{file.inspect}: raised #{$!}"
43
+ false
44
+ end
45
+ end
46
+
49
47
  def reload
50
- EtestReloader.reload(name)
48
+ Reloader.reload(self)
51
49
  self
52
50
  end
53
51
 
52
+ def source_files
53
+ public_instance_methods(false).
54
+ map do |method_name| instance_method(method_name) end.
55
+ map(&:source_location).compact.
56
+ map(&:first).
57
+ uniq.
58
+ sort
59
+ end
60
+
54
61
  #
55
62
  # returns all instances of a module
56
63
  def instances #:nodoc:
@@ -0,0 +1,28 @@
1
+ module String::Etest
2
+ def test_underscore
3
+ $etest_stats[:underscore] += 1
4
+
5
+ assert_equal "x", "X".underscore
6
+ assert_equal "xa_la_nder", "XaLaNder".underscore
7
+ end
8
+
9
+ def test_camelize
10
+ $etest_stats[:camelize] += 1
11
+
12
+ assert_equal "X", "x".camelize
13
+ assert_equal "XaLaNder", "xa_la_nder".camelize
14
+ end
15
+
16
+ def test_camelize_lower
17
+ assert_equal "x", "x".camelize(:lower)
18
+ assert_equal "xaLaNder", "xa_la_nder".camelize(:lower)
19
+ end
20
+ end
21
+
22
+ module Fixnum::Etest
23
+ def test_success
24
+ $etest_stats[:success] += 1
25
+
26
+ assert true
27
+ end
28
+ end
data/test/etest_test.rb CHANGED
@@ -1,44 +1,22 @@
1
1
  #!/usr/bin/env ruby
2
- DIRNAME = File.expand_path File.dirname(__FILE__)
2
+ if !defined?(DIRNAME)
3
+ DIRNAME = File.expand_path File.dirname(__FILE__)
4
+ end
5
+
3
6
  Dir.chdir(DIRNAME)
4
7
 
5
- ETEST_TEST=true
8
+ if !defined?(ETEST_TEST)
9
+ ETEST_TEST=true
10
+ end
6
11
 
7
12
  require "etest-unit"
8
13
  require "expectation"
9
14
 
10
15
  # ---------------------------------------------------------------------
11
16
 
12
- $etest_stats = Hash.new(0)
13
-
14
- module String::Etest
15
- def test_underscore
16
- $etest_stats[:underscore] += 1
17
+ require_relative "./etest_test.inc.rb"
17
18
 
18
- assert_equal "x", "X".underscore
19
- assert_equal "xa_la_nder", "XaLaNder".underscore
20
- end
21
-
22
- def test_camelize
23
- $etest_stats[:camelize] += 1
24
-
25
- assert_equal "X", "x".camelize
26
- assert_equal "XaLaNder", "xa_la_nder".camelize
27
- end
28
-
29
- def test_camelize_lower
30
- assert_equal "x", "x".camelize(:lower)
31
- assert_equal "xaLaNder", "xa_la_nder".camelize(:lower)
32
- end
33
- end
34
-
35
- module Fixnum::Etest
36
- def test_success
37
- $etest_stats[:success] += 1
38
-
39
- assert true
40
- end
41
- end
19
+ $etest_stats = Hash.new(0)
42
20
 
43
21
  begin
44
22
  String.etest
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etest-unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-30 00:00:00.000000000 Z
11
+ date: 2014-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: Build your tests alongside your code.
@@ -30,11 +30,12 @@ executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
- - lib/etest-unit/version.rb
33
+ - README.md
34
34
  - lib/etest-unit.rb
35
+ - lib/etest-unit/version.rb
35
36
  - lib/module_ext.rb
36
37
  - lib/string_ext.rb
37
- - README.md
38
+ - test/etest_test.inc.rb
38
39
  - test/etest_test.rb
39
40
  homepage: http://github.com/radiospiel/etest
40
41
  licenses: []
@@ -45,17 +46,17 @@ require_paths:
45
46
  - lib
46
47
  required_ruby_version: !ruby/object:Gem::Requirement
47
48
  requirements:
48
- - - '>='
49
+ - - ">="
49
50
  - !ruby/object:Gem::Version
50
51
  version: '0'
51
52
  required_rubygems_version: !ruby/object:Gem::Requirement
52
53
  requirements:
53
- - - '>='
54
+ - - ">="
54
55
  - !ruby/object:Gem::Version
55
56
  version: '0'
56
57
  requirements: []
57
58
  rubyforge_project:
58
- rubygems_version: 2.0.3
59
+ rubygems_version: 2.2.2
59
60
  signing_key:
60
61
  specification_version: 4
61
62
  summary: Build your tests alongside your code.