gregwebs-quicktest 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +145 -0
- data/bin/quickspec +3 -0
- data/lib/quicktest.rb +238 -0
- data/spec/__test.rb +7 -0
- data/spec/test.rb +141 -0
- data/tasks/gregproject.rake +65 -0
- data/tasks/helpers.rb +36 -0
- metadata +91 -0
data/README
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
|
3
|
+
== Summary
|
4
|
+
Quicktest - A utility for inlining ruby unit tests with the ruby code under test
|
5
|
+
|
6
|
+
== Example
|
7
|
+
run with bin/quickspec
|
8
|
+
|
9
|
+
=end rdoc
|
10
|
+
|
11
|
+
class Foo
|
12
|
+
def initialize
|
13
|
+
@bar = true
|
14
|
+
end
|
15
|
+
def quicktest
|
16
|
+
it "bar should be initialized to true" do
|
17
|
+
@bar.should == true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.hello arg
|
22
|
+
"hello" + arg
|
23
|
+
end
|
24
|
+
def self.quicktest meth
|
25
|
+
it "should prepend 'hello' to its argument" do
|
26
|
+
meth["world"].should == 'hello world' # error - no space 'helloworld'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
=begin rdoc
|
32
|
+
|
33
|
+
Running quicktest on the source of this README file outputs the following:
|
34
|
+
.F
|
35
|
+
|
36
|
+
1)
|
37
|
+
'Foo hello should prepend 'hello' to its argument' FAILED
|
38
|
+
expected: "hello world",
|
39
|
+
got: "helloworld" (using ==)
|
40
|
+
./README:22:in `quicktest'
|
41
|
+
/home/greg/quicktest/lib/quicktest.rb:65:in `instance_eval'
|
42
|
+
/home/greg/quicktest/lib/quicktest.rb:65:in `run_tests'
|
43
|
+
|
44
|
+
Finished in 0.008338 seconds
|
45
|
+
|
46
|
+
2 examples, 1 failure
|
47
|
+
|
48
|
+
== Usage
|
49
|
+
=== Install
|
50
|
+
|
51
|
+
gem install quicktest
|
52
|
+
|
53
|
+
=== test code
|
54
|
+
To test a method, place another method called 'quicktest' immediately after it
|
55
|
+
the quicktest method has one OPTIONAL argument:
|
56
|
+
- a method object for the method under test
|
57
|
+
|
58
|
+
=== execution
|
59
|
+
run with
|
60
|
+
|
61
|
+
spec -r quicktest file_to_test
|
62
|
+
|
63
|
+
There is a convenience script so that you can just run
|
64
|
+
|
65
|
+
quickspec file_to_test
|
66
|
+
|
67
|
+
== Author and License
|
68
|
+
Copyright (c) 2008 Greg Weber, http://gregweber.info
|
69
|
+
Licensed under the MIT license
|
70
|
+
|
71
|
+
== About
|
72
|
+
|
73
|
+
The typical test driven development workflow requires constant switching between the file containg the source code and the the file containg the tests. When creating code, it is much faster to be able to place tests immediately after the code you are writing. After the code has been written, it may be a good idea to move it to another file.
|
74
|
+
|
75
|
+
Quicktest is designed to support quick tests in a framework agnostic way. Currently, only an rspec testrunner is available, but it is trivial to write one for another testing framework.
|
76
|
+
|
77
|
+
Quicktest uses method tracing to know the method you are testing. By default the output of a failed test will show the object and method name.
|
78
|
+
|
79
|
+
== Install
|
80
|
+
gem install quicktest
|
81
|
+
|
82
|
+
== Source
|
83
|
+
=== browser
|
84
|
+
http://github.com/gregwebs/quicktest/tree/master
|
85
|
+
|
86
|
+
=== repository
|
87
|
+
git clone git://github.com/gregwebs/quicktest.git
|
88
|
+
|
89
|
+
== Homepage
|
90
|
+
http://gregweber.info/projects/quicktest.html
|
91
|
+
|
92
|
+
== RDoc documentation
|
93
|
+
included with the gem
|
94
|
+
|
95
|
+
== Important Notes
|
96
|
+
- def quicktest will instantiate an object for the class you are testing, which gives a convenient referenct to self in the quicktest method. However, it calls new() without any parameters. If you need parameters for new(), you will have to use def self.quicktest and call new() yourself
|
97
|
+
|
98
|
+
== Configuration
|
99
|
+
- when testing module instance methods, the module is included into an anonymous class. By default, that class inherits from Object. To change this you must define an object that the module will be included into by defining the following in the module:
|
100
|
+
|
101
|
+
def self.quicktest_include_into; String end
|
102
|
+
|
103
|
+
- you can change the testing method name from quicktest to something else using the command line option
|
104
|
+
|
105
|
+
--quicktest better_testing_name
|
106
|
+
|
107
|
+
== TroubleShooting
|
108
|
+
- quicktest methods not working properly? if the class (or one of its ancestors) is overriding method tracing then including QuickTest::Tracer will fix it, but you should also fix the class or its ancestor.
|
109
|
+
|
110
|
+
== Unimportant Notes
|
111
|
+
=== production performance
|
112
|
+
leaving test code in with your production code is not necessarily a good idea, but you can put
|
113
|
+
|
114
|
+
remove_method :quicktest
|
115
|
+
|
116
|
+
at the bottom of a class to completely remove the quicktest method
|
117
|
+
|
118
|
+
=== rationals
|
119
|
+
* tests for scripts
|
120
|
+
Definitely very useful for one file scripts, or any type of code that does not have a well established project home where the tests will be. You can distribute the tests with script so that anyone who wants to modify it can also modify the tests instead of assuming the original author did not write any.
|
121
|
+
You can have a flow of development where a 'quick and dirty' script becomes well tested. Here is a shell function that tests the file before every run.
|
122
|
+
function test_run () { quickspec $1 && $1 }
|
123
|
+
* documentation
|
124
|
+
Tests are a form of documentation. It can be argued that it is better to have all documentation include in the source
|
125
|
+
|
126
|
+
* efficient TDD and prototyping
|
127
|
+
When writing fresh code you now have the possibility to be directly next to the code under test without having to switch back and forth between files. When you are done writing the new code, you can easily pull all the quicktest methods out and into a spec file.
|
128
|
+
|
129
|
+
|
130
|
+
=== Origins
|
131
|
+
Quicktest came out of my dabbling in the D programming language, which allows you to place testing blocks inline with your source code
|
132
|
+
unittest{
|
133
|
+
...
|
134
|
+
}
|
135
|
+
|
136
|
+
Normally, these blocks are ignored, but if you compile with a different switch, they are linked in and ran at the beginning of your program.
|
137
|
+
Originally, I made an exact copy of this, but among other things, it requires the placement of a line like
|
138
|
+
(def unittest;end) if not defined? unittest
|
139
|
+
at the beginning of the file. It would be nice if Ruby had a similar construct built in to the language.
|
140
|
+
|
141
|
+
=== implementation
|
142
|
+
Quicktest uses method tracing to know the method you are testing. For the object under test, testing methods are included into it, and then the test is run.
|
143
|
+
|
144
|
+
|
145
|
+
=end rdoc
|
data/bin/quickspec
ADDED
data/lib/quicktest.rb
ADDED
@@ -0,0 +1,238 @@
|
|
1
|
+
# :main: README
|
2
|
+
|
3
|
+
# TODO
|
4
|
+
# allow self.quicktest after instance method, and quicktest after a class method
|
5
|
+
# test module instance methods by setting the quicktest object to include them into
|
6
|
+
|
7
|
+
module QuickTest
|
8
|
+
|
9
|
+
# create module variables
|
10
|
+
class << self
|
11
|
+
# then name of the testing method, default is :quicktest
|
12
|
+
attr_accessor :test_method
|
13
|
+
|
14
|
+
# don't record the fact that we add Module.method_added
|
15
|
+
attr_accessor :ignore_first_method_added
|
16
|
+
|
17
|
+
# set which code will be running the tests
|
18
|
+
attr_accessor :runner, :runner_module
|
19
|
+
|
20
|
+
# when testing module instance methods
|
21
|
+
# this defines the class to include a module into
|
22
|
+
# user sets this by defining self.quicktest_include_into in a module
|
23
|
+
# otherwise, a generic class is used
|
24
|
+
attr_accessor :include_module_into
|
25
|
+
|
26
|
+
attr_accessor :last_self
|
27
|
+
end
|
28
|
+
|
29
|
+
# to reuse this implementation
|
30
|
+
# - create a module specific to the testing system
|
31
|
+
# - and then add a flag at the bottom of this file to
|
32
|
+
# set QuickTest.runner_module to the new module
|
33
|
+
# The module should
|
34
|
+
# - implement any methods to be publicly available in the quicktest method
|
35
|
+
# - contain the constants
|
36
|
+
# * QuickTestIgnoreClasses
|
37
|
+
# * QuickTestIncludeModules
|
38
|
+
#
|
39
|
+
# see RSpecTestRunner as an example
|
40
|
+
#
|
41
|
+
# it is possible to write a test runner without re-using this code.
|
42
|
+
# The test runner class to be used is set at the bottom of this file
|
43
|
+
# with QuickTest.runner =
|
44
|
+
class TestRunner
|
45
|
+
class << self
|
46
|
+
attr_accessor :methods, :tested_self
|
47
|
+
end
|
48
|
+
|
49
|
+
# keep a list of all traced methods
|
50
|
+
self.methods = []
|
51
|
+
def self.add_method meth
|
52
|
+
self.methods.push meth
|
53
|
+
end
|
54
|
+
def self.add_singleton_method meth
|
55
|
+
self.methods.push meth
|
56
|
+
end
|
57
|
+
|
58
|
+
def initialize tested, included_module=nil
|
59
|
+
self.class.tested_self = tested
|
60
|
+
|
61
|
+
q = tested.method QuickTest.test_method
|
62
|
+
tested.extend(QuickTest.runner_module)
|
63
|
+
QuickTest.runner_module::QuickTestIncludeModules.each do |mod|
|
64
|
+
tested.extend mod
|
65
|
+
end
|
66
|
+
|
67
|
+
case q.arity
|
68
|
+
when 0 then q.call
|
69
|
+
when 1 then q.call tested.method(self.class.methods[-1])
|
70
|
+
else raise ArgumentError, "to many arguments for #{QuickTest.test_method} method"
|
71
|
+
end
|
72
|
+
|
73
|
+
tested.send :__quicktest_run_tests__
|
74
|
+
|
75
|
+
# removing the quicktest method will prevent Ruby from warning about the method being redefined
|
76
|
+
if tested.kind_of?(Class) or tested.kind_of?(Module)
|
77
|
+
# TODO: errors for some cases here
|
78
|
+
unless included_module
|
79
|
+
class << tested
|
80
|
+
remove_method QuickTest.test_method
|
81
|
+
end
|
82
|
+
end
|
83
|
+
else
|
84
|
+
tested.class.class_eval { remove_method QuickTest.test_method }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# all public instance methods are RSpec method wrappers
|
90
|
+
module RSpecTestRunner
|
91
|
+
QuickTestIgnoreClasses = [/^Spec/]
|
92
|
+
QuickTestIncludeModules = [Spec::Matchers]
|
93
|
+
@@quicktests = Hash.new
|
94
|
+
@@after_block = nil
|
95
|
+
@@before_block = nil
|
96
|
+
|
97
|
+
def before( *args, &block ) @@before_block = [args, block] end
|
98
|
+
def after( *args, &block ) @@after_block = [args, block] end
|
99
|
+
def it specification, &block
|
100
|
+
@@quicktests[(TestRunner.methods.pop.to_s << ' ' << specification)] = block
|
101
|
+
TestRunner.methods.clear
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
def __quicktest_run_tests__ # :nodoc:
|
106
|
+
before_args, before_block = @@before_block
|
107
|
+
after_args, after_block = @@after_block
|
108
|
+
tests = @@quicktests
|
109
|
+
|
110
|
+
describe( TestRunner.tested_self.to_s ) do
|
111
|
+
before(*before_args) { before_block.call } if before_block
|
112
|
+
after(*after_args) { after_block.call } if after_block
|
113
|
+
|
114
|
+
tests.each_pair do |spec, test_block|
|
115
|
+
it( spec ) { test_block.call }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
@@quicktests.clear
|
119
|
+
@@after_block &&= nil
|
120
|
+
@@before_block &&= nil
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# if the class under test (or one of its ancestors)
|
125
|
+
# is overriding method tracing then it must include QuickTest::Tracer
|
126
|
+
module Tracer
|
127
|
+
def self.included(into)
|
128
|
+
if into == Class or into == Module # default include in in Module
|
129
|
+
self.tracer_include into
|
130
|
+
else
|
131
|
+
self.tracer_include(class<<into;self;end)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.tracer_include(meta)
|
136
|
+
meta.module_eval do
|
137
|
+
|
138
|
+
# monkeypatch the two hook methods called on method creation
|
139
|
+
# so they will still be called for any method other than _quicktest_
|
140
|
+
alias_method :__quicktest_singleton_method_added__, :singleton_method_added
|
141
|
+
alias_method :__quicktest_method_added__, :method_added
|
142
|
+
|
143
|
+
# ruby tracing hook
|
144
|
+
def singleton_method_added traced
|
145
|
+
# avoid infinite recursion if module is included into a class by a user
|
146
|
+
return if traced == QuickTest.runner.methods.last
|
147
|
+
|
148
|
+
if QuickTest.last_self != self
|
149
|
+
QuickTest.last_self = self
|
150
|
+
QuickTest.include_module_into = Object
|
151
|
+
end
|
152
|
+
|
153
|
+
if traced == QuickTest.test_method
|
154
|
+
QuickTest.runner.new self
|
155
|
+
|
156
|
+
elsif traced == :quicktest_include_into
|
157
|
+
QuickTest.include_module_into = self.quicktest_include_into
|
158
|
+
|
159
|
+
else
|
160
|
+
QuickTest.runner.add_singleton_method traced
|
161
|
+
__quicktest_singleton_method_added__ traced
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
QuickTest.ignore_first_method_added = true
|
166
|
+
|
167
|
+
# ruby tracing hook
|
168
|
+
def method_added traced
|
169
|
+
qt = QuickTest
|
170
|
+
# avoid infinite recursion if module is included into a class by a user
|
171
|
+
return if traced == qt.runner.methods.last
|
172
|
+
|
173
|
+
if traced == QuickTest.test_method
|
174
|
+
begin
|
175
|
+
qt.runner.new( *
|
176
|
+
if self.class != Module
|
177
|
+
[self.new]
|
178
|
+
else
|
179
|
+
[Class.new(QuickTest.include_module_into).extend(self), self]
|
180
|
+
end
|
181
|
+
)
|
182
|
+
rescue ArgumentError
|
183
|
+
puts <<-EOS
|
184
|
+
method:
|
185
|
+
#{qt.runner.methods.last}
|
186
|
+
object initialization requires arguments, use:
|
187
|
+
"def self.quicktest"
|
188
|
+
instead of:
|
189
|
+
"def quicktest"
|
190
|
+
EOS
|
191
|
+
exit(1)
|
192
|
+
end
|
193
|
+
|
194
|
+
else
|
195
|
+
unless qt.ignore_first_method_added or
|
196
|
+
qt.runner_module::QuickTestIgnoreClasses.detect {|m| self.to_s =~ m}
|
197
|
+
qt.runner.add_method traced
|
198
|
+
end
|
199
|
+
|
200
|
+
qt.ignore_first_method_added = false
|
201
|
+
__quicktest_method_added__ traced
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
# configurable
|
211
|
+
QuickTest.test_method = :quicktest
|
212
|
+
QuickTest.runner = QuickTest::TestRunner
|
213
|
+
QuickTest.runner_module = QuickTest::RSpecTestRunner
|
214
|
+
QuickTest.include_module_into = Object
|
215
|
+
|
216
|
+
files = []
|
217
|
+
while(arg = ARGV.shift)
|
218
|
+
case arg
|
219
|
+
when '--rspec'
|
220
|
+
QuickTest.runner_module = ARGV.shift ||
|
221
|
+
(puts "--rspec requires an argument";exit(1))
|
222
|
+
when '--quicktest'
|
223
|
+
QuickTest.test_method = ARGV.shift.to_sym ||
|
224
|
+
(puts "--quicktest requires an argument";exit(1))
|
225
|
+
else
|
226
|
+
(puts "unknown argument: #{arg}";exit(1)) unless File.exist? arg
|
227
|
+
files.push(arg)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
ARGV.concat files
|
231
|
+
|
232
|
+
# trace all methods
|
233
|
+
class Module # :nodoc:
|
234
|
+
include QuickTest::Tracer
|
235
|
+
end
|
236
|
+
|
237
|
+
# TODO: run pending tests at exit
|
238
|
+
#at_exit do end
|
data/spec/__test.rb
ADDED
data/spec/test.rb
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
# regenerate test_result.txt with
|
2
|
+
# spec -r ../lib/quicktest test.rb >| test_result.txt
|
3
|
+
# run tests with
|
4
|
+
# spec -r ../lib/quicktest test.rb
|
5
|
+
# regenerate and run
|
6
|
+
# spec -r ../lib/quicktest test.rb >| test_result.txt || spec -r ../lib/quicktest test.rb
|
7
|
+
|
8
|
+
def quicktest
|
9
|
+
it "should be of class Object" do
|
10
|
+
self.should be_kind_of(Object)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
# all tests for this class should always pass
|
14
|
+
class Tester
|
15
|
+
def self.meth
|
16
|
+
"hello"
|
17
|
+
end
|
18
|
+
def self.quicktest
|
19
|
+
it "should say hi" do
|
20
|
+
meth.should == "hello"
|
21
|
+
lambda{raise}.should raise_error
|
22
|
+
end
|
23
|
+
end
|
24
|
+
def self.hello arg
|
25
|
+
"hello" + arg
|
26
|
+
end
|
27
|
+
def self.quicktest m
|
28
|
+
it "should say hello" do
|
29
|
+
m[' bob'].should == "hello bob"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
def method_missing meth
|
33
|
+
@foo if meth == :foo
|
34
|
+
end
|
35
|
+
def initialize
|
36
|
+
@foo = true
|
37
|
+
end
|
38
|
+
def quicktest
|
39
|
+
it "foo should be true" do
|
40
|
+
foo.should == true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
def bar; @foo end
|
44
|
+
def quicktest meth
|
45
|
+
it "foo should be true" do
|
46
|
+
meth.call.should == true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# test failure text
|
52
|
+
$r = File.readlines('test_result.txt')
|
53
|
+
3.times {$r.shift}
|
54
|
+
|
55
|
+
def quicktest
|
56
|
+
msg = "should show class name in output"
|
57
|
+
it msg do
|
58
|
+
$r.shift.should =~ /^'#<#{self.class}:0x[^>]+> #{msg}' FAILED$/
|
59
|
+
7.times {$r.shift}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
@@new_meth = :new_method_added
|
63
|
+
eval"def #@@new_meth; end"
|
64
|
+
|
65
|
+
def quicktest
|
66
|
+
msg = "should show name of added method"
|
67
|
+
it msg do
|
68
|
+
$r.shift.should =~ /^'#<#{self.class}:0x[^>]+> #{@@new_meth} #{msg}' FAILED$/
|
69
|
+
7.times {$r.shift}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
module TestModule
|
74
|
+
@@klass = self
|
75
|
+
def self.quicktest
|
76
|
+
msg = "should show class name in output"
|
77
|
+
it msg do
|
78
|
+
$r.shift.should =~ /^'#{@@klass} #{msg}' FAILED$/
|
79
|
+
7.times {$r.shift}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
@@new_singleton_meth = 'new_singleton_method_added'
|
84
|
+
eval"def self.#@@new_singleton_meth;end"
|
85
|
+
|
86
|
+
def self.quicktest
|
87
|
+
msg = "should show class name in output"
|
88
|
+
it msg do
|
89
|
+
$r.shift.should =~ /^'#{@@klass} #@@new_singleton_meth #{msg}' FAILED$/
|
90
|
+
7.times {$r.shift}
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
define_method(:the_method) {}
|
95
|
+
def quicktest
|
96
|
+
msg = "should include the module into class Object"
|
97
|
+
it msg do
|
98
|
+
$r.shift.should =~ /^'#<Class:0x[^>]+> the_method #{msg}' FAILED$/
|
99
|
+
7.times {$r.shift}
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class TestClass
|
105
|
+
@@klass = self
|
106
|
+
def self.quicktest
|
107
|
+
msg = "should show class name in output"
|
108
|
+
it msg do
|
109
|
+
$r.shift.should =~ /^'#{@@klass} #{msg}' FAILED$/
|
110
|
+
7.times {$r.shift}
|
111
|
+
end
|
112
|
+
end
|
113
|
+
def quicktest
|
114
|
+
msg = "should show class name in output"
|
115
|
+
it msg do
|
116
|
+
$r.shift.should =~ /^'#<#{self.class}:0x[^>]+> #{msg}' FAILED$/
|
117
|
+
7.times {$r.shift}
|
118
|
+
end
|
119
|
+
end
|
120
|
+
@@new_meth = :new_method_added
|
121
|
+
define_method @@new_meth do end
|
122
|
+
|
123
|
+
def quicktest
|
124
|
+
msg = "should show name of added method"
|
125
|
+
it msg do
|
126
|
+
$r.shift.should =~ /^'#<#{self.class}:0x[^>]+> #{@@new_meth} #{msg}' FAILED$/
|
127
|
+
7.times {$r.shift}
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
@@new_singleton_meth = 'new_singleton_method_added'
|
132
|
+
eval"def self.#@@new_singleton_meth;end"
|
133
|
+
|
134
|
+
def self.quicktest
|
135
|
+
msg = "should show class name in output"
|
136
|
+
it msg do
|
137
|
+
$r.shift.should =~ /^'#{@@klass} #@@new_singleton_meth #{msg}' FAILED$/
|
138
|
+
7.times {$r.shift}
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
desc "run specs"
|
2
|
+
task :spec do
|
3
|
+
Dir[ 'spec/*' ].each do |file|
|
4
|
+
out "spec #{file}"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
require 'spec/rake/spectask'
|
10
|
+
desc "verify test coverage with RCov"
|
11
|
+
task :rcov => 'rcov:verify'
|
12
|
+
namespace :rcov do
|
13
|
+
Spec::Rake::SpecTask.new('rcov') do |t|
|
14
|
+
t.spec_files = ['spec/*.rb']
|
15
|
+
t.rcov = true
|
16
|
+
t.rcov_opts = ['--exclude', 'spec']
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'spec/rake/verify_rcov'
|
20
|
+
# rcov is wrong- I am actually at 100%
|
21
|
+
RCov::VerifyTask.new(:verify => :rcov) do |t|
|
22
|
+
t.threshold = 100 # Make sure you have rcov 0.7 or higher!
|
23
|
+
t.index_html = $rcov_index_html
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "create a new gem release"
|
28
|
+
task :release => [:test,:record,:rdoc,:website,:gem_specification,:package] do
|
29
|
+
Dir.chdir('pkg') do
|
30
|
+
release = Dir['*.gem'].sort_by {|file| File.mtime(file)}.last
|
31
|
+
release =~ /^[^-]+-([.0-9]+).gem$/
|
32
|
+
out "rubyforge login && rubyforge add_release #{$project} #{$project} #$1 #{release}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "update website"
|
37
|
+
file :website => ['README','Rakefile'] do
|
38
|
+
Dir.chdir '/home/greg/sites/projects/' do
|
39
|
+
out 'rake --silent projects:update'
|
40
|
+
out 'rake --silent deploy:rsync'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
|
46
|
+
Rake::RDocTask.new do |rd|
|
47
|
+
rd.main = "README"
|
48
|
+
rd.rdoc_dir = "doc"
|
49
|
+
rd.rdoc_files.include("README", "lib/**/*.rb")
|
50
|
+
rd.title = "#$project rdoc"
|
51
|
+
rd.options << '-S' # inline source
|
52
|
+
rd.template = `allison --path`.chomp + '.rb'
|
53
|
+
end
|
54
|
+
|
55
|
+
desc 'git add and push'
|
56
|
+
task :record do
|
57
|
+
unless `git status`.split($/).last =~ /nothing added/
|
58
|
+
puts `git diff`
|
59
|
+
ARGV.clear
|
60
|
+
puts "enter commit message"
|
61
|
+
out "git commit -a -m '#{Kernel.gets}'"
|
62
|
+
puts "committed! now pushing.. "
|
63
|
+
out 'git push origin master'
|
64
|
+
end
|
65
|
+
end
|
data/tasks/helpers.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
def exit_msg(msg, code=1)
|
2
|
+
puts msg
|
3
|
+
exit(code)
|
4
|
+
end
|
5
|
+
def run command
|
6
|
+
res = `#{command}`
|
7
|
+
if $?.exitstatus != 0
|
8
|
+
exit_msg(
|
9
|
+
"\nfailure on command:\n #{command.chomp}\nresult:\n #{res}\n",
|
10
|
+
$?.exitstatus
|
11
|
+
)
|
12
|
+
end
|
13
|
+
res
|
14
|
+
end
|
15
|
+
def out command
|
16
|
+
(puts (run command))
|
17
|
+
end
|
18
|
+
|
19
|
+
def cd_tmp
|
20
|
+
Dir.mkdir 'tmp' unless File.directory? 'tmp'
|
21
|
+
Dir.chdir('tmp') do |dir|
|
22
|
+
yield dir
|
23
|
+
end
|
24
|
+
rm_rf 'tmp'
|
25
|
+
end
|
26
|
+
|
27
|
+
class IO
|
28
|
+
def self.write( file, str )
|
29
|
+
self.open( file, 'w' ) { |fh| fh.print str }
|
30
|
+
end
|
31
|
+
def self.read_write( file, write_file=file )
|
32
|
+
self.write(write_file, (yield( self.read( file ))))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Dir.glob('tasks/*.rake').sort.each {|fn| import fn}
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gregwebs-quicktest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Greg Weber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-11-06 00:00:00 -08:00
|
13
|
+
default_executable: quickspec
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.0
|
23
|
+
version:
|
24
|
+
description:
|
25
|
+
email:
|
26
|
+
executables:
|
27
|
+
- quickspec
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README
|
32
|
+
files:
|
33
|
+
- ./bin
|
34
|
+
- ./doc
|
35
|
+
- ./lib
|
36
|
+
- ./TODO
|
37
|
+
- ./spec
|
38
|
+
- ./quicktest.gemspec.rb
|
39
|
+
- ./Rakefile
|
40
|
+
- ./tasks
|
41
|
+
- ./README
|
42
|
+
- ./quicktest-0.6.1.gem
|
43
|
+
- bin/quickspec
|
44
|
+
- doc/files
|
45
|
+
- doc/index.html
|
46
|
+
- doc/rdoc-style.css
|
47
|
+
- doc/fr_method_index.html
|
48
|
+
- doc/fr_class_index.html
|
49
|
+
- doc/fr_file_index.html
|
50
|
+
- doc/created.rid
|
51
|
+
- doc/classes
|
52
|
+
- lib/quicktest.rb
|
53
|
+
- spec/__test.rb
|
54
|
+
- spec/test.rb
|
55
|
+
- tasks/helpers.rb
|
56
|
+
- tasks/gregproject.rake
|
57
|
+
- README
|
58
|
+
has_rdoc: true
|
59
|
+
homepage: http://gregweber.info/projects/quicktest.html
|
60
|
+
post_install_message: |+
|
61
|
+
|
62
|
+
spec and quickspec are ruby executable scripts, whose directory location must be in your PATH environment variable (or you must invoke the with the full file path).
|
63
|
+
|
64
|
+
run tests with
|
65
|
+
quickspec [file1 file2 ...]
|
66
|
+
|
67
|
+
rdoc_options: []
|
68
|
+
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project: quicktest
|
86
|
+
rubygems_version: 1.2.0
|
87
|
+
signing_key:
|
88
|
+
specification_version: 2
|
89
|
+
summary: utility for inlining tests with the code tested
|
90
|
+
test_files: []
|
91
|
+
|