etest 0.4.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gemspec ADDED
@@ -0,0 +1,2 @@
1
+ require "vex/gem"
2
+ Gem.spec File.dirname(__FILE__)
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ coverage
2
+ doc/rdoc
3
+ *log
4
+ pkg
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ load "#{File.dirname __FILE__}/vex/gem.rake"
2
+
1
3
  task :default => :test
2
4
 
3
5
  task :test do
@@ -11,7 +13,3 @@ end
11
13
  task :rdoc do
12
14
  sh "rdoc -o doc/rdoc"
13
15
  end
14
-
15
- Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext|
16
- puts ext
17
- load ext }
data/gem.yml CHANGED
@@ -1,12 +1,14 @@
1
- gem:
2
- description: Embedded testing
3
- url: http://github.com/pboy/etest
4
- author: pboy
5
- email: eno-pboy@open-lab.org
6
- ignore_pattern:
7
- - "tmp/*"
8
- - "**/.*"
9
- # runtime_dependencies:
10
- # - nokogiri
11
- # - htmlentities
12
- # - rdiscount
1
+ version: "0.6.0"
2
+ description: Embedded testing
3
+ summary: Embedded testing
4
+ # url: http://github.com/pboy/etest
5
+ author: pboy
6
+ email: eno-pboy@open-lab.org
7
+ # ignore_pattern:
8
+ # - "tmp/*"
9
+ # - "**/.*"
10
+ dependencies:
11
+ - dlog
12
+ # - nokogiri
13
+ # - htmlentities
14
+ # - rdiscount
@@ -169,43 +169,3 @@ end
169
169
  class MiniTest::Unit::TestCase
170
170
  include Etest::Assertions
171
171
  end
172
-
173
- unless defined?(ETEST_TEST)
174
-
175
- module Etest::Assertions::Etest
176
- #
177
- # this actually tests the existance of an assertion and one successful
178
- # assertion, nothing less, and nothing more...
179
- def test_asserts
180
- assert_respond_to "nsn", :upcase
181
- assert respond_to?(:assert_invalid)
182
- assert respond_to?(:assert_valid)
183
- end
184
-
185
- class TestError < RuntimeError; end
186
-
187
- def test_assert_raises_kind_of
188
- assert_raises_kind_of RuntimeError do
189
- raise TestError
190
- end
191
- end
192
-
193
- def test_assert_file_exist
194
- assert_file_exist __FILE__
195
- end
196
-
197
- def test_xml
198
- assert_valid_xml <<-XML
199
- <root>
200
- <p> lkhj </p>
201
- </root>
202
- XML
203
-
204
- assert_invalid_xml <<-XML
205
- <root>
206
- <p> lkhj </p>
207
- XML
208
- end
209
- end
210
- end
211
-
@@ -29,19 +29,3 @@ end
29
29
  class MiniTest::Unit::TestCase
30
30
  include ::Etest::ComparisonAssertions
31
31
  end
32
-
33
- unless defined?(ETEST_TEST)
34
-
35
- module Etest::ComparisonAssertions::Etest
36
- # I don't know how to test asserts. This, at least, give (fake) C0 coverage
37
- def test_comparision_assertions
38
- assert_lt 1, 2
39
- assert_le 1, 1
40
- assert_ge 2, 2
41
- assert_gt 2, 1
42
- assert_eq 2, 2
43
- assert_ne 1, 2
44
- end
45
- end
46
-
47
- end
data/lib/etest.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "rubygems"
2
+ require "dlog"
2
3
 
3
4
  begin
4
5
  require "minitest-rg"
@@ -9,7 +10,6 @@ end
9
10
 
10
11
  require File.dirname(__FILE__) + "/string_ext"
11
12
  require File.dirname(__FILE__) + "/module_ext"
12
- require File.dirname(__FILE__) + "/dlog_ext"
13
13
 
14
14
  #
15
15
  # Embedded test cases:
