quicktest 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -71,11 +71,12 @@ Quicktest is designed to support quick tests in a framework agnostic way. Curre
71
71
  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.
72
72
 
73
73
  == Install
74
- gem instlal quicktest
74
+ gem install quicktest
75
75
 
76
76
  == Source
77
77
  === browser
78
78
  http://github.com/gregwebs/quicktest/tree/master
79
+
79
80
  === repository
80
81
  git clone git://github.com/gregwebs/quicktest.git
81
82
 
@@ -83,19 +84,21 @@ git clone git://github.com/gregwebs/quicktest.git
83
84
  http://gregweber.info/projects/quicktest.html
84
85
 
85
86
  == RDoc documentation
86
- http://quicktest.rubyforge.org/
87
+ included with the gem
87
88
 
88
89
  == Important Notes
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
+ - 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:
90
91
 
91
- def self.quicktest_include_into; Object end
92
+ def self.quicktest_include_into; String end
92
93
 
93
94
  - 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
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.
95
+
96
+ == TroubleShooting
97
+ - 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.
95
98
 
96
99
  == Unimportant Notes
97
100
  === production performance
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
101
+ leaving test code in with your production code is not necessarily a good idea, but you can put
99
102
 
100
103
  remove_method :quicktest
101
104
 
@@ -124,4 +127,8 @@ Originally, I made an exact copy of this, but among other things, it requires th
124
127
  (def unittest;end) if not defined? unittest
125
128
  at the beginning of the file. It would be nice if Ruby had a similar construct built in to the language.
126
129
 
130
+ === implementation
131
+ 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.
132
+
133
+
127
134
  =end rdoc
data/doc/created.rid CHANGED
@@ -1 +1 @@
1
- Sat, 08 Mar 2008 00:15:37 -0600
1
+ Sun, 09 Mar 2008 12:19:06 -0500
data/lib/quicktest.rb CHANGED
@@ -17,7 +17,10 @@ module QuickTest
17
17
  # when testing module instance methods
18
18
  # this defines the class to include a module into
19
19
  # user sets this by defining self.quicktest_include_into in a module
20
+ # otherwise, a generic class is used
20
21
  attr_accessor :include_module_into
22
+
23
+ attr_accessor :last_self
21
24
  end
22
25
 
23
26
  # to reuse this implementation
@@ -126,6 +129,11 @@ module QuickTest
126
129
  # avoid infinite recursion if module is included into a class by a user
127
130
  return if traced == QuickTest.runner.methods.last
128
131
 
132
+ if QuickTest.last_self != self
133
+ QuickTest.last_self = self
134
+ QuickTest.include_module_into = nil
135
+ end
136
+
129
137
  if traced == :quicktest
130
138
  QuickTest.runner.new self
131
139
 
@@ -151,7 +159,8 @@ module QuickTest
151
159
  if self.class != Module
152
160
  self.new
153
161
  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
162
+ imi = QuickTest.include_module_into
163
+ o = (imi ? Class.new(imi) : Class.new).new
155
164
  o.extend(self)
156
165
  o
157
166
  end
Binary file
data/rakefile CHANGED
@@ -1,25 +1,30 @@
1
+ project = 'quicktest'
1
2
  def test_dir; Dir.chdir('test') {|dir| yield dir } end
2
3
 
3
4
  desc "test"
4
5
  task :test do
5
6
  run = 'spec -r ../lib/quicktest test.rb'
6
7
  test_dir {puts `#{run} >| test_result.txt || #{run}`}
8
+ exit $?.exitstatus if $?.exitstatus != 0
7
9
  end
8
10
 
9
11
  namespace :test do
10
12
  run = '../bin/quickspec test.rb'
11
13
  task :generate do
12
14
  test_dir {`#{run} >| test_result.txt`}
15
+ exit $?.exitstatus if $?.exitstatus != 0
13
16
  end
14
17
 
15
18
  desc "test quickspec executable"
16
19
  task :quickspec => :generate do
17
20
  test_dir {puts `#{run}`}
21
+ exit $?.exitstatus if $?.exitstatus != 0
18
22
  end
19
23
 
20
24
  desc "test readme file"
21
25
  task :README do
22
26
  puts `./bin/quickspec README`
