quicktest 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -86,12 +86,20 @@ http://gregweber.info/projects/quicktest.html
86
86
  http://quicktest.rubyforge.org/
87
87
 
88
88
  == Important Notes
89
- - 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.
89
+ - to test a module instance method, you must define an object that the module will be included into by defining the following in the module:
90
+
91
+ def self.quicktest_include_into; Object end
92
+
93
+ - 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
90
94
  - quicktest methods not working properly? if the class (or one of its ancestors) is overriding method tracing then including QuickTest::Tracer will fix it.
91
95
 
92
96
  == Unimportant Notes
93
97
  === production performance
94
- leaving test code in with your production code is not necessarily a good idea, but there is almost no runtime overhead to doing so since ruby will not evaluate code in a method until the method is invoked
98
+ leaving test code in with your production code is not necessarily a good idea, but there is almost no runtime overhead to doing so since ruby will not evaluate code in a method until the method is invoked. You can also put
99
+
100
+ remove_method :quicktest
101
+
102
+ at the bottom of a class to completely remove the quicktest method
95
103
 
96
104
  === rationals
97
105
  * tests for scripts
@@ -101,7 +109,7 @@ You can have a flow of development where a 'quick and dirty' script becomes well
101
109
  * documentation
102
110
  Tests are a form of documentation. It can be argued that it is better to have all documentation include in the source
103
111
 
104
- * efficient TDD
112
+ * efficient TDD and prototyping
105
113
  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.
106
114
 
107
115
 
data/doc/created.rid CHANGED
@@ -1 +1 @@
1
- Thu, 06 Mar 2008 23:06:11 -0600
1
+ Sat, 08 Mar 2008 00:15:37 -0600
data/lib/quicktest.rb CHANGED
@@ -13,6 +13,11 @@ module QuickTest
13
13
 
14
14
  # set which code will be running the tests
15
15
  attr_accessor :runner, :runner_module
16
+
17
+ # when testing module instance methods
18
+ # this defines the class to include a module into
19
+ # user sets this by defining self.quicktest_include_into in a module
20
+ attr_accessor :include_module_into
16
21
  end
17
22
 
18
23
  # to reuse this implementation
@@ -123,6 +128,10 @@ module QuickTest
123
128
 
124
129
  if traced == :quicktest
125
130
  QuickTest.runner.new self
131
+
132
+ elsif traced == :quicktest_include_into
133
+ QuickTest.include_module_into = self.quicktest_include_into
134
+
126
135
  else
127
136
  QuickTest.runner.add_singleton_method traced
128
137
  __quicktest_singleton_method_added__ traced
@@ -138,10 +147,15 @@ module QuickTest
138
147
  return if traced == qt.runner.methods.last
139
148
 
140
149
  if traced == :quicktest
141
- if self.class == Module
142
- fail "to test module instance methods, include them in a class"
143
- end
144
- qt.runner.new self.new
150
+ qt.runner.new(
151
+ if self.class != Module
152
+ self.new
153
+ else
154
+ o = (QuickTest.include_module_into || (fail "to test module instance methods, include them in a class or define a method for the module 'self.quicktest_include_into'")).new
155
+ o.extend(self)
156
+ o
157
+ end
158
+ )
145
159
 
146
160
  else
147
161
  unless qt.ignore_first_method_added or
Binary file
data/rakefile CHANGED
@@ -80,13 +80,22 @@ namespace :readme do
80
80
  end
81
81
  end
82
82
 
83
+ desc "release a new gem to rubyforge"
84
+ task :release => [:rdoc,:package] do
85
+ Dir.chdir('pkg') do
86
+ release = Dir['*.gem'].sort_by {|file| File.mtime(file)}.last
87
+ release =~ /^[^-]+-([.0-9]+).gem$/
88
+ `rubyforge login && rubyforge add_release quicktest quicktest #$1 #{release}`
89
+ end
90
+ end
91
+
83
92
  require 'rubygems'
84
93
  require 'rake/gempackagetask'
85
94
 
86
95
  spec = Gem::Specification.new do |s|
87
96
  s.name = "quicktest"
88
97
  s.rubyforge_project = "quicktest"
89
- s.version = "0.3.4"
98
+ s.version = "0.4.0"
90
99
  s.author = "Greg Weber"
91
100
  s.email = "greg@gregweber.info"
92
101
  s.homepage = "http://quicktest.rubyfore.org/"
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: quicktest
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.4
7
- date: 2008-03-07 00:00:00 -06:00
6
+ version: 0.4.0
7
+ date: 2008-03-08 00:00:00 -06:00
8
8
  summary: utility for inlining tests with the code tested
9
9
  require_paths:
10
10
  - lib
@@ -47,6 +47,7 @@ files:
47
47
  - doc/classes
48
48
  - lib/quicktest.rb
49
49
  - pkg/quicktest-0.3.2.gem
50
+ - pkg/quicktest-0.3.4.gem
50
51
  - test/test.rb
51
52
  - test/test_result.txt
52
53
  - README