@@ -17,7 +17,6 @@ require File.dirname(__FILE__) + "/dlog_ext"
17
17
  # The Etest module contains methods to run etests.
18
18
  #
19
19
  module Etest
20
- VERSION=File.read(File.dirname(__FILE__) + "/../VERSION")
21
20
  end
22
21
 
23
22
  require File.dirname(__FILE__) + "/etest/assertions"
@@ -26,6 +25,12 @@ require File.dirname(__FILE__) + "/etest/comparison_assertions"
26
25
  class MiniTest::Unit::TestCase
27
26
  def self.run_etests(*test_cases)
28
27
  outside_etests = @@test_suites
28
+
29
+ if test_cases.empty?
30
+ dlog.warn "Found no etest test_cases"
31
+ return
32
+ end
33
+
29
34
  reset
30
35
 
31
36
  MiniTest::Unit::TestCase.reset
@@ -64,10 +69,10 @@ module Etest
64
69
  end
65
70
 
66
71
  def self.run(*etests)
67
- dlog "Running", etests
68
72
  #
69
73
  # convert all Etest modules into a test case
70
74
  test_cases = etests.map { |etest|
75
+ dlog "Running", etest
71
76
  to_test_case etest
72
77
  }
73
78
 
data/lib/string_ext.rb CHANGED
@@ -12,19 +12,3 @@ class String
12
12
  gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
13
13
  end
14
14
  end
15
-
16
- unless defined?(TEST_ETEST)
17
-
18
- module String::Etest
19
- def test_camelize
20
- assert_equal "x", "X".underscore
21
- assert_equal "xa_la_nder", "XaLaNder".underscore
22
- end
23
-
24
- def test_underscore
25
- assert_equal "X", "x".camelize
26
- assert_equal "XaLaNder", "xa_la_nder".camelize
27
- end
28
- end
29
-
30
- end
@@ -1,3 +1,14 @@
1
+ module Etest::ComparisonAssertions::Etest
2
+ # I don't know how to test asserts. This, at least, give (fake) C0 coverage
3
+ def test_comparision_assertions
4
+ assert_lt 1, 2
5
+ assert_le 1, 1
6
+ assert_ge 2, 2
7
+ assert_gt 2, 1
8
+ assert_eq 2, 2
9
+ assert_ne 1, 2
10
+ end
11
+ end
1
12
 
2
13
  module Etest::Assertions::Etest
3
14
  #
data/test/etest_string.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  module String::Etest
3
2
  def test_camelize
4
3
  assert_equal "x", "X".underscore
@@ -10,4 +9,3 @@ module String::Etest
10
9
  assert_equal "XaLaNder", "xa_la_nder".camelize
11
10
  end
12
11
  end
