greenbar 0.1.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,47 +1,20 @@
1
- NOTE: this is essentially the same license as Ruby has, without paragraphs
2
- that do not apply.
3
-
4
-
5
- Greenbar is copyrighted free software.
6
- You can redistribute it and/or modify it under the conditions below:
7
-
8
- 1. You may make and give away verbatim copies of the source form of the
9
- software without restriction, provided that you duplicate all of the
10
- original copyright notices and associated disclaimers.
11
-
12
- 2. You may modify your copy of the software in any way, provided that
13
- you do at least ONE of the following:
14
-
15
- a) place your modifications in the Public Domain or otherwise
16
- make them Freely Available, such as by posting said
17
- modifications to Usenet or an equivalent medium, or by allowing
18
- the author to include your modifications in the software.
19
-
20
- b) use the modified software only within your corporation or
21
- organization.
22
-
23
- c) rename any non-standard executables so the names do not conflict
24
- with standard executables, which must also be provided.
25
-
26
- d) make other distribution arrangements with the author.
27
-
28
- 3. You may distribute the software in object code or executable
29
- form, provided that you do at least ONE of the following:
30
-
31
- a) distribute the executables and library files of the software,
32
- together with instructions (in the manual page or equivalent)
33
- on where to get the original distribution.
34
-
35
- b) accompany the distribution with the machine-readable source of
36
- the software.
37
-
38
- c) give non-standard executables non-standard names, with
39
- instructions on where to get the original software distribution.
40
-
41
- d) make other distribution arrangements with the author.
42
-
43
- 4. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
44
- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
45
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46
- PURPOSE.
47
-
1
+ The MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files
5
+ (the "Software"), to deal in the Software without restriction,
6
+ including without limitation the rights to use, copy, modify,
7
+ merge, publish, distribute, sublicense, and/or sell copies of the
8
+ Software, and to permit persons to whom the Software is furnished to
9
+ do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included
12
+ in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -7,7 +7,7 @@ class DateDueCalculatorTest < Test::Unit::TestCase
7
7
  include Greenbar::DateSetup
8
8
 
9
9
  def test_calculate_date_due
10
- Date.today = Date.civil(2006, 4, 15)
10
+ make_Date_today_return Date.civil(2006, 4, 15)
11
11
  calculator = DateDueCalculator.new
12
12
  assert_equal Date.civil(2006, 4, 22), calculator.calculate_due_date(Movie.new(:standard))
13
13
  assert_equal Date.civil(2006, 4, 19), calculator.calculate_due_date(Movie.new(:hotflick))
@@ -7,7 +7,7 @@ class WebServiceTest < Test::Unit::TestCase
7
7
  include Greenbar::TimeSetup
8
8
 
9
9
  def test_expires
10
- Time.now = Time.local(2006, 4, 16, 15, 23)
10
+ make_Time_now_return Time.local(2006, 4, 16, 15, 23)
11
11
  response = WebService.new.handle_request
12
12
  assert_equal Time.local(2006, 4, 16, 16, 23), response.expires_at
13
13
  end
@@ -44,10 +44,7 @@ end
44
44
  # ===Usage
45
45
  #
46
46
  # 1. Include Greenbar::ClassMethodSetup in your test case.
47
- # 2. Use replace_class_method, define_class_method, or replace_new
48
- # as needed.
49
- #
50
- # You may change 'today' as often as you want.
47
+ # 2. Use replace_class_method, define_class_method, or replace_new as needed.
51
48
  #
52
49
  # ===Examples
53
50
  #
@@ -85,7 +82,7 @@ module Greenbar::ClassMethodSetup
85
82
  # Replaces a class method _method_name_ on class _target_class_. The implementation
86
83
  # will be the _block_, and may take any number of arguments. The original method
87
84
  # will be restored automatically. The primary purpose for this method is when you
88
- # need to provide a mock implementation of some class_method.
85
+ # need to provide a mock implementation of a class method.
89
86
  #
90
87
  def replace_class_method target_class, method_name, &block
91
88
  @class_methods_to_restore << [target_class, method_name]
@@ -107,12 +104,12 @@ module Greenbar::ClassMethodSetup
107
104
 
108
105
  # Replaces the new method on class _target_class_.
109
106
  #
110
- # In the canonical form, _results_ should will respond to to_hash.
107
+ # In the canonical form, _results_ should respond to to_hash.
111
108
  # The hash is keyed by arrays that match the expected arguments to the new method.
112
- # the hash value is the object to return for that set of arguments.
109
+ # The hash value is the object to return for that set of arguments.
113
110
  #