27
+ exit $?.exitstatus if $?.exitstatus != 0
23
28
  end
24
29
  end
25
30
 
@@ -68,15 +73,17 @@ namespace :readme do
68
73
  end
69
74
  end
70
75
 
71
- desc "create html for website using coderay"
76
+ desc "create html for website using coderay, use --silent option"
72
77
  task :html => :rdoc do
73
78
  require 'hpricot'
74
79
  doc = open( 'doc/files/README.html' ) { |f| Hpricot(f) }
75
80
  # find example code
76
- ex = doc.at('#description').search('pre').select {|elem| elem.inner_html =~ /def self\.quicktest/}.first
77
- ex.swap("<coderay lang='ruby'>#{ex.inner_html}</coderay>")
78
- # undo what rdoc has done in the example code
79
- puts doc.at('#description').to_html.gsub('&quot;', '"')
81
+ doc.at('#description').search('pre').
82
+ select {|elem| elem.inner_html =~ /class |module /}.each do |ex|
83
+ # add coderay and undo what rdoc has done in the example code
84
+ ex.swap("<coderay lang='ruby'>#{ex.inner_html.gsub('&quot;', '"').gsub('&gt;','>')}</coderay>")
85
+ end
86
+ puts doc.at('#description').to_html
80
87
  end
81
88
  end
82
89
 
@@ -85,7 +92,7 @@ task :release => [:rdoc,:package] do
85
92
  Dir.chdir('pkg') do
86
93
  release = Dir['*.gem'].sort_by {|file| File.mtime(file)}.last
87
94
  release =~ /^[^-]+-([.0-9]+).gem$/
88
- `rubyforge login && rubyforge add_release quicktest quicktest #$1 #{release}`
95
+ `rubyforge login && rubyforge add_release #{project} #{project} #$1 #{release}`
89
96
  end
90
97
  end
91
98
 
@@ -93,9 +100,9 @@ require 'rubygems'
93
100
  require 'rake/gempackagetask'
94
101
 
95
102
  spec = Gem::Specification.new do |s|
96
- s.name = "quicktest"
97
- s.rubyforge_project = "quicktest"
98
- s.version = "0.4.0"
103
+ s.name = project
104
+ s.rubyforge_project = project
105
+ s.version = "0.5.0"
99
106
  s.author = "Greg Weber"
100
107
  s.email = "greg@gregweber.info"
101
108
  s.homepage = "http://quicktest.rubyfore.org/"
data/test/test_result.txt CHANGED
@@ -1,69 +1,69 @@
1
1
  .....FFFFFFFF
2
2
 
3
3
  1)
4
- '#<Object:0xb787b240> should show class name in output' FAILED
4
+ '#<Object:0xb78e4d30> should show class name in output' FAILED
5
5
  expected: /^'#<Object:0x[^>]+> should show class name in output' FAILED$/,
6
6
  got: nil (using =~)
7
7
  ./test.rb:58:in `quicktest'
8
- ../lib/quicktest.rb:91:in `call'
9
- ../lib/quicktest.rb:91:in `__quicktest_run_tests__'
8
+ ../lib/quicktest.rb:99:in `call'
9
+ ../lib/quicktest.rb:99:in `__quicktest_run_tests__'
10
10
 
11
11
  2)
12
- '#<Object:0xb787a548> new_method_added should show name of added method' FAILED
12
+ '#<Object:0xb78e3f20> new_method_added should show name of added method' FAILED
13
13
  expected: /^'#<Object:0x[^>]+> new_method_added should show name of added method' FAILED$/,
14
14
  got: nil (using =~)
15
15
  ./test.rb:68:in `quicktest'
16
- ../lib/quicktest.rb:91:in `call'
17
- ../lib/quicktest.rb:91:in `__quicktest_run_tests__'
16
+ ../lib/quicktest.rb:99:in `call'
17
+ ../lib/quicktest.rb:99:in `__quicktest_run_tests__'
18
18
 
19
19
  3)
20
20
  'TestModule should show class name in output' FAILED
21
21
  expected: /^'TestModule should show class name in output' FAILED$/,
22
22
  got: nil (using =~)
