rspec 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/CHANGES +10 -2
  2. data/EXAMPLES.rd +34 -0
  3. data/README +1 -1
  4. data/Rakefile +23 -28
  5. data/bin/spec +0 -1
  6. data/doc/src/core_team.page +18 -9
  7. data/doc/src/tools/rails.page +71 -5
  8. data/doc/src/tools/rake.page +5 -8
  9. data/doc/src/tools/rcov.page +14 -5
  10. data/doc/src/tools/spec.page +33 -18
  11. data/doc/src/tutorials/meta.info +6 -1
  12. data/doc/src/tutorials/stack.rb +1 -1
  13. data/doc/src/tutorials/stack_01.page +2 -0
  14. data/doc/src/tutorials/stack_02.page +6 -4
  15. data/doc/src/tutorials/stack_03.page +7 -15
  16. data/doc/src/tutorials/stack_04.page +39 -78
  17. data/doc/src/tutorials/stack_05.page +1 -1
  18. data/doc/src/tutorials/stack_spec.rb +2 -18
  19. data/lib/spec/rake/rcov_verify.rb +2 -2
  20. data/lib/spec/rake/spectask.rb +4 -9
  21. data/lib/spec/runner.rb +1 -0
  22. data/lib/spec/runner/backtrace_tweaker.rb +2 -0
  23. data/lib/spec/runner/context.rb +7 -5
  24. data/lib/spec/runner/context_runner.rb +4 -4
  25. data/lib/spec/runner/kernel_ext.rb +1 -1
  26. data/lib/spec/runner/spec_matcher.rb +39 -0
  27. data/lib/spec/runner/specification.rb +3 -3
  28. data/lib/spec/version.rb +1 -1
  29. data/test/spec/api/helper/equality_test.rb +1 -1
  30. data/test/spec/runner/backtrace_tweaker_test.rb +15 -9
  31. data/test/spec/runner/context_matching_test.rb +35 -0
  32. data/test/spec/runner/context_runner_test.rb +16 -16
  33. data/test/spec/runner/context_test.rb +0 -21
  34. data/test/spec/runner/spec_matcher_test.rb +42 -0
  35. data/test/spec/runner/specification_test.rb +9 -4
  36. metadata +12 -10
  37. data/doc/reference/rspec reference.page +0 -0
  38. data/test/rcov/rcov_testtask.rb +0 -46
data/CHANGES CHANGED
@@ -1,7 +1,15 @@
1
1
  = RSpec Changelog
2
2
 
3
- == Version 0.5.4 (in SVN)
4
- Release notes go here
3
+ == Version 0.5.5
4
+ This release adds initial support for Ruby on Rails in the rspec_generator gem.
5
+
6
+ * [Rails] Reorganised Lachie's original code to be a generator packaged as a gem rather than a plugin.
7
+ * [Rails] Imported code from http://lachie.info/svn/projects/rails_plugins/rspec_on_rails (Written by Lachie Cox)
8
+ * Remove stack trace lines from TextMate's Ruby bundle
9
+ * Better error message from spectask when no spec files are found.
10
+
11
+ == Version 0.5.4
12
+ The "the tutorial is ahead of the gem" release
5
13
 
6
14
  * Support for running a single spec with --spec
7
15
  * Exitcode is now 1 unless all specs pass, in which case it's 0.
data/EXAMPLES.rd CHANGED
@@ -0,0 +1,34 @@
1
+ # Airport at home
2
+ # * should always work
3
+ # * not need cables
4
+ # * not need electricity
5
+ # BDD framework
6
+ # * should be adopted quickly
7
+ # * should be intuitive
8
+ # Mocker
9
+ # * should be able to call mock()
10
+ # An empty stack
11
+ # * should accept an item when sent push
12
+ # * should complain when sent top
13
+ # * should complain when sent pop
14
+ # A stack with one item
15
+ # * should accept an item when sent push
16
+ # * should return top when sent top
17
+ # * should not remove top when sent top
18
+ # * should return top when sent pop
19
+ # * should remove top when sent pop
20
+ # An almost full stack (with one item less than capacity)
21
+ # * should accept an item when sent push
22
+ # * should return top when sent top
23
+ # * should not remove top when sent top
24
+ # * should return top when sent pop
25
+ # * should remove top when sent pop
26
+ # A full stack
27
+ # * should complain on push
28
+ # * should return top when sent top
29
+ # * should not remove top when sent top
30
+ # * should return top when sent pop
31
+ # * should remove top when sent pop
32
+ # Underscore sugar
33
+ # * should be available for regular objects
34
+ # * should be available for mocks
data/README CHANGED
@@ -1 +1 @@
1
- See http://rspec.rubyforge.org
1
+ See http://rspec.rubyforge.org for detailed documentation.
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ require 'rake/rdoctask'
8
8
  require 'spec/version'
