behaviors 1.0.3 → 1.99.99

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.
@@ -49,10 +49,14 @@ class BehaviorsTasksTest < Test::Unit::TestCase
49
49
  def test_that_behaviors_tasks_should_list_behavioral_definitions_for_the_classes_under_test
50
50
  run_behaviors_task
51
51
  user_behaviors = [
52
- "User should:",
53
- " - be able set user name and age during construction",
54
- " - be able to get user name and age",
55
- " - be able to ask if a user is an adult"
52
+ "User:",
53
+ " - should:",
54
+ " - allow age to be changed",
55
+ " - allow name to be changed",
56
+ " - given a constructed instance should:",
57
+ " - be an adult if age is 18",
58
+ " - when constructing should:",
59
+ " - set name and age accessors"
56
60
  ]
57
61
  assert_match(/#{user_behaviors.join("\n")}/, @report)
58
62
  end
@@ -62,10 +66,14 @@ class BehaviorsTasksTest < Test::Unit::TestCase
62
66
  see_html_task_output_message
63
67
  see_that_html_report_file_exits
64
68
  user_behaviors = [
65
- "User should:",
66
- "be able set user name and age during construction",
67
- "be able to get user name and age",
68
- "be able to ask if a user is an adult"
69
+ "User",
70
+ "should",
71
+ "allow age to be changed",
72
+ "allow name to be changed",
73
+ "given a constructed instance should",
74
+ "be an adult if age is 18",
75
+ "when constructing should",
76
+ "set name and age accessors"
69
77
  ]
70
78
  html_report_file_should_contain user_behaviors
71
79
  end
@@ -2,49 +2,227 @@ require 'test/unit'
2
2
  require File.expand_path(File.dirname(__FILE__)) + '/../lib/behaviors'
3
3
  require 'stringio'
4
4
 
5
+ class Dog < Test::Unit::TestCase
6
+ extend Behaviors
7
+ attr_accessor :fed
8
+
9
+ alias_method :orig_run, :run #tuck run out of the way so DeveloperTest does not have test methods run at_exit
10
+ def run(result)
11
+ end
12
+
13
+ should 'be fed' do
14
+ @fed = true
15
+ end
16
+ end
17
+
5
18
  loading_developer_test_class_stdout = StringIO.new
6
19
  saved_stdout = $stdout.dup
7
20
  $stdout = loading_developer_test_class_stdout
8
21
 
9
- class DeveloperTest
22
+ class DeveloperTest < Test::Unit::TestCase
10
23
  extend Behaviors
11
- attr_accessor :flunk_msg, :tested_code
12
24
 
13
- should "test their code" do
14
- @tested_code = true
25
+ attr_accessor :tests_code, :studies, :work_snack, :home_snack,
26
+ :study_atmosphere, :rest_atmosphere, :unlimited_power,
27
+ :work_atmosphere, :has_been_setup
28
+
29
+
30
+ alias_method :orig_run, :run #tuck run out of the way so DeveloperTest does not have test methods run at_exit
31
+ def run(result)
32
+ end
33
+
34
+ def setup
35
+ @snack = 'yogurt'
36
+ end
37
+
38
+ def have_unlimited_power
39
+ @unlimited_power = true
40
+ end
41
+
42
+ context 'developer at home' do
43
+ setup do
44
+ @noise_level = 'quiet'
45
+ end
46
+
47
+ should 'study' do
48
+ @studies = true
49
+ @home_snack = @snack
50
+ @study_atmosphere = @noise_level
51
+ end
52
+
53
+ should 'rest' do
54
+ @rest_atmosphere = @noise_level
55
+ end
56
+ end
57
+
58
+ context 'developer at work' do
59
+ should 'test their code' do
60
+ @has_been_setup = @setup
61
+ @tests_code = true
62
+ @work_snack = @snack
63
+ @noise_level ||= nil
64
+ @work_atmosphere = @noise_level
65
+ have_unlimited_power
66
+ end
67
+
68
+ setup do
69
+ @setup = true
70
+ end
71
+
72
+ should 'go to meetings'
15
73
  end
16
- should "go to meetings"
74
+
17
75
  end
18
76
 
19
77
  $stdout = saved_stdout
20
78
  loading_developer_test_class_stdout.rewind
21
79
  $loading_developer_test_class_output = loading_developer_test_class_stdout.read
22
80
 
23
- class BehaviorsTest < Test::Unit::TestCase
24
81
 
82
+ class BehaviorsTest < Test::Unit::TestCase
25
83
 
26
84
  def setup
27
- @target = DeveloperTest.new
28
- assert_nil @target.tested_code, "block called too early"
85
+ @developer_test_suite = DeveloperTest.suite
29
86
  end
30
87
 
31
88
  #
32
89
  # TESTS
33
90
  #
34
91
  def test_should_called_with_a_block_defines_a_test
35
- assert @target.methods.include?("test_should_test their code"), "Missing test method"
92
+ at_work_test = @developer_test_suite.tests.find {|test| test.method_name == 'test developer at work should test their code'}
93
+ at_home_test = @developer_test_suite.tests.find {|test| test.method_name == 'test developer at home should study'}
36
94
 
37
- @target.send("test_should_test their code")
95
+ assert_nil at_work_test.tests_code, 'should be nil until test method called'
96
+ assert_nil at_home_test.studies, 'should be nil until test method called'
38
97
 
39
- assert @target.tested_code, "block not called"
98
+ at_work_test.orig_run(Test::Unit::TestResult.new) {|result,progress_block|}
99
+ at_home_test.orig_run(Test::Unit::TestResult.new) {|result,progress_block|}
100
+
101
+ assert at_work_test.tests_code, 'should be true after test method called'
102
+ assert at_home_test.studies, 'should be true after test method called'
40
103
  end
41
104
 
42
105
  def test_should_called_without_a_block_does_not_create_a_test_method
43
- assert !@target.methods.include?("test_should_go to meetings"), "Should not have method"
106
+ assert !@developer_test_suite.tests.any? {|test| test.method_name == 'test should_go to meetings' }, 'should not have defined test method'
107
+ end
108
+
109
+ def test_contexts_will_share_test_case_setup
110
+ at_work_test = @developer_test_suite.tests.find {|test| test.method_name == 'test developer at work should test their code'}
111
+ at_home_test = @developer_test_suite.tests.find {|test| test.method_name == 'test developer at home should study'}
112
+
113
+ assert_nil at_work_test.work_snack, 'work snack should not be defined'
114
+ assert_nil at_home_test.home_snack, 'home snack should not be defined'
115
+
116
+ at_work_test.orig_run(Test::Unit::TestResult.new) {|result,progress_block|}
117
+ at_home_test.orig_run(Test::Unit::TestResult.new) {|result,progress_block|}
118
+
119
+ assert_equal 'yogurt', at_work_test.work_snack, 'wrong home snack'
120
+ assert_equal 'yogurt', at_home_test.home_snack, 'wrong home snack'
121
+ end
122
+
123
+ def test_contexts_can_make_calls_to_helpers_defined_outside_of_the_context
124
+ at_work_test = @developer_test_suite.tests.find {|test| test.method_name == 'test developer at work should test their code'}
125
+
126
+ assert_nil at_work_test.unlimited_power, 'should not have unlimited power yet'
127
+
128
+ at_work_test.orig_run(Test::Unit::TestResult.new) {|result,progress_block|}
129
+ assert at_work_test.unlimited_power, 'should have unlimited power'
130
+ end
131
+
132
+ def test_contexts_can_have_their_own_setup_that_will_be_invoked_before_each_should
133
+ at_home_study_test = @developer_test_suite.tests.find {|test| test.method_name == 'test developer at home should study'}
134
+ at_home_rest_test = @developer_test_suite.tests.find {|test| test.method_name == 'test developer at home should rest'}
135
+
136
+ assert_nil at_home_study_test.study_atmosphere, 'study atmosphere should not be defined'
137
+ assert_nil at_home_rest_test.rest_atmosphere, 'rest atmosphere should not be defined'
138
+
139
+ at_home_study_test.orig_run(Test::Unit::TestResult.new) {|result,progress_block|}
140
+ at_home_rest_test.orig_run(Test::Unit::TestResult.new) {|result,progress_block|}
141
+
142
+ assert_equal 'quiet', at_home_study_test.study_atmosphere, 'wrong study atmosphere'
143
+ assert_equal 'quiet', at_home_rest_test.rest_atmosphere, 'wrong rest atmosphere'
144
+ end
145
+
146
+ def test_setup_can_be_placed_anywhere_in_a_context
147
+ at_work_test = @developer_test_suite.tests.find {|test| test.method_name == 'test developer at work should test their code'}
148
+
149
+ assert_nil at_work_test.unlimited_power, 'should not have unlimited power yet'
150
+
151
+ at_work_test.orig_run(Test::Unit::TestResult.new) {|result,progress_block|}
152
+ assert at_work_test.has_been_setup, 'should have called setup'
153
+ end
154
+
155
+ def test_a_context_does_get_polluted_with_instance_variables_from_another_context
156
+ at_home_study_test = @developer_test_suite.tests.find {|test| test.method_name == 'test developer at home should study'}
157
+ assert_nil at_home_study_test.study_atmosphere, 'study atmosphere should not be defined'
158
+
159
+ at_home_study_test.orig_run(Test::Unit::TestResult.new) {|result,progress_block|}
160
+ assert_equal 'quiet', at_home_study_test.study_atmosphere, 'wrong study atmosphere'
161
+
162
+
163
+ at_work_test = @developer_test_suite.tests.find {|test| test.method_name == 'test developer at work should test their code'}
164
+ assert_nil at_work_test.work_atmosphere, 'work atmosphere should not be defined'
165
+
166
+ at_work_test.orig_run(Test::Unit::TestResult.new) {|result,progress_block|}
167
+ assert_nil at_work_test.work_atmosphere, 'work atmosphere should not be defined'
44
168
  end
45
169
 
46
170
  def test_should_called_without_a_block_will_give_unimplemented_output_when_class_loads
47
- unimplemented_output = "UNIMPLEMENTED CASE: Developer should go to meetings"
171
+ unimplemented_output = 'UNIMPLEMENTED CASE: Developer should go to meetings'
48
172
  assert_match(/#{unimplemented_output}/, $loading_developer_test_class_output)
49
173
  end
174
+
175
+ def test_can_use_shoulds_without_a_context
176
+ dog_suite = Dog.suite
177
+ fed_test = dog_suite.tests.find {|test| test.method_name == 'test should be fed'}
178
+ assert_nil fed_test.fed, 'fed should not be defined yet'
179
+ fed_test.orig_run(Test::Unit::TestResult.new) {|result,progress_block|}
180
+ assert fed_test.fed, 'fed should be true'
181
+ end
182
+
183
+ def test_contexts_without_a_block_will_raise
184
+ assert_not_nil @@context_without_block_error, 'should have thrown an error'
185
+ assert_equal RuntimeError, @@context_without_block_error.class, 'wrong error type'
186
+ assert_match(/context: 'this will not work' called without a block/, @@context_without_block_error.message, 'wrong error message')
187
+ end
188
+
189
+ def test_defining_two_setups_in_context_will_raise
190
+ assert_not_nil @@context_without_block_error, 'should have thrown an error'
191
+ assert_equal RuntimeError, @@two_setups_error.class, 'wrong error type'
192
+ assert_equal "Can't define two setups within one context", @@two_setups_error.message
193
+ end
194
+
195
+ begin
196
+ class BoomBoom < Test::Unit::TestCase
197
+ extend Behaviors
198
+
199
+ alias_method :orig_run, :run #tuck run out of the way so Test does not have test methods run at_exit
200
+ def run(result)
201
+ end
202
+
203
+ context 'this will not work'
204
+ end
205
+ rescue => err
206
+ @@context_without_block_error = err
207
+ end
208
+
209
+ begin
210
+ class TwoSetups < Test::Unit::TestCase
211
+ extend Behaviors
212
+
213
+ alias_method :orig_run, :run #tuck run out of the way so Test does not have test methods run at_exit
214
+ def run(result)
215
+ end
216
+
217
+ context 'two setups will raise' do
218
+ setup do
219
+ end
220
+ setup do
221
+ end
222
+ end
223
+ end
224
+ rescue => err
225
+ @@two_setups_error = err
226
+ end
227
+
50
228
  end
metadata CHANGED
@@ -1,63 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
3
- specification_version: 1
4
2
  name: behaviors
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.0.3
7
- date: 2007-01-14 00:00:00 -05:00
8
- summary: behavior-driven unit test helper
9
- require_paths:
10
- - lib
11
- email: dev@atomicobject.com
12
- homepage: http://behaviors.rubyforge.org
13
- rubyforge_project: behaviors
14
- description: Behaviors allows for Test::Unit test case methods to be defined as human-readable descriptions of program behavior. It also provides Rake tasks to list the behaviors of your project.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.99.99
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
- - Atomic Object LLC
31
- files:
32
- - Manifest.txt
33
- - Rakefile
34
- - lib/behaviors.rb
35
- - lib/behaviors/reporttask.rb
36
- - test/behaviors_tasks_test.rb
37
- - test/behaviors_test.rb
38
- - test/tasks_test/lib/user.rb
39
- - test/tasks_test/Rakefile
40
- - test/tasks_test/test/user_test.rb
41
- test_files:
42
- - test/behaviors_tasks_test.rb
43
- - test/behaviors_test.rb
44
- rdoc_options: []
7
+ - Atomic Object
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
45
11
 
46
- extra_rdoc_files: []
12
+ date: 2009-12-01 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
47
15
 
16
+ description: DEPRECATED! behaviors will no longer be maintained. We recommend switching to shoulda or rspec
17
+ email: github@atomicobject.com
48
18
  executables: []
49
19
 
50
20
  extensions: []
51
21
 
22
+ extra_rdoc_files: []
23
+
24
+ files: []
25
+
26
+ has_rdoc: true
27
+ homepage: http://atomicobject.github.com
28
+ licenses: []
29
+
30
+ post_install_message:
31
+ rdoc_options:
32
+ - --charset=UTF-8
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: "0"
40
+ version:
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
52
47
  requirements: []
53
48
 
54
- dependencies:
55
- - !ruby/object:Gem::Dependency
56
- name: hoe
57
- version_requirement:
58
- version_requirements: !ruby/object:Gem::Version::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 1.1.7
63
- version:
49
+ rubyforge_project:
50
+ rubygems_version: 1.3.5
51
+ signing_key:
52
+ specification_version: 3
53
+ summary: behavior-driven unit test helper. DEPRECATED! Use rspec or shoulda instead
54
+ test_files:
55
+ - test/behaviors_tasks_test.rb
56
+ - test/behaviors_test.rb
@@ -1,9 +0,0 @@
1
- Manifest.txt
2
- Rakefile
3
- lib/behaviors.rb
4
- lib/behaviors/reporttask.rb
5
- test/behaviors_tasks_test.rb
6
- test/behaviors_test.rb
7
- test/tasks_test/lib/user.rb
8
- test/tasks_test/Rakefile
9
- test/tasks_test/test/user_test.rb
data/Rakefile DELETED
@@ -1,19 +0,0 @@
1
- require 'rake'
2
- require 'rubygems'
3
- require 'hoe'
4
-
5
- Hoe.new('behaviors','1.0.3') do |p|
6
- p.author = "Atomic Object LLC"
7
- p.email = "dev@atomicobject.com"
8
- p.url = "http://behaviors.rubyforge.org"
9
- p.summary = "behavior-driven unit test helper"
10
- p.description = <<-EOS
11
- Behaviors allows for Test::Unit test case methods to be defined as
12
- human-readable descriptions of program behavior. It also provides
13
- Rake tasks to list the behaviors of your project.
14
- EOS
15
- p.test_globs = ['test/*_test.rb']
16
-
17
- p.changes = <<-EOS
18
- EOS
19
- end
@@ -1,76 +0,0 @@
1
- =begin rdoc
2
- = Usage
3
- Behaviors provides a single method: should.
4
-
5
- Instead of naming test methods like:
6
-
7
- def test_something
8
- end
9
-
10
- You declare test methods like:
11
-
12
- should "perform action" do
13
- end
14
-
15
- You may omit the body of a <tt>should</tt> method to describe unimplemented behavior.
16
-
17
- should "perform other action"
18
-
19
- When you run your unit tests, empty <tt>should</tt> methods will appear as an 'UNIMPLEMENTED CASE' along with the described behavior.
20
- This is useful for sketching out planned behavior quickly.
21
-
22
- Simply <tt>extend Behaviors</tt> in your <tt>TestCase</tt> to start using behaviors.
23
-
24
- require 'test/unit'
25
- require 'behaviors'
26
- require 'user'
27
-
28
- class UserTest < Test::Unit::TestCase
29
- extend Behaviors
30
- ...
31
- end
32
-
33
- = Motivation
34
- Test methods typically focus on the name of the method under test instead of its behavior.
35
- Creating test methods with <tt>should</tt> statements focuses on the behavior of an object.
36
- This helps you to think about the role of the object under test.
37
-
38
- Using a behavior-driven approach prevents the danger in assuming a one-to-one mapping of method names to
39
- test method names.
40
- As always, you get the most value by writing the tests first.
41
-
42
- For a more complete BDD framework, try RSpec http://rspec.rubyforge.org/
43
-
44
- = Rake tasks
45
-
46
- You can define a <tt>Behaviors::ReportTask</tt> in your <tt>Rakefile</tt> to generate rake tasks that
47
- summarize the behavior of your project.
48
-
49
- These tasks are named <tt>behaviors</tt> and <tt>behaviors_html</tt>. They will output to the
50
- console or an html file in the <tt>doc</tt> directory with a list all of your <tt>should</tt> tests.
51
- Behaviors::ReportTask.new do |t|
52
- t.pattern = 'test/**/*_test.rb'
53
- end
54
-
55
- You may also initialize the <tt>ReportTask</tt> with a custom name to associate with a particular suite of tests.
56
- Behaviors::ReportTask.new(:widget_subsystem) do |t|
57
- t.pattern = 'test/widgets/*_test.rb'
58
- end
59
-
60
- The html report will be placed in the <tt>doc</tt> directory by default.
61
- You can override this default by setting the <tt>html_dir</tt> in the <tt>ReportTask</tt>.
62
- Behaviors::ReportTask.new do |t|
63
- t.pattern = 'test/**/*_test.rb'
64
- t.html_dir = 'behaviors_html_reports'
65
- end
66
- =end
67
- module Behaviors
68
- def should(behave,&block)
69
- mname = "test_should_#{behave}"
70
- if block
71
- define_method mname, &block
72
- else
73
- puts ">>> UNIMPLEMENTED CASE: #{name.sub(/Test$/,'')} should #{behave}"
74
- end
75
- end
76
- end
@@ -1,158 +0,0 @@
1
- require 'rake'
2
- require 'rake/tasklib'
3
-
4
- module Behaviors
5
- include Rake
6
-
7
- class ReportTask < TaskLib
8
- attr_accessor :pattern
9
- attr_accessor :html_dir
10
-
11
- def initialize(name=:behaviors)
12
- @name = name
13
- @html_dir = 'doc'
14
- yield self if block_given?
15
- define
16
- end
17
-
18
- def define
19
- desc "List behavioral definitions for the classes specified (use for=<regexp> to further limit files included in report)"
20
- task @name do
21
- specifications.each do |spec|
22
- puts "#{spec.name} should:\n"
23
- spec.requirements.each do |req|
24
- puts " - #{req}"
25
- end
26
- end
27
- end
28
-
29
- desc "Generate html report of behavioral definitions for the classes specified (use for=<regexp> to further limit files included in report)"
30
- task "#{@name}_html" do
31
- require 'erb'
32
- txt =<<-EOS
33
- <html>
34
- <head>
35
- <style>
36
-
37
- div.title
38
- {
39
- width: 600px;
40
- font: bold 14pt trebuchet ms;
41
- }
42
-
43
- div.specification
44
- {
45
- font: bold 12pt trebuchet ms;
46
- border: solid 1px black;
47
- width: 600px;
48
- padding: 5px;
49
- margin: 5px;
50
- }
51
-
52
- ul.requirements
53
- {
54
- font: normal 11pt verdana;
55
- padding-left: 0;
56
- margin-left: 0;
57
- border-bottom: 1px solid gray;
58
- width: 600px;
59
- }
60
-
61
- ul.requirements li
62
- {
63
- list-style: none;
64
- margin: 0;
65
- padding: 0.25em;
66
- border-top: 1px solid gray;
67
- }
68
- </style>
69
- </head>
70
- <body>
71
- <div class="title">Specifications</div>
72
- <% specifications.each do |spec| %>
73
- <div class="specification">
74
- <%= spec.name %> should:
75
- <ul class="requirements">
76
- <% spec.requirements.each do |req| %>
77
- <li><%= req %></li>
78
- <% end %>
79
- </ul>
80
- </div>
81
- <% end %>
82
- </body>
83
- </html>
84
- EOS
85
- output_dir = File.expand_path(@html_dir)
86
- mkdir_p output_dir
87
- output_filename = output_dir + "/behaviors.html"
88
- File.open(output_filename,"w") do |f|
89
- f.write ERB.new(txt).result(binding)
90
- end
91
- puts "(Wrote #{output_filename})"
92
- end
93
- end
94
-
95
- private
96
- def test_files
97
- test_list = FileList[@pattern]
98
- if ENV['for']
99
- test_list = test_list.grep(/#{ENV['for']}/i)
100
- end
101
- test_list
102
- end
103
-
104
- def specifications
105
- test_files.map do |file|
106
- spec = OpenStruct.new
107
- m = %r".*/([^/].*)_test.rb".match(file)
108
- class_name = titleize(m[1]) if m[1]
109
- spec.name = class_name
110
- spec.requirements = []
111
- File::readlines(file).each do |line|
112
- if line =~ /^\s*should\s+\(?\s*["'](.*)["']/
113
- spec.requirements << $1
114
- end
115
- end
116
- spec
117
- end
118
- end
119
-
120
- ############################################################
121
- # STOLEN FROM inflector.rb
122
- ############################################################
123
- #--
124
- # Copyright (c) 2005 David Heinemeier Hansson
125
- #
126
- # Permission is hereby granted, free of charge, to any person obtaining
127
- # a copy of this software and associated documentation files (the
128
- # "Software"), to deal in the Software without restriction, including
129
- # without limitation the rights to use, copy, modify, merge, publish,
130
- # distribute, sublicense, and/or sell copies of the Software, and to
131
- # permit persons to whom the Software is furnished to do so, subject to
132
- # the following conditions:
133
- #
134
- # The above copyright notice and this permission notice shall be
135
- # included in all copies or substantial portions of the Software.
136
- #
137
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
138
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
139
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
140
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
141
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
142
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
143
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
144
- #++
145
- def titleize(word)
146
- humanize(underscore(word)).gsub(/\b([a-z])/) { $1.capitalize }
147
- end
148
-
149
- def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/').
150
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase
151
- end
152
-
153
- def humanize(lower_case_and_underscored_word)
154
- lower_case_and_underscored_word.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize
155
- end
156
-
157
- end
158
- end
@@ -1,19 +0,0 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
-
4
- here = File.expand_path(File.dirname(__FILE__))
5
- require "#{here}/../../lib/behaviors/reporttask"
6
-
7
- desc 'Default: run unit tests.'
8
- task :default => :test
9
-
10
- Rake::TestTask.new(:test) do |t|
11
- t.libs << "#{here}/../../lib"
12
- t.pattern = 'test/**/*_test.rb'
13
- t.verbose = true
14
- end
15
-
16
- Behaviors::ReportTask.new(:behaviors) do |t|
17
- t.pattern = 'test/**/*_test.rb'
18
- t.html_dir = 'behaviors_doc'
19
- end
@@ -1,2 +0,0 @@
1
- class User
2
- end
@@ -1,17 +0,0 @@
1
- require 'test/unit'
2
- require 'behaviors'
3
-
4
- require 'user'
5
-
6
- class UserTest < Test::Unit::TestCase
7
- extend Behaviors
8
-
9
- def setup
10
- end
11
-
12
- should "be able set user name and age during construction"
13
- should "be able to get user name and age"
14
- should "be able to ask if a user is an adult"
15
- def test_DELETEME
16
- end
17
- end