23
23
  ./test.rb:78:in `quicktest'
24
- ../lib/quicktest.rb:91:in `call'
25
- ../lib/quicktest.rb:91:in `__quicktest_run_tests__'
24
+ ../lib/quicktest.rb:99:in `call'
25
+ ../lib/quicktest.rb:99:in `__quicktest_run_tests__'
26
26
 
27
27
  4)
28
28
  'TestModule new_singleton_method_added should show class name in output' FAILED
29
29
  expected: /^'TestModule new_singleton_method_added should show class name in output' FAILED$/,
30
30
  got: nil (using =~)
31
31
  ./test.rb:89:in `quicktest'
32
- ../lib/quicktest.rb:91:in `call'
33
- ../lib/quicktest.rb:91:in `__quicktest_run_tests__'
32
+ ../lib/quicktest.rb:99:in `call'
33
+ ../lib/quicktest.rb:99:in `__quicktest_run_tests__'
34
34
 
35
35
  5)
36
36
  'TestClass should show class name in output' FAILED
37
37
  expected: /^'TestClass should show class name in output' FAILED$/,
38
38
  got: nil (using =~)
39
39
  ./test.rb:100:in `quicktest'
40
- ../lib/quicktest.rb:91:in `call'
41
- ../lib/quicktest.rb:91:in `__quicktest_run_tests__'
40
+ ../lib/quicktest.rb:99:in `call'
41
+ ../lib/quicktest.rb:99:in `__quicktest_run_tests__'
42
42
 
43
43
  6)
44
- '#<TestClass:0xb7877c94> should show class name in output' FAILED
44
+ '#<TestClass:0xb78de124> should show class name in output' FAILED
45
45
  expected: /^'#<TestClass:0x[^>]+> should show class name in output' FAILED$/,
46
46
  got: nil (using =~)
47
47
  ./test.rb:107:in `quicktest'
48
- ../lib/quicktest.rb:91:in `call'
49
- ../lib/quicktest.rb:91:in `__quicktest_run_tests__'
48
+ ../lib/quicktest.rb:99:in `call'
49
+ ../lib/quicktest.rb:99:in `__quicktest_run_tests__'
50
50
 
51
51
  7)
52
- '#<TestClass:0xb78763bc> new_method_added should show name of added method' FAILED
52
+ '#<TestClass:0xb78dc4b4> new_method_added should show name of added method' FAILED
53
53
  expected: /^'#<TestClass:0x[^>]+> new_method_added should show name of added method' FAILED$/,
54
54
  got: nil (using =~)
55
55
  ./test.rb:117:in `quicktest'
56
- ../lib/quicktest.rb:91:in `call'
57
- ../lib/quicktest.rb:91:in `__quicktest_run_tests__'
56
+ ../lib/quicktest.rb:99:in `call'
57
+ ../lib/quicktest.rb:99:in `__quicktest_run_tests__'
58
58
 
59
59
  8)
60
60
  'TestClass new_singleton_method_added should show class name in output' FAILED
61
61
  expected: /^'TestClass new_singleton_method_added should show class name in output' FAILED$/,
62
62
  got: nil (using =~)
63
63
  ./test.rb:128:in `quicktest'
64
- ../lib/quicktest.rb:91:in `call'
65
- ../lib/quicktest.rb:91:in `__quicktest_run_tests__'
64
+ ../lib/quicktest.rb:99:in `call'
65
+ ../lib/quicktest.rb:99:in `__quicktest_run_tests__'
66
66
 
67
- Finished in 0.182849 seconds
67
+ Finished in 0.04979 seconds
68
68
 
69
69
  13 examples, 8 failures
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.4.0
7
- date: 2008-03-08 00:00:00 -06:00
6
+ version: 0.5.0
7
+ date: 2008-03-09 00:00:00 -06:00
8
8
  summary: utility for inlining tests with the code tested
9
9
  require_paths:
10
10
  - lib
@@ -48,6 +48,7 @@ files:
48
48
  - lib/quicktest.rb
49
49
  - pkg/quicktest-0.3.2.gem
50
50
  - pkg/quicktest-0.3.4.gem
51
+ - pkg/quicktest-0.4.0.gem
51
52
  - test/test.rb
52
53
  - test/test_result.txt
53
54
  - README