9
9
  require 'spec/rake/spectask'
10
10
  require 'spec/rake/rcov_verify'
11
- require 'test/rcov/rcov_testtask'
11
+ require 'rcov/rcovtask'
12
12
 
13
13
  # Some of the tasks are in separate files since they are also part of the website documentation
14
14
  load File.dirname(__FILE__) + '/test/tasks/examples.rake'
@@ -17,12 +17,6 @@ load File.dirname(__FILE__) + '/test/tasks/examples_with_rcov.rake'
17
17
  load File.dirname(__FILE__) + '/test/tasks/rcov_verify.rake'
18
18
 
19
19
  PKG_NAME = "rspec"
20
- # Versioning scheme: MAJOR.MINOR.PATCH
21
- # MAJOR bumps when API is broken backwards
22
- # MINOR bumps when the API is broken backwards in a very slight/subtle (but not fatal) way
23
- # -OR when a new release is made and propaganda is sent out.
24
- # PATCH is bumped for every API addition and/or bugfix (ideally for every commit)
25
-
26
20
  PKG_VERSION = Spec::VERSION::STRING
27
21
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
28
22
  PKG_FILES = FileList[
@@ -45,9 +39,10 @@ Rake::TestTask.new do |t|
45
39
  t.verbose = true
46
40
  end
47
41
 
48
- RCov::TestTask.new do |t|
42
+ Rcov::RcovTask.new do |t|
49
43
  t.test_files = FileList['test/**/*_test.rb']
50
- t.verbose = true
44
+ t.output_dir = 'doc/output/coverage'
45
+ t.rcov_opts = []
51
46
  end
52
47
 
53
48
  desc 'Generate HTML documentation'
@@ -66,11 +61,11 @@ end
66
61
  spec = Gem::Specification.new do |s|
67
62
  s.name = PKG_NAME
68
63
  s.version = PKG_VERSION
69
- s.summary = "Behaviour Specification Framework for Ruby"
64
+ s.summary = Spec::VERSION::DESCRIPTION
70
65
  s.description = <<-EOF
71
- RSpec is a behaviour specification framework for Ruby. RSpec was created in
72
- response to Dave Astels' article _A New Look at Test Driven Development_ which
73
- can be read at: http://daveastels.com/index.php?p=5 RSpec is intended to
66
+ RSpec is a behaviour driven development (BDD) framework for Ruby. RSpec was
67
+ created in response to Dave Astels' article _A New Look at Test Driven Development_
68
+ which can be read at: http://daveastels.com/index.php?p=5 RSpec is intended to
74
69
  provide the features discussed in Dave's article.
75
70
  EOF
76
71
 
@@ -90,8 +85,8 @@ spec = Gem::Specification.new do |s|
90
85
  s.bindir = "bin"
91
86
  s.executables = ["spec", "test2rspec"]
92
87
  s.default_executable = "spec"
93
- s.author = "Steven Baker"
94
- s.email = "srbaker@pobox.com"
88
+ s.author = "Steven Baker, Aslak Hellesoy, Dave Astels, David Chelimsky"
89
+ s.email = "rspec-devel@rubyforge.org"
95
90
  s.homepage = "http://rspec.rubyforge.org"
96
91
  s.rubyforge_project = "rspec"
97
92
  end
@@ -121,24 +116,16 @@ task :todo do
121
116
  end
122
117
 
123
118
  task :clobber do
124
- rm_rf 'coverage'
125
119
  rm_rf 'doc/output'
126
120
  end
127
121
 
128
122
  task :release => [:clobber, :verify_user, :verify_password, :test, :publish_packages, :publish_website, :publish_news]
129
123
 
130
124
  desc "Build the website with rdoc and rcov, but do not publish it"
131
- task :website => [:clobber, :copy_rcov_report, :doc, :examples_specdoc, :rdoc]
132
-
133
- task :copy_rcov_report => [:test_with_rcov, :rcov_verify] do
134
- rm_rf 'doc/output/coverage'
135
- mkdir 'doc/output' unless File.exists? 'doc/output'
136
- mv 'coverage', 'doc/output'
137
- end
125
+ task :website => [:clobber, :rcov_verify, :doc, :examples_specdoc, :rdoc]
138
126
 
139
127
  task :verify_user do
140
128
  raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
141
- raise "BEHAVIOURDRIVEN_USER environment variable not set!" unless ENV['BEHAVIOURDRIVEN_USER']
142
129
  end
143
130
 
144
131
  task :verify_password do
@@ -148,22 +135,30 @@ end
148
135
  desc "Upload Website to RubyForge"
149
136
  task :publish_website => [:verify_user, :website] do
150
137
  publisher = Rake::SshDirPublisher.new(
151
- "#{ENV['BEHAVIOURDRIVEN_USER']}@www.behaviourdriven.org",
152
- "/var/www/behaviourdriven.org/htdocs/#{PKG_NAME}",
138
+ "#{ENV['RUBYFORGE_USER']}@rubyforge.org",
139
+ "/var/www/gforge-projects/#{PKG_NAME}",
153
140
  "doc/output"
154
141
  )
155
142
 
156
143
  publisher.upload
157
144
  end
158
145
 
146
+ task :package_rails do
147
+ Dir.chdir 'vendor/rspec_on_rails/vendor/generators/rspec' do
148
+ `rake clobber gem`
149
+ raise "Failed to package RSpec on Rails" if $? != 0
150
+ end
151
+ end
152
+
159
153
  desc "Publish gem+tgz+zip on RubyForge. You must make sure lib/version.rb is aligned with the CHANGELOG file"
160
- task :publish_packages => [:verify_user, :verify_password, :package] do
154
+ task :publish_packages => [:verify_user, :verify_password, :package, :package_rails] do
161
155
  require 'meta_project'
162
156
  require 'rake/contrib/xforge'
163
157
  release_files = FileList[
164
158
  "pkg/#{PKG_FILE_NAME}.gem",
165
159
  "pkg/#{PKG_FILE_NAME}.tgz",
166
- "pkg/#{PKG_FILE_NAME}.zip"
160
+ "pkg/#{PKG_FILE_NAME}.zip",
161
+ "vendor/rspec_on_rails/vendor/generators/rspec/pkg/rspec_generator-#{Spec::VERSION::STRING}.gem"
167
162
  ]
168
163
 
169
164
  Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new(PKG_NAME)) do |xf|
