analtester 0.0.1
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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +22 -0
- data/Rakefile +9 -0
- data/analtester.gemspec +23 -0
- data/bin/analtester +4 -0
- data/lib/analtester.rb +116 -0
- data/test/analtester_test.rb +27 -0
- data/test/test_helper.rb +2 -0
- metadata +78 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 JJ Buckley
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Analtester
|
2
|
+
|
3
|
+
A silly gem for generating minitest files
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install analtester
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
$ cd myproject
|
12
|
+
$ analtest
|
13
|
+
|
14
|
+
That's it.
|
15
|
+
|
16
|
+
## Contributing
|
17
|
+
|
18
|
+
1. Fork it
|
19
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
20
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
21
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
22
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/analtester.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "analtester"
|
7
|
+
gem.version = "0.0.1"
|
8
|
+
gem.authors = ["JJ Buckley"]
|
9
|
+
gem.email = ["jj@dawandamail.com"]
|
10
|
+
gem.description = %q{Makes some failing tests for you}
|
11
|
+
gem.summary = <<DESCRIPTION
|
12
|
+
analtester will look through your ./lib directory and create corresponding tests in test/.
|
13
|
+
They will all fail, until you write them. Use it to quickly populate an untested
|
14
|
+
library with tests. Just run `analtester` from the command-line in your project's root.
|
15
|
+
Requires minitest.
|
16
|
+
DESCRIPTION
|
17
|
+
gem.homepage = "http://github.com/jjbuckley/analtester"
|
18
|
+
|
19
|
+
gem.files = `git ls-files`.split($/)
|
20
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
21
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
22
|
+
gem.require_paths = ["lib"]
|
23
|
+
end
|
data/bin/analtester
ADDED
data/lib/analtester.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
class Analtester
|
5
|
+
include FileUtils
|
6
|
+
def self.run
|
7
|
+
new.run
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(dir = nil)
|
11
|
+
@dir = dir || Dir.pwd
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
ensure_test_helper
|
16
|
+
tests.each { |test| ensure_test(test) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def testfile(f)
|
20
|
+
self.class.testfile(f)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.testfile(f)
|
24
|
+
f.sub('lib/', 'test/').sub!(/\.rb/, '_test.rb')
|
25
|
+
end
|
26
|
+
|
27
|
+
def tests
|
28
|
+
libraries.map { |f| testfile(f) }
|
29
|
+
end
|
30
|
+
|
31
|
+
def libraries
|
32
|
+
Dir["#{@dir}/lib/**/*.rb"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def ensure_test_helper
|
36
|
+
ensure_test_directory
|
37
|
+
print test_helper + " "
|
38
|
+
if File.file?(test_helper)
|
39
|
+
puts "✓"
|
40
|
+
else
|
41
|
+
make_test_helper!
|
42
|
+
puts "Created"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def ensure_test_directory
|
47
|
+
print test_dir, " "
|
48
|
+
if File.directory?(test_dir)
|
49
|
+
puts "✓"
|
50
|
+
else
|
51
|
+
make_test_directory!
|
52
|
+
puts "Created"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_helper
|
57
|
+
File.join(test_dir, "test_helper.rb")
|
58
|
+
end
|
59
|
+
|
60
|
+
def make_test_helper!
|
61
|
+
File.open(test_helper, 'w') do |f|
|
62
|
+
f.puts <<-RUBY
|
63
|
+
require 'minitest/autorun'
|
64
|
+
RUBY
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def ensure_test(file)
|
69
|
+
ensure_directory(File.dirname(file))
|
70
|
+
print file, " "
|
71
|
+
if File.file?(file)
|
72
|
+
puts "✓"
|
73
|
+
else
|
74
|
+
make_test!(file)
|
75
|
+
puts "Created"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def ensure_directory(dir)
|
80
|
+
print dir, " "
|
81
|
+
if File.directory?(dir)
|
82
|
+
puts "✓"
|
83
|
+
else
|
84
|
+
mkdir_p(dir)
|
85
|
+
puts "Created"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def class_name(file)
|
90
|
+
# TODO - modules
|
91
|
+
basename = File.basename(file, File.extname(file))
|
92
|
+
basename.split('_').map { |s| s.chars.first.upcase + s.chars.to_a[1..-1].join }.join
|
93
|
+
end
|
94
|
+
|
95
|
+
def make_test!(file)
|
96
|
+
File.open(file, 'w') do |f|
|
97
|
+
f.puts <<-RUBY
|
98
|
+
require 'test_helper'
|
99
|
+
|
100
|
+
class #{class_name(file)} < Minitest::Unit::TestCase
|
101
|
+
def test_something
|
102
|
+
flunk "Write me."
|
103
|
+
end
|
104
|
+
end
|
105
|
+
RUBY
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def make_test_directory!
|
110
|
+
mkdir_p test_dir
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_dir
|
114
|
+
File.join(@dir, "test")
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class AnaltesterTest < MiniTest::Unit::TestCase
|
6
|
+
include FileUtils
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@home = pwd
|
10
|
+
@test_directory = Dir.mktmpdir
|
11
|
+
Dir.chdir(@test_directory)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_creation_of_tests
|
15
|
+
mkdir_p 'lib/foo/bar'
|
16
|
+
touch %w(lib/foo.rb lib/foo/bar.rb lib/foo/bar/baz.rb)
|
17
|
+
Analtester.new(@test_directory).run
|
18
|
+
assert File.exists?('test/foo/bar/baz_test.rb')
|
19
|
+
assert File.exists?('test/foo/bar_test.rb')
|
20
|
+
assert File.exists?('test/foo_test.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
Dir.chdir(@home)
|
25
|
+
rm_rf @test_directory
|
26
|
+
end
|
27
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: analtester
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- JJ Buckley
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-11-27 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Makes some failing tests for you
|
23
|
+
email:
|
24
|
+
- jj@dawandamail.com
|
25
|
+
executables:
|
26
|
+
- analtester
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- LICENSE.txt
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- analtester.gemspec
|
38
|
+
- bin/analtester
|
39
|
+
- lib/analtester.rb
|
40
|
+
- test/analtester_test.rb
|
41
|
+
- test/test_helper.rb
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: http://github.com/jjbuckley/analtester
|
44
|
+
licenses: []
|
45
|
+
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 3
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.3.7
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: analtester will look through your ./lib directory and create corresponding tests in test/. They will all fail, until you write them. Use it to quickly populate an untested library with tests. Just run `analtester` from the command-line in your project's root. Requires minitest.
|
76
|
+
test_files:
|
77
|
+
- test/analtester_test.rb
|
78
|
+
- test/test_helper.rb
|