114
- # If _results_ does not respond to to_hash, is is assumed to be the desired
115
- # return value for a no-argument call to new.
111
+ # If _results_ does not respond to to_hash, it provides the desired return value
112
+ # for a no-argument call to new. That is, it is shorthand for {[] => results}.
116
113
  #
117
114
  def replace_new target_class, results
118
115
  argument_instance_map = results.respond_to?(:to_hash) ? results.to_hash : { [] => results }
@@ -23,7 +23,7 @@ class Date; end
23
23
  # ===Usage
24
24
  #
25
25
  # 1. Include Greenbar::DateSetup in your test case.
26
- # 2. Use Date.today= to define the date you want to be 'today'
26
+ # 2. Use make_Date_today_return to define the date you want to be 'today'
27
27
  #
28
28
  # You may change 'today' as often as you want.
29
29
  #
@@ -31,12 +31,6 @@ class Date; end
31
31
  #
32
32
  # :include: doc/examples/DateSetup.rb
33
33
  #
34
- # ===Additional definitions
35
- # Date.today=(date)
36
- #
37
- # sets the Date to returned as 'today' for Date.today
38
- # Must be called before Date.today if DateSetup is being used.
39
- #
40
34
 
41
35
  module Greenbar::DateSetup
42
36
  include Greenbar::TestSetup
@@ -44,19 +38,22 @@ module Greenbar::DateSetup
44
38
 
45
39
  def setup_mixin #:nodoc:
46
40
  replace_class_method(Date, :today) {
47
- raise "Must use Date.today= when using DateSetup." unless defined? @today
41
+ raise "Must use make_Date_today_return() when using DateSetup." unless defined? @today
48
42
  @today
49
43
  }
50
44
 
51
- def Date.today=(date) #:nodoc:
52
- @today = date
53
- end
45
+ end
46
+
47
+ #
48
+ # Sets the Date to be returned for Date.today
49
+ # Must be called before Date.today if DateSetup is being used.
50
+ #
51
+ def make_Date_today_return date
52
+ Date.instance_variable_set '@today', date
54
53
  end
55
54
 
56
55
  def teardown_mixin #:nodoc:
57
- class << Date
58
- remove_method :today=
59
- end
56
+ Date.instance_eval {remove_instance_variable '@today'} if Date.instance_variables.include?('@today')
60
57
  end
61
58
 
62
59
  end
@@ -22,7 +22,7 @@ class Time; end
22
22
  # ===Usage
23
23
  #
24
24
  # 1. Include Greenbar::TimeSetup in your test case.
25
- # 2. Use Time.now= to define the time you want to be 'now'
25
+ # 2. Use make_Time_now_return to define the time you want to be 'now'
26
26
  #
27
27
  # You may change 'now' as often as you want.
28
28
  #
@@ -30,12 +30,6 @@ class Time; end
30
30
  #
31
31
  # :include: doc/examples/TimeSetup.rb
32
32
  #
33
- # ===Additional definitions
34
- # Time.now=(time)
35
- #
36
- # sets the Time to returned as 'now' for Time.new and Time.now
37
- # Must be called before Time.new or Time.now if TimeSetup is being used.
38
- #
39
33
  module Greenbar::TimeSetup
40
34
  #:stopdoc:
41
35
  include Greenbar::TestSetup
@@ -44,7 +38,7 @@ module Greenbar::TimeSetup
44
38
 
45
39
  def setup_mixin #:nodoc:
46
40
  replace_class_method(Time, :now) {
47
- raise "Must use Time.now= when using TimeSetup." unless @now
41
+ raise "Must use make_Time_now_return() when using TimeSetup." unless @now
48
42
  @now
49
43
  }
50
44
 
@@ -52,15 +46,17 @@ module Greenbar::TimeSetup
52
46
  Time.now
53
47
  }
54
48
 
55
- def Time.now=(time) #:nodoc:
56
- @now = time
57
- end
49
+ end
50
+ #
51
+ # Sets the Time to be returned for time.now
52
+ # Must be called before Time.new or Time.now if TimeSetup is being used.
53
+ #
54
+ def make_Time_now_return time
55
+ Time.instance_variable_set '@now', time
58
56
  end
59
57
 
60
58
  def teardown_mixin #:nodoc:
61
- class << Time
62
- remove_method :now=
63
- end
59
+ Time.instance_eval {remove_instance_variable '@now'} if Time.instance_variables.include?('@now')
64
60
  end
65
61
 
66
62
  end
@@ -4,7 +4,7 @@ require 'rake/clean'
4
4
  require 'rake/testtask'
5
5
  require 'rake/rdoctask'
6
6
 
7
- GREENBAR_VERSION = '0.1.1'
7
+ GREENBAR_VERSION = '0.2.1'
8
8
  WEB_BUILD="web/build"