data/bin/spec CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require File.expand_path(File.dirname(__FILE__) + "/../lib/spec") # better stack traces this way
4
3
 
5
4
  $context_runner = ::Spec::Runner::OptionParser.create_context_runner(ARGV, false, STDERR, STDOUT)
@@ -10,13 +10,22 @@ h2. The Core Team
10
10
  * David Chelimsky
11
11
  * Aslak Hellesoy
12
12
 
13
+ <notextile>
13
14
  <table>
14
- <tr>
15
- <td><img src="images/David_and_Aslak.jpg"></td>
16
- <td><img src="images/Whats_That_Dude.jpg"></td>
17
- </tr>
18
- <tr>
19
- <td align="center">David and Aslak getting ready for 1.0</td>
20
- <td align="center">What's that, Dude?</td>
21
- </tr>
22
- </table>
15
+ <tr>
16
+ <td><img src="images/David_and_Aslak.jpg" /></td>
17
+ <td><img src="images/Whats_That_Dude.jpg" /></td>
18
+ <td><img src="http://static.flickr.com/1/127260733_84714abc76_o_d.png" /></td>
19
+ </tr>
20
+ <tr>
21
+ <td align="center">David and Aslak tweaking backtraces</td>
22
+ <td align="center">What's that, Dude?</td>
23
+ <td align="center">Dave Astels</td>
24
+ </tr>
25
+ </table>
26
+ </notextile>
27
+
28
+ h2. Contributors
29
+
30
+ * Lachie Cox (Rails support)
31
+ * Rich Kilmer (Underscore syntactic sugar)
@@ -1,9 +1,75 @@
1
1
  ---
2
- title: Rails Integration
2
+ title: RSpec on Rails
3
3
  inMenu: true
4
4
  ---
5
- h2. Rails Integration
5
+ h2. RSpec on Rails
6
6
 
