behaviors 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Rakefile +1 -1
  2. data/lib/behaviors.rb +38 -12
  3. metadata +2 -2
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rake'
2
2
  require 'rubygems'
3
3
  require 'hoe'
4
4
 
5
- Hoe.new('behaviors','1.0.2') do |p|
5
+ Hoe.new('behaviors','1.0.3') do |p|
6
6
  p.author = "Atomic Object LLC"
7
7
  p.email = "dev@atomicobject.com"
8
8
  p.url = "http://behaviors.rubyforge.org"
@@ -1,8 +1,6 @@
1
1
  =begin rdoc
2
2
  = Usage
3
3
  Behaviors provides a single method: should.
4
-
5
- Your test classes should <tt>extend Behaviors</tt>.
6
4
 
7
5
  Instead of naming test methods like:
8
6
 
@@ -14,29 +12,57 @@ You declare test methods like:
14
12
  should "perform action" do
15
13
  end
16
14
 
17
- You also have the ability to declare flunking test methods as a way
18
- to describe future tests:
15
+ You may omit the body of a <tt>should</tt> method to describe unimplemented behavior.
19
16
 
20
17
  should "perform other action"
21
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
+
22
33
  = Motivation
23
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.
24
37
 
25
- Creating test methods with <tt>should</tt> statements focuses on the behaviors of an object.
26
- This enhances the TDD experience by provoking the developer to think about the role of the object under test.
27
-
28
- Writing the tests first to declare an object's behaviors and then implementing those
29
- behaviors through object methods produces the most value.
30
- Using this behavior-driven approach prevents the dangers associated with assuming a one-to-one mapping of method names to
38
+ Using a behavior-driven approach prevents the danger in assuming a one-to-one mapping of method names to
31
39
  test method names.
40
+ As always, you get the most value by writing the tests first.
32
41
 
33
42
  For a more complete BDD framework, try RSpec http://rspec.rubyforge.org/
34
43
 
35
44
  = Rake tasks
36
45
 
37
- Behaviors includes a pair of Rake tasks, <tt>behaviors</tt> and <tt>behaviors_html</tt>. These tasks will output to the
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
38
50
  console or an html file in the <tt>doc</tt> directory with a list all of your <tt>should</tt> tests.
39
- Use these tasks to summarize the behavior of your project.
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
40
66
  =end
41
67
  module Behaviors
42
68
  def should(behave,&block)
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: behaviors
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.2
7
- date: 2007-01-13 00:00:00 -05:00
6
+ version: 1.0.3
7
+ date: 2007-01-14 00:00:00 -05:00
8
8
  summary: behavior-driven unit test helper
9
9
  require_paths:
10
10
  - lib