13
-
data/vex/gem.rake ADDED
@@ -0,0 +1,36 @@
1
+ def sys(*args)
2
+ STDERR.puts "#{args.join(" ")}"
3
+ system *args
4
+ end
5
+
6
+ namespace :gem do
7
+ task :build => :spec do
8
+ options = []
9
+ sys "gem build .gemspec #{options.join(" ")} && mkdir -p pkg && mv *.gem pkg"
10
+ end
11
+
12
+ task :spec do
13
+ File.open ".gemspec", "w" do |file|
14
+ file.write <<-TXT
15
+ require "vex/gem"
16
+ Gem.spec File.dirname(__FILE__)
17
+ TXT
18
+ end
19
+ end
20
+
21
+ task :install => :build do
22
+ file = Dir.glob("pkg/*.gem").sort.last
23
+ sys "gem install #{file}"
24
+ end
25
+
26
+ task :push => :build do
27
+ file = Dir.glob("pkg/*.gem").sort.last
28
+ puts "To push the gem to gemcutter please run"
29
+ puts
30
+ puts "\tgem push #{file}"
31
+ end
32
+ end
33
+
34
+ desc "Build gem"
35
+ # task :gem => %w(test gem:install)
36
+ task :gem => %w(gem:install gem:push)
data/vex/gem.rb ADDED
@@ -0,0 +1,95 @@
1
+ module Gem
2
+ (class << self; self; end).class_eval do
3
+ def default_attributes
4
+ %w(name version date files executables)
5
+ end
6
+
7
+ def set_root(root)
8
+ @root = File.expand_path(root)
9
+ @name = File.basename(@root)
10
+ @conf ||= YAML.load File.read("#{@root}/gem.yml")
11
+ @attributes ||= (default_attributes + @conf.keys.map(&:to_s)).uniq
12
+ end
13
+
14
+ # attr_reader :root, :conf, :attributes,
15
+ attr_reader :name
16
+
17
+ def attribute(name)
18
+ if @conf.key?(name) && !%w(dependencies).include?(name)
19
+ @conf[name]
20
+ else
21
+ self.send(name)
22
+ end
23
+ end
24
+
25
+ #
26
+ # create a new Gem::Specification object for this gem.
27
+ def spec(root)
28
+ self.set_root root
29
+
30
+ Gem::Specification.new do |s|
31
+ @attributes.each do |attr|
32
+ v = attribute(attr)
33
+ next if v.nil?
34
+
35
+ log attr, v
36
+
37
+ s.send attr + "=", v
38
+ end
39
+
40
+ %w(pre_uninstall post_install).each do |hook|
41
+ next unless File.exists?("#{root}/hooks/#{hook}.rb")
42
+ log hook, "yes"
43
+ Gem.send(hook) {
44
+ load "hooks/#{hook}.rb"
45
+ }
46
+ end
47
+ end
48
+ end
49
+
50
+ def log(attr, v)
51
+ v = case attr
52
+ when "files" then "#{v.length} files"
53
+ else v.inspect
54
+ end
55
+
56
+ STDERR.puts "#{"%20s" % attr}:\t#{v}"
57
+ end
58
+
59
+ def dependencies
60
+ return nil unless @conf["dependencies"]
61
+
62
+ @conf["dependencies"].map do |d|
63
+ Gem::Dependency.new d, ">= 0"
64
+ end
65
+ end
66
+
67
+ def head(file)
68
+ File.open(file) do |f|
69
+ f.readline
70
+ end
71
+ end
72
+
73
+ def executables
74
+ r = Dir.glob("#{@root}/bin/**/*").map do |file|
75
+ next unless head(file) =~ /^#!/
76
+ file[@root.length + 5 .. -1]
77
+ end.compact
78
+
79
+ return nil if r.empty?
80
+ r
81
+ end
82
+
83
+ #
84
+ # get files from git
85
+ def files
86
+ r = `git ls-files`.split("\n")
87
+ end
88
+
89
+ #
90
+ # return the date
91
+ def date
92
+ Date.today.to_s
93
+ end
94
+ end
95
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etest
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 2
10
- version: 0.4.2
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - pboy
@@ -15,32 +15,37 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-29 00:00:00 +02:00
18
+ date: 2010-12-08 00:00:00 +01:00
19
19
  default_executable:
20
- dependencies: []
21
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: dlog
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
22
35
  description: Embedded testing
23
36
  email: eno-pboy@open-lab.org
24
37
  executables: []
25
38
 
26
39
  extensions: []
27
40
 
28
- extra_rdoc_files:
29
- - lib/dlog_ext.rb
30
- - lib/etest.rb
31
- - lib/etest/assertions.rb
32
- - lib/etest/comparison_assertions.rb
33
- - lib/etest/grep.rb
34
- - lib/module_ext.rb
35
- - lib/string_ext.rb
36
- - tasks/echoe.rake
41
+ extra_rdoc_files: []
42
+
37
43
  files:
38
- - "#Rakefile#"
44
+ - .gemspec
45
+ - .gitignore
39
46
  - Rakefile
40
- - VERSION
41
47
  - gem.yml
42
48
  - init.rb
43
- - lib/dlog_ext.rb
44
49
  - lib/etest.rb
45
50
  - lib/etest/assertions.rb
46
51
  - lib/etest/comparison_assertions.rb
@@ -49,23 +54,19 @@ files:
49
54
  - lib/string_ext.rb
50
55
  - script/console
51
56
  - script/rebuild
52
- - tasks/echoe.rake
53
57
  - test/assertions.rb
54
58
  - test/etest_assertions.rb
55
59
  - test/etest_string.rb
56
60
  - test/test.rb
57
- - Manifest
58
- - etest.gemspec
61
+ - vex/gem.rake
62
+ - vex/gem.rb
59
63
  has_rdoc: true
60
- homepage: http://github.com/pboy/etest
64
+ homepage:
61
65
  licenses: []
62
66
 
63
67
  post_install_message:
64
- rdoc_options:
65
- - --line-numbers
66
- - --inline-source
67
- - --title
68
- - Etest
68
+ rdoc_options: []
69
+
69
70
  require_paths:
70
71
  - lib
71
72
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -82,14 +83,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
83
  requirements:
83
84
  - - ">="
84
85
  - !ruby/object:Gem::Version
85
- hash: 11
86
+ hash: 3
86
87
  segments:
87
- - 1
88
- - 2
89
- version: "1.2"
88
+ - 0
89
+ version: "0"
90
90
  requirements: []
91
91
 
92
- rubyforge_project: etest
92
+ rubyforge_project:
93
93
  rubygems_version: 1.3.7
94
94
  signing_key:
95
95
  specification_version: 3