7
- Rspec's support for Rails is in a very early and experimental stage.
8
- If you are adventurous, you can check out the branches/ar_fixtures_facade branch in Subversion.
9
- See the downloads page for details.
7
+ RSpec's rspec_generator Rubygem brings RSpec to Rails.
8
+
9
+ h3. Features
10
+
11
+ * Integrated fixture loading
12
+ * Uses many of the controller-test integration features
13
+ * Special generators for models and controllers that generate specs instead of tests.
14
+
15
+ h3. Installation
16
+
17
+ RSpec support for rails lives in a separate gem. Install that gem:
18
+ <pre>
19
+ gem install rspec_generator
20
+ </pre>
21
+
22
+ Once the gem is installed, you must configure you Rails app. Stand in the root of your Rails app and run:
23
+ <pre>
24
+ ruby script/generate rspec
25
+ </pre>
26
+
27
+ Now, you can generate models and controllers in a similar fashion to Rails' builtin generators. Example:
28
+
29
+ <pre>
30
+ ruby script/generate rspec_model person
31
+ </pre>
32
+
33
+ or
34
+
35
+ <pre>
36
+ ruby script/generate rspec_controller person
37
+ </pre>
38
+
39
+ For more information on each generator, just run them without any arguments.
40
+
41
+ h3. Running specs
42
+
43
+ Model specs can be run with
44
+ <pre>
45
+ rake spec:models
46
+ </pre>
47
+
48
+ Controller specs can be run with
49
+ <pre>
50
+ rake spec:controllers
51
+ </pre>
52
+
53
+ To see all the RSpec related tasks, run
54
+ <pre>
55
+ rake --tasks spec
56
+ </pre>
57
+
58
+ h3. Naming conventions
59
+
60
+ When you use Rails without RSpec (with Test::Unit), tests for models end up in tests/unit and tests for controllers
61
+ end up in tests/functional.
62
+
63
+ In order to make things more consistent, RSpec chooses a slightly different naming convention for direcotries and
64
+ Rake tasks. So you will find model specs under specs/models, and controller specs under specs/controllers. The
65
+ Rake tasks are named accordingly.
66
+
67
+ h3. Examples
68
+
69
+ RSpec on Rails adds several methods to your specs with a look and feel similar to Test::Unit. Example:
70
+
71
+ Model:
72
+ <ruby file="../vendor/rspec_on_rails/spec/models/person_spec.rb"/>
73
+
74
+ Controller:
75
+ <ruby file="../vendor/rspec_on_rails/spec/controllers/person_controller_spec.rb"/>
@@ -4,21 +4,18 @@ inMenu: true
4
4
  ---
5
5
  h2. Rake Task
6
6
 
7
- RSpec's Rake task allows you to do many things.
8
- (See the <notextile><a href="../rdoc/classes/Spec/Rake/SpecTask.html">RDoc</a></notextile> for details)
7
+ RSpec coomes with a Rake task for executing specs.
8
+ See "Spec::Rake::SpecTask":../rdoc/classes/Spec/Rake/SpecTask.html for details.
9
9
 
10
10
  h3. Run specs
11
11
 
12
12
  <ruby file="../test/tasks/examples.rake"/>
13
13
 
14
- h3. Run specs with RCov
15
-
16
- <ruby file="../test/tasks/examples_with_rcov.rake"/>
17
-
18
- This will generate a coverage report like <notextile><a href="../coverage/index.html">this</a></notextile>.
14
+ Also see the "RCov":rcov.html page for info about how to generate a coverage report.
19
15
 
20
16
  h3. Generate specdocs
21
17
 
22
18
  <ruby file="../test/tasks/examples_specdoc.rake"/>
23
19
 
24
- This will output the specdocs to a file, which can be included in your RDoc. Just like <notextile><a href="../rdoc/files/EXAMPLES_rd.html">this</a></notextile>.
20
+ This will output the specdocs to a file, which can be included in your RDoc.
21
+ Just like "this":../rdoc/files/EXAMPLES_rd.html.
@@ -4,16 +4,25 @@ inMenu: true
4
4
  ---
5
5
  h2. RCov
6
6
 
7
- RSpec has tight integration with <a href="http://eigenclass.org/hiki.rb?rcov=">RCov</a>. If you have RCov installed you can
8
- use the rake task to generate a coverage report. See the <a href="../rake.html">Rake</a> for details.
7
+ RSpec has tight integration with "RCov":http://eigenclass.org/hiki.rb?rcov=.
8
+
9
+ h3. Run specs with RCov
10
+
11
+ <ruby file="../test/tasks/examples_with_rcov.rake"/>
12
+
13
+ By adding rcov=true to the rake task, specs will be run with rcov
14
+ instead of ruby, and a coverage report like "this":../coverage/index.html will be generated.
15
+
16
+ See "Spec::Rake::SpecTask":../rdoc/classes/Spec/Rake/SpecTask.html for details.
9
17
 
