yamltest 0.5.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,18 +1,29 @@
1
- == yamltest 0.5.3 2009-06-17
1
+ == 0.7.0 2010-07-12
2
+
3
+ * 1 major improvement/change
4
+ * :directory paths first try to resolve as absolute paths
5
+
6
+ == 0.6.0 2010-05-13
7
+
8
+ * 2 minor improvements
9
+ * Renamed 'file method' created to hold the list of tests to 'xxx_tests'
10
+ * Using Jeweler to manage gem
11
+
12
+ == 0.5.3 2009-06-17
2
13
 
3
14
  * 1 minor improvement
4
15
  * Added support for spaces in method names
5
16
 
6
- == yamltest 0.5.2 2009-05-28
17
+ == 0.5.2 2009-05-28
7
18
 
8
19
  * 1 minor improvement
9
20
  * Added an option to disable generating 'src' from the test title
10
21
 
11
- == yamltest 0.5.1 2009-02-02
22
+ == 0.5.1 2009-02-02
12
23
 
13
24
  * Simplified gem specification (avoid hoe/newgem/etc dependency)
14
25
 
15
- == yamltest 0.5 2009-01-21
26
+ == 0.5 2009-01-21
16
27
 
17
28
  * 1 major improvement
18
29
  * First release after extraction from zena (http://zenadmin.org). [gaspard]
data/Rakefile CHANGED
@@ -1,123 +1,55 @@
1
- require "rubygems"
2
- require "rake/gempackagetask"
3
- require "rake/rdoctask"
4
- require 'lib/yamltest'
1
+ require 'rubygems'
2
+ require 'rake'
5
3
 
6
- task :default => :test
7
-
8
- require "rake/testtask"
9
- Rake::TestTask.new do |t|
10
- t.libs << "test"
11
- t.test_files = FileList["test/**/*_test.rb"]
12
- t.verbose = true
13
- end
14
-
15
- # This builds the actual gem. For details of what all these options
16
- # mean, and other ones you can add, check the documentation here:
17
- #
18
- # http://rubygems.org/read/chapter/20
19
- #
20
- spec = Gem::Specification.new do |s|
21
-
22
- # Change these as appropriate
23
- s.name = "yamltest"
24
- s.version = Yamltest::VERSION.to_s
25
- s.summary = "yamltest lets you configure unit test with yaml documents"
26
- s.author = 'Gaspard Bucher'
27
- s.email = 'gaspard@teti.ch'
28
- s.homepage = 'http://github.com/zena/yamltest/tree'
29
-
30
- s.has_rdoc = true
31
- s.extra_rdoc_files = %w(README.rdoc)
32
- s.rdoc_options = %w(--main README.rdoc)
33
-
34
- # Add any extra files to include in the gem
35
- s.files = %w(History.txt Manifest.txt Rakefile README.rdoc) + Dir.glob("{test,lib}/**/*")
36
-
37
- s.require_paths = ["lib"]
38
-
39
- # If you want to depend on other gems, add them here, along with any
40
- # relevant versions
41
- # s.add_dependency("some_other_gem", "~> 0.1.0")
42
-
43
- # If your tests use any gems, include them here
44
- # s.add_development_dependency("mocha")
45
-
46
- # If you want to publish automatically to rubyforge, you'll may need
47
- # to tweak this, and the publishing task below too.
48
- s.rubyforge_project = "yamltest"
49
- end
50
-
51
- # This task actually builds the gem. We also regenerate a static
52
- # .gemspec file, which is useful if something (i.e. GitHub) will
53
- # be automatically building a gem for this project. If you're not
54
- # using GitHub, edit as appropriate.
55
- Rake::GemPackageTask.new(spec) do |pkg|
56
- pkg.gem_spec = spec
57
-
58
- # Generate the gemspec file for github.
59
- file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
60
- File.open(file, "w") {|f| f << spec.to_ruby }
61
- end
4
+ require(File.join(File.dirname(__FILE__), 'lib/yamltest/version'))
62
5
 
63
- # Generate documentation
64
- Rake::RDocTask.new do |rd|
65
- rd.main = "README.rdoc"
66
- rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
67
- rd.rdoc_dir = "rdoc"
6
+ begin
7
+ require 'jeweler'
8
+ Jeweler::Tasks.new do |gem|
9
+ gem.version = Yamltest::VERSION
10
+ gem.name = "yamltest"
11
+ gem.summary = %Q{yamltest lets you configure unit test with yaml documents}
12
+ gem.description = %Q{yamltest lets you configure unit test with yaml documents}
13
+ gem.email = "gaspard@teti.ch"
14
+ gem.homepage = "http://github.com/zena/yamltest/tree"
15
+ gem.authors = ["Gaspard Bucher"]
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
68
21
  end
69
22
 
70
- desc 'Clear out RDoc and generated packages'
71
- task :clean => [:clobber_rdoc, :clobber_package] do
72
- rm "#{spec.name}.gemspec"
23
+ require 'rake/testtask'
24
+ Rake::TestTask.new(:test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.pattern = 'test/**/*_test.rb'
27
+ test.verbose = true
73
28
  end
74
29
 
75
- # If you want to publish to RubyForge automatically, here's a simple
76
- # task to help do that. If you don't, just get rid of this.
77
- # Be sure to set up your Rubyforge account details with the Rubyforge
78
- # gem; you'll need to run `rubyforge setup` and `rubyforge config` at
79
- # the very least.
80
30
  begin
81
- require "rake/contrib/sshpublisher"
82
- namespace :rubyforge do
83
-
84
- desc "Release gem and RDoc documentation to RubyForge"
85
- task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
86
-
87
- namespace :release do
88
- desc "Release a new version of this gem"
89
- task :gem => [:package] do
90
- require 'rubyforge'
91
- rubyforge = RubyForge.new
92
- rubyforge.configure
93
- rubyforge.login
94
- rubyforge.userconfig['release_notes'] = spec.summary
95
- path_to_gem = File.join(File.dirname(__FILE__), "pkg", "#{spec.name}-#{spec.version}.gem")
96
- puts "Publishing #{spec.name}-#{spec.version.to_s} to Rubyforge..."
97
- rubyforge.add_release(spec.rubyforge_project, spec.name, spec.version.to_s, path_to_gem)
98
- end
99
-
100
- desc "Publish RDoc to RubyForge."
101
- task :docs => [:rdoc] do
102
- config = YAML.load(
103
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
104
- )
105
-
106
- host = "#{config['username']}@rubyforge.org"
107
- remote_dir = "/var/www/gforge-projects/yamltest/" # Should be the same as the rubyforge project name
108
- local_dir = 'rdoc'
109
-
110
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
111
- end
112
- end
31
+ require 'rcov/rcovtask'
32
+ Rcov::RcovTask.new do |test|
33
+ test.libs << 'test'
34
+ test.pattern = 'test/**/*_test.rb'
35
+ test.verbose = true
113
36
  end
114
37
  rescue LoadError
115
- puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
38
+ task :rcov do
39
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
+ end
116
41
  end
117
42
 
118
- desc 'Generate the gemspec to serve this Gem from Github'
119
- task :github do
120
- file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
121
- File.open(file, 'w') {|f| f << spec.to_ruby }
122
- puts "Created gemspec: #{file}"
123
- end
43
+ task :test => :check_dependencies
44
+
45
+ task :default => :test
46
+
47
+ require 'rake/rdoctask'
48
+ Rake::RDocTask.new do |rdoc|
49
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "yamltest #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
data/lib/yamltest.rb CHANGED
@@ -1,27 +1,25 @@
1
1
  require 'test/unit'
2
2
  require 'yaml'
3
-
4
- $:.unshift(File.dirname(__FILE__)) unless
5
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+ require 'yamltest/version'
6
4
 
7
5
  module Yamltest
8
- VERSION = '0.5.3'
6
+
9
7
  module Helper
10
8
  def self.included(obj)
11
9
  obj.extend Yamltest::ClassMethods
12
10
  end
13
11
  end
14
-
12
+
15
13
  module ClassMethods
16
-
14
+
17
15
  # build an array of file_name, file_path, options
18
16
  def file_list(caller_path, opts)
19
17
  directories = opts[:directories] || [opts[:directory] || :default]
20
-
18
+
21
19
  if files = opts[:files]
22
20
  files.map!{|f| f.to_s}
23
21
  end
24
-
22
+
25
23
  directories = directories.map do |dir|
26
24
  if dir == :default
27
25
  if caller_path.split('/').last =~ /^(.*)_test.rb/ || caller_path.split('/').last =~ /^test_(.*).rb/
@@ -31,13 +29,18 @@ module Yamltest
31
29
  directories = [File.dirname(caller_path)]
32
30
  end
33
31
  else
34
- # relative to caller
35
- Dir[File.join(File.dirname(caller_path),dir)]
32
+ # GLOB absolute path
33
+ list = Dir[dir]
34
+ if list.empty?
35
+ # relative to caller
36
+ list = Dir[File.join(File.dirname(caller_path),dir)]
37
+ end
38
+ list
36
39
  end
37
- end.flatten
40
+ end.flatten.uniq
38
41
 
39
42
  file_list = []
40
-
43
+
41
44
  directories.each do |dir|
42
45
  Dir.foreach(dir) do |f|
43
46
  next unless f =~ /^([\w_-]+).yml/
@@ -45,11 +48,11 @@ module Yamltest
45
48
  file_list << [$1, File.join(dir, "#{$1}.yml"), opts[$1] || opts[$1.to_sym] || {}]
46
49
  end
47
50
  end
48
-
51
+
49
52
  file_list
50
53
  end
51
-
52
-
54
+
55
+
53
56
  # Setup yaml testing.
54
57
  # usage:
55
58
  # class SuperTest < Test::Unit::TestCase
@@ -75,14 +78,14 @@ module Yamltest
75
78
  # attr_accessor test_strings
76
79
  # end
77
80
  # and then use "self.test_strings"
78
-
81
+
79
82
  class_eval %Q{
80
83
  @@test_strings = {}
81
84
  @@test_methods = {}
82
85
  @@test_options = {}
83
86
  @@test_files = []
84
87
  @@file_list = file_list(#{caller[0].inspect}, #{opts.inspect})
85
-
88
+
86
89
  @@file_list.each do |file_name, file_path, opts|
87
90
  strings = {}
88
91
  test_methods = []
@@ -98,7 +101,7 @@ module Yamltest
98
101
  raise err
99
102
  end
100
103
  class_eval "
101
- def \#{file_name}
104
+ def \#{file_name}_tests
102
105
  @@test_strings['\#{file_name}']
103
106
  end
104
107
  "
@@ -106,19 +109,19 @@ module Yamltest
106
109
  @@test_methods[file_name] = test_methods
107
110
  @@test_files << file_name
108
111
  end
109
-
112
+
110
113
  # Override this in your test class
111
114
  def yt_parse(key, source, context)
112
115
  source
113
116
  end
114
-
117
+
115
118
  def yt_do_test(file, test, context = yt_get('context',file,test))
116
119
  @@test_strings[file][test].keys.each do |key|
117
120
  next if ['src', 'context'].include?(key)
118
121
  yt_assert yt_get(key,file,test), yt_parse(key, yt_get('src',file,test), context)
119
122
  end
120
123
  end
121
-
124
+
122
125
  protected
123
126
  def yt_assert(test_res, res)
124
127
  if test_res.kind_of?(String) && test_res[0..1] == '!/'
@@ -129,7 +132,7 @@ module Yamltest
129
132
  assert_equal test_res, res
130
133
  end
131
134
  end
132
-
135
+
133
136
  def yt_get(key, file, test)
134
137
  case key
135
138
  when 'context', :context
@@ -144,7 +147,7 @@ module Yamltest
144
147
  end
145
148
  }
146
149
  end
147
-
150
+
148
151
  def yt_make
149
152
  class_eval %q{
150
153
  return unless @@test_methods
@@ -1,13 +1,3 @@
1
1
  module Yamltest
2
- module Version
3
-
4
- MAJOR = 0
5
- MINOR = 5
6
- TINY = 3
7
-
8
- def self.to_s # :nodoc:
9
- [MAJOR, MINOR, TINY].join('.')
10
- end
11
-
12
- end
2
+ VERSION = '0.7.0'
13
3
  end
@@ -6,10 +6,10 @@ require 'yamltest'
6
6
 
7
7
  class TestYamltestGem < Test::Unit::TestCase
8
8
  yamltest :directory => '.'
9
-
9
+
10
10
  def yt_parse(key, source, context)
11
11
  source.split(//).reverse.join
12
12
  end
13
-
13
+
14
14
  yt_make
15
15
  end
@@ -0,0 +1,7 @@
1
+ default:
2
+ src: "other_folder_default"
3
+ res: 20
4
+
5
+ hello_world:
6
+ src: "other_folder_hello_world"
7
+ res: 24
@@ -13,23 +13,23 @@ end
13
13
 
14
14
  class TestDefaultFolder < Test::Unit::TestCase
15
15
  yamltest
16
-
16
+
17
17
  def yt_parse(key, source, context)
18
18
  eval(source)
19
19
  end
20
-
20
+
21
21
  def test_to_make_sure_tests_are_valid
22
22
  assert (respond_to?('test_simple_default') and
23
23
  (method('test_simple_default').arity == 0 ||
24
24
  method('test_simple_default').arity == -1))
25
25
  end
26
-
26
+
27
27
  yt_make
28
28
  end
29
29
 
30
30
  class TestCustomKeys < Test::Unit::TestCase
31
31
  yamltest :directory => 'zoo', :src_from_title => true
32
-
32
+
33
33
  def yt_parse(key, source, context)
34
34
  res = source.gsub('o', 'a')
35
35
  case key
@@ -43,13 +43,34 @@ class TestCustomKeys < Test::Unit::TestCase
43
43
  "bad test key #{key.inspect}"
44
44
  end
45
45
  end
46
-
46
+
47
47
  # This test will not be redefined by 'make_tests'
48
48
  def test_complicated_animal
49
49
  context = yt_get('context', 'complicated', 'animal')
50
50
  context['foo'] = 'bozo'
51
51
  yt_do_test('complicated', 'animal', context)
52
52
  end
53
-
53
+
54
+ yt_make
55
+ end
56
+
57
+ class TestCustomFolder < Test::Unit::TestCase
58
+ yamltest :directory => File.join(File.dirname(__FILE__), 'yamltest', 'other_folder')
59
+
60
+ def yt_parse(key, source, context)
61
+ puts source
62
+ case key
63
+ when 'res'
64
+ source.length
65
+ else
66
+ "bad test key #{key.inspect}"
67
+ end
68
+ end
69
+
70
+ def test_to_make_sure_tests_are_valid
71
+ assert respond_to?('test_bar_default')
72
+ assert respond_to?('test_bar_hello_world')
73
+ end
74
+
54
75
  yt_make
55
76
  end
data/yamltest.gemspec ADDED
@@ -0,0 +1,56 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{yamltest}
8
+ s.version = "0.7.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Gaspard Bucher"]
12
+ s.date = %q{2010-07-22}
13
+ s.description = %q{yamltest lets you configure unit test with yaml documents}
14
+ s.email = %q{gaspard@teti.ch}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "History.txt",
21
+ "Manifest.txt",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "lib/yamltest.rb",
25
+ "lib/yamltest/version.rb",
26
+ "test/gem_test/foo.yml",
27
+ "test/gem_test/simple_test.rb",
28
+ "test/test_helper.rb",
29
+ "test/yamltest/other_folder/bar.yml",
30
+ "test/yamltest/simple.yml",
31
+ "test/yamltest_test.rb",
32
+ "test/zoo/complicated.yml",
33
+ "yamltest.gemspec"
34
+ ]
35
+ s.homepage = %q{http://github.com/zena/yamltest/tree}
36
+ s.rdoc_options = ["--charset=UTF-8"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.3.6}
39
+ s.summary = %q{yamltest lets you configure unit test with yaml documents}
40
+ s.test_files = [
41
+ "test/gem_test/simple_test.rb",
42
+ "test/test_helper.rb",
43
+ "test/yamltest_test.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
+ else
52
+ end
53
+ else
54
+ end
55
+ end
56
+
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yamltest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 7
8
+ - 0
9
+ version: 0.7.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Gaspard Bucher
@@ -9,11 +14,11 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-06-18 00:00:00 +02:00
17
+ date: 2010-07-22 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
16
- description:
21
+ description: yamltest lets you configure unit test with yaml documents
17
22
  email: gaspard@teti.ch
18
23
  executables: []
19
24
 
@@ -22,48 +27,52 @@ extensions: []
22
27
  extra_rdoc_files:
23
28
  - README.rdoc
24
29
  files:
30
+ - .gitignore
25
31
  - History.txt
26
32
  - Manifest.txt
27
- - Rakefile
28
33
  - README.rdoc
29
- - test/gem_test
34
+ - Rakefile
35
+ - lib/yamltest.rb
36
+ - lib/yamltest/version.rb
30
37
  - test/gem_test/foo.yml
31
38
  - test/gem_test/simple_test.rb
32
39
  - test/test_helper.rb
33
- - test/yamltest
40
+ - test/yamltest/other_folder/bar.yml
34
41
  - test/yamltest/simple.yml
35
42
  - test/yamltest_test.rb
36
- - test/zoo
37
43
  - test/zoo/complicated.yml
38
- - lib/yamltest
39
- - lib/yamltest/version.rb
40
- - lib/yamltest.rb
44
+ - yamltest.gemspec
41
45
  has_rdoc: true
42
46
  homepage: http://github.com/zena/yamltest/tree
47
+ licenses: []
48
+
43
49
  post_install_message:
44
50
  rdoc_options:
45
- - --main
46
- - README.rdoc
51
+ - --charset=UTF-8
47
52
  require_paths:
48
53
  - lib
49
54
  required_ruby_version: !ruby/object:Gem::Requirement
50
55
  requirements:
51
56
  - - ">="
52
57
  - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
53
60
  version: "0"
54
- version:
55
61
  required_rubygems_version: !ruby/object:Gem::Requirement
56
62
  requirements:
57
63
  - - ">="
58
64
  - !ruby/object:Gem::Version
65
+ segments:
66
+ - 0
59
67
  version: "0"
60
- version:
61
68
  requirements: []
62
69
 
63
- rubyforge_project: yamltest
64
- rubygems_version: 1.3.1
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.6
65
72
  signing_key:
66
- specification_version: 2
73
+ specification_version: 3
67
74
  summary: yamltest lets you configure unit test with yaml documents
68
- test_files: []
69
-
75
+ test_files:
76
+ - test/gem_test/simple_test.rb
77
+ - test/test_helper.rb
78
+ - test/yamltest_test.rb