data/#Rakefile# DELETED
@@ -1,18 +0,0 @@
1
- task :default => :test
2
-
3
- task :test do
4
- sh "ruby test/test.rb"
5
- end
6
-
7
- task :rcov do
8
- sh "cd test; rcov -o ../coverage -x ruby/.*/gems -x ^test.rb test.rb"
9
- end
10
-
11
- task :rdoc do
12
- sh "rdoc -o doc/rdoc"
13
- end
14
-
15
- Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext|
16
- puts ext
17
-
18
- 2B load ext }
data/Manifest DELETED
@@ -1,20 +0,0 @@
1
- #Rakefile#
2
- Rakefile
3
- VERSION
4
- gem.yml
5
- init.rb
6
- lib/dlog_ext.rb
7
- lib/etest.rb
8
- lib/etest/assertions.rb
9
- lib/etest/comparison_assertions.rb
10
- lib/etest/grep.rb
11
- lib/module_ext.rb
12
- lib/string_ext.rb
13
- script/console
14
- script/rebuild
15
- tasks/echoe.rake
16
- test/assertions.rb
17
- test/etest_assertions.rb
18
- test/etest_string.rb
19
- test/test.rb
20
- Manifest
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.4.2
data/etest.gemspec DELETED
@@ -1,30 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{etest}
5
- s.version = "0.4.2"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["pboy"]
9
- s.date = %q{2010-07-29}
10
- s.description = %q{Embedded testing}
11
- s.email = %q{eno-pboy@open-lab.org}
12
- s.extra_rdoc_files = ["lib/dlog_ext.rb", "lib/etest.rb", "lib/etest/assertions.rb", "lib/etest/comparison_assertions.rb", "lib/etest/grep.rb", "lib/module_ext.rb", "lib/string_ext.rb", "tasks/echoe.rake"]
13
- s.files = ["#Rakefile#", "Rakefile", "VERSION", "gem.yml", "init.rb", "lib/dlog_ext.rb", "lib/etest.rb", "lib/etest/assertions.rb", "lib/etest/comparison_assertions.rb", "lib/etest/grep.rb", "lib/module_ext.rb", "lib/string_ext.rb", "script/console", "script/rebuild", "tasks/echoe.rake", "test/assertions.rb", "test/etest_assertions.rb", "test/etest_string.rb", "test/test.rb", "Manifest", "etest.gemspec"]
14
- s.homepage = %q{http://github.com/pboy/etest}
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Etest"]
16
- s.require_paths = ["lib"]
17
- s.rubyforge_project = %q{etest}
18
- s.rubygems_version = %q{1.3.7}
19
- s.summary = %q{Embedded testing}
20
-
21
- if s.respond_to? :specification_version then
22
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
- s.specification_version = 3
24
-
25
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- else
27
- end
28
- else
29
- end
30
- end
data/lib/dlog_ext.rb DELETED
@@ -1,81 +0,0 @@
1
- module Dlog
2
- def dlog(*args)
3
- end
4
- end
5
-
6
- if !ENV["NO_DLOG"]
7
-
8
- module Dlog
9
- ROOT = if defined?(RAILS_ROOT)
10
- RAILS_ROOT
11
- else
12
- File.expand_path(Dir.getwd)
13
- end
14
-
15
- HOME = ENV["HOME"] + "/"
16
-
17
- def self.release!
18
- @release = true
19
- end
20
-
21
- def self.release?
22
- @release
23
- end
24
-
25
- def self.debug!
26
- @release = false
27
- end
28
-
29
- def self.debug?
30
- !@release
31
- end
32
-
33
- def self.quiet!
34
- @quiet = true
35
- end
36
-
37
- def self.quiet?
38
- @quiet
39
- end
40
-
41
- def dlog(*args)
42
- return if Dlog.quiet?
43
-
44
- msg = ""
45
- was_string = true
46
- args.map do |s|
47
- msg += was_string ? " " : ", " unless msg.empty?
48
- msg += ((was_string = s.is_a?(String)) ? s : s.inspect)
49
- end
50
- STDERR.puts "#{Dlog.release? ? rlog_caller : dlog_caller} #{msg}"
51
- end
52
-
53
- def rlog_caller
54
- if caller[1] =~ /^(.*):(\d+)/
55
- file, line = $1, $2
56
- "[" + File.basename(file).sub(/\.[^\.]*$/, "") + "]"
57
- else
58
- "[log]"
59
- end
60
- end
61
-
62
- def dlog_caller
63
- if caller[1] =~ /^(.*):(\d+)/
64
- file, line = $1, $2
65
- file = File.expand_path(file)
66
-
67
- file.gsub!(ROOT, ".") or
68
- file.gsub!(HOME, "~/")
69
-
70
- "#{file}(#{line}):"
71
- else
72
- "<dlog>:"
73
- end
74
- end
75
- end
76
-
77
- end
78
-
79
- class Object
80
- include Dlog
81
- end
data/tasks/echoe.rake DELETED
@@ -1,31 +0,0 @@
1
- #
2
- # GEM settings
3
- #
4
- GEM_ROOT = File.expand_path("#{File.dirname(__FILE__)}/..")
5
- if gem_config = YAML.load(File.read("#{GEM_ROOT}/gem.yml"))["gem"]
6
- require 'echoe'
7
-
8
- GEM_NAME = File.basename(GEM_ROOT)
9
- Echoe.new(File.basename(GEM_ROOT), File.read("#{GEM_ROOT}/VERSION")) do |p|
10
- gem_config.each do |k,v|
11
- p.send "#{k}=",v
12
- end
13
- end
14
-
15
- desc "Rebuild and install the gem"
16
- task :rebuild => %w(manifest default build_gemspec package) do
17
- gem = Dir.glob("pkg/*.gem").sort_by do |filename|
18
- File.new(filename).mtime
19
- end.last
20
-
21
- puts "============================================="
22
- puts "Installing gem..."
23
-
24
- system "gem install #{gem} > /dev/null 2>&1"
25
-
26
- puts ""
27
- puts "I built and installed the gem for you. To upload, run "
28
- puts
29
- puts " gem push #{gem}"
30
- end
31
- end