10
18
  h3. Coverage threshold
11
19
 
12
- You can guard your codebase's coverage from dropping by adding the
13
- <notextile><a href="../rdoc/classes/RCov/VerifyTask.html">RCov::VerifyTask</a></notextile>
14
- task to your Rakefile. Example:
20
+ You can guard your codebase's coverage from dropping below a certain threshold
21
+ by using RSpec's built-in task for verification of the total RCov coverage.
15
22
 
16
23
  <ruby file="../test/tasks/rcov_verify.rake"/>
17
24
 
18
25
  This will give you a :rcov_verify task that will fail your build if the
19
26
  coverage drops below the threshold you define (the higher the better).
27
+
28
+ See "RCov::VerifyTask":../rdoc/classes/RCov/VerifyTask.html for details.
@@ -32,8 +32,8 @@ Any number of files and/or directories can be provided, all ruby source files
32
32
  that are found are loaded. Running spec on the previous example results in:
33
33
 
34
34
  <pre>
35
- bin/spec
36
- {execute: ../bin/spec ../examples}
35
+ bin/spec examples
36
+ {execute: ruby ../bin/spec ../examples}
37
37
  </pre>
38
38
 
39
39
  Very simple and to the point. Passing specifications are indicated by a '.',
@@ -55,23 +55,10 @@ Additional command line options can be passed to customize the output and behavi
55
55
  The following options apply whether specs are run in standalone mode (by executing the .rb files directly),
56
56
  or using the spec command.
57
57
 
58
- h3. -v, --verbose
58
+ h3. -f, --format [specdoc|s|rdoc|r|]
59
59
 
60
- Using this option tells the formatter (which by default is specdoc) to produce more verbose output:
61
-
62
- <pre>
63
- $ bin/spec failing_examples/team_spec.rb -v
64
-
65
- {execute: ../bin/spec ../failing_examples/team_spec.rb -v}
66
- </pre>
67
-
68
- The spec command does double duty as documentation generation from a set of
69
- specifications as well as running them against your code.
70
-
71
- h3. -f, --format [specdoc|rdoc]
72
-
73
- Specify the output format. Most formats will produce some form of "testdox":http://agiledox.sourceforge.net/
74
- output. The --verbose and --dry-run options may also affect the output format.
60
+ Specify the output format. Default format is "progress bar" ("." for pass, "F" for fail). Most formats will produce some form of "testdox":http://agiledox.sourceforge.net/
61
+ output. The --dry-run options may also affect the output format.
75
62
 
76
63
  For example, by setting the formatter to rdoc, we can output the kind of input that RDoc
77
64
  needs to produce something like "this":../rdoc/files/EXAMPLES_rd.html
@@ -97,3 +84,31 @@ $ bin/spec failing_examples/team_spec.rb -b
97
84
 
98
85
  {execute: ../bin/spec ../failing_examples/team_spec.rb -b}
99
86
  </pre>
87
+
88
+ h3. -s, --spec &lt;name of context and/or specification&gt;
89
+
90
+ Enter the name of a context, spec, or both to run:
91
+
92
+ all the specs in a context ...
93
+
94
+ <pre>
95
+ $ bin/spec examples --spec "A stack with one item" -f s
96
+
97
+ {execute: ../bin/spec ../examples --spec "A stack with one item" -f s}
98
+ </pre>
99
+
100
+ ... any spec in any context with a given name ...
101
+
102
+ <pre>
103
+ $ bin/spec examples --spec "should return top when sent top" -f s
104
+
105
+ {execute: ../bin/spec ../examples --spec "should return top when sent top" -f s}
106
+ </pre>
107
+
108
+ ... or a specific spec in a specific context:
109
+
110
+ <pre>
111
+ $ bin/spec examples --spec "A stack with one item should return top when sent top" -f s
112
+
113
+ {execute: ../bin/spec ../examples --spec "A stack with one item should return top when sent top" -f s}
114
+ </pre>
@@ -25,7 +25,12 @@ stack_04.page:
25
25
 
26
26
  stack_05.page:
27
27
  title: '5'
28
- inMenu: true
28
+ inMenu: false
29
29
  orderInfo: 15
30
30
 
31
+ stack_05.page:
32
+ title: '6'
33
+ inMenu: false
34
+ orderInfo: 16
35
+
31
36
 
@@ -8,4 +8,4 @@ class Stack
8
8
  def top
9
9
  @item
10
10
  end
11
- end
11
+ end