9
9
 
10
10
  desc "Default Task"
@@ -43,15 +43,17 @@ Rake::TestTask.new(:examples) {|unitTest|
43
43
  unitTest.verbose = true
44
44
  }
45
45
 
46
+ COMMON_RDOC_OPTIONS = [
47
+ '--title', '"Greenbar - Aids for Testing with Test::Unit"',
48
+ '--main', 'README',
49
+ '--line-numbers', '--inline-source',
50
+ ]
51
+
46
52
  rdoc = Rake::RDocTask.new("rdoc") {|rdoc|
47
53
  rdoc.rdoc_dir = 'html'
48
- rdoc.template = 'jamis'
49
- rdoc.title = "Greenbar -- Test::Unit Tools"
50
- rdoc.options << '--line-numbers' << '--inline-source'
51
- rdoc.main = 'README'
52
- rdoc.rdoc_files.include('README')
53
- rdoc.rdoc_files.include('LICENSE')
54
- rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
54
+ rdoc.template = 'jamis.rb'
55
+ rdoc.options += COMMON_RDOC_OPTIONS
56
+ rdoc.rdoc_files.include 'README', 'LICENSE', 'lib/**/*.rb', 'doc/**/*.rdoc'
55
57
  }
56
58
 
57
59
  FILES_TO_PACKAGE = FileList[
@@ -85,10 +87,7 @@ else
85
87
 
86
88
  spec.has_rdoc = true
87
89
  spec.extra_rdoc_files = rdoc.rdoc_files.reject {|filename| filename =~ /\.rb$/ }.to_a << 'README'
88
- spec.rdoc_options <<
89
- '--title' << 'Greenbar - Aids for Testing with Test::Unit' <<
90
- '--main' << 'README' <<
91
- '--line-numbers' << '--inline-source'
90
+ spec.rdoc_options + COMMON_RDOC_OPTIONS
92
91
 
93
92
  # spec.signing_key = 'gem-private_key.pem'
94
93
  # spec.cert_chain = ['gem-public_cert.pem']
@@ -22,18 +22,23 @@ class DateSetupTest < Test::Unit::TestCase
22
22
  test = Test.new
23
23
  test.setup
24
24
 
25
- assert_raise(RuntimeError, 'Expected a RuntimeError if Date.now= not called before Date.today') {
25
+ assert_raise(RuntimeError, 'Expected a RuntimeError if make_Date_today_return not called before Date.today') {
26
26
  Date.today
27
27
  }
28
28
 
29
- Date.today = july4th2004
29
+ test.make_Date_today_return july4th2004
30
30
  assert_equal july4th2004, Date.today
31
31
 
32
32
  test.teardown
33
33
 
34
34
  assert Date.today > july4th2004
35
- assert_raise(NoMethodError) {
36
- Date.today = july4th2004
37
- }
35
+ assert ! Date.instance_variables.include?('@today'), "Date@today should have been removed"
36
+ end
37
+
38
+ def test_when_today_is_not_set
39
+ test = Test.new
40
+ test.setup
41
+ test.teardown
38
42
  end
43
+
39
44
  end
@@ -30,16 +30,20 @@ class TimeSetupTest < Test::Unit::TestCase
30
30
  Time.new
31
31
  }
32
32
 
33
- Time.now = july4th2004
33
+ test.make_Time_now_return july4th2004
34
34
  assert_equal july4th2004, Time.now
35
35
  assert_equal july4th2004, Time.new
36
36
 
37
37
  test.teardown
38
38
  assert Time.new > july4th2004
39
39
  assert Time.now > july4th2004
40
- assert_raise(NoMethodError) {
41
- Time.now = july4th2004
42
- }
40
+
41
+ assert ! Time.instance_variables.include?('@now'), "Time@now should have been removed"
43
42
  end
44
43
 
44
+ def test_when_now_is_not_set
45
+ test = Test.new
46
+ test.setup
47
+ test.teardown
48
+ end
45
49
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: greenbar
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2006-04-23 00:00:00 -04:00
6
+ version: 0.2.1
7
+ date: 2006-04-28 00:00:00 -04:00
8
8
  summary: Test::Unit tools.
9
9
  require_paths:
10
10
  - lib
@@ -57,13 +57,8 @@ files:
57
57
  - rakefile.rb
58
58
  test_files:
59
59
  - test/allTests.rb
60
- rdoc_options:
61
- - --title
62
- - Greenbar - Aids for Testing with Test::Unit
63
- - --main
64
- - README
65
- - --line-numbers
66
- - --inline-source
60
+ rdoc_options: []
61
+
67
62
  extra_rdoc_files:
68
63
  - README
69
64
  - LICENSE