Commit 794caa6e2c37edb8131fe1bb60964f549285223e

Update to latest rspec.

Commit diff

vendor/plugins/rspec/.autotest

 
1Autotest.add_hook :initialize do |at|
2 at.add_exception("spec/interop/test/unit/resources")
3end
toggle raw diff

vendor/plugins/rspec/CHANGES

 
1== Version 1.1.4 (trunk)
2
3Maintenance release.
4Note: we've removed the metaclass method from Object. There were some generated specs that
5used it, and they will now break. Just replace the metaclass call with (class << self; self; end)
6and all will be well.
7
8* Applied patch from Zach Dennis to merge :steps functionality to :steps_for. Closes #324.
9* Applied patch from Pat Maddox to handle redirect_to w/ SSL. Closes #320.
10* Applied patch from Ryan Davis to add eval of block passed to raise_error matcher. Closes #321.
11* alias :context :describe in example_group_methods. Closes #312.
12* Applied patch from Ben Mabey to make the Story runner exit with a non-0 exit code on failing stories. Closes #228.
13* Added #helper and #assigns to helper specs.
14* Applied patch from Bryan Helmkamp to tweak format of generated spec.opts to be more obvious. Closes #162.
15* Tweaked list of exceptions (ignores) for autotest with rspec_on_rails.
16* Applied patch from Coda Hale to get the :red hook called in autotest. Closes #279.
17* Applied patch from Patrick Ritchie to support --drb in spec.opts. Closes #274, #293.
18* Applied patch from Rick Olson to get rspec_on_rails working with rails edge (>= 8862)
19* Moved metaclass method from Object to an internal module which gets included where it is needed.
20* Applied patch from Dayo Esho: and_yield clobbers return value from block. Closes #217.
21* Applied patch from Bob Cotton: ExampleGroupFactory.default resets previously registered types. Closes #222.
22* Applied patch from Mike Williams to support the lib directory in rails apps with the Textmate Alternate File command. Closes #276.
23* ExampleGroupMethods#xspecify aliases #xit
24* A SharedExampleGroup can be created within another ExampleGroup.
25* Applied patch from Bob Cotton: Nested ExampleGroups do not have a spec_path. Closes #224.
26* Applied patch from Wincent Colaiuta to invert sense of "spec --diff". Closes #281.
27* Allow any type of render in view specs. Closes #57.
28* Applied patch from Ian White to get rspec working with edge rails (8804). Closes #271.
29
30== Version 1.1.3
31
32Maintenance release.
33Notice to autotest users: you must also upgrade to ZenTest-3.9.0.
34
35* Tightened up exceptions list in autotest/rails_spec. Closes #264.
36* Applied patch from Ryan Davis for ZenTest-3.9.0 compatibility
37* Applied patch from Kero to add step_upcoming to story listeners. Closes #253.
38* Fixed bug where the wrong named error was not always caught by "should raise_error"
39* Applied patch from Luis Lavena: No coloured output on Windows due missing RUBYOPT. Closes #244.
40* Applied patch from Craig Demyanovich to add support for "should_not render_template" to rspec_on_rails. Closes #241.
41* Added --pattern (-p for short) option to control what files get loaded. Defaults to '**/*_spec.rb'
42* Exit with non-0 exit code if examples *or tests* (in test/unit interop mode) fail. Closes #203.
43* Moved at_exit hook to a method in Spec::Runner which only runs if specs get loaded. Closes #242.
44* Applied patch from kakutani ensuring that base_view_path gets cleared after each view example. Closes #235.
45* More tweaks to regexp step names
46* Fixed focused specs in nested ExampleGroups. Closes #225.
47
48== Version 1.1.2
49
50Minor bug fixes/enhancements.
51Notice to autotest users: you must also upgrade to ZenTest-3.8.0.
52
53* RSpec's Autotest subclasses compatible with ZenTest-3.8.0 (thanks to Ryan Davis for making it easier on Autotest subs).
54* Applied patch from idl to add spec/lib to rake stats. Closes #226.
55* calling setup_fixtures and teardown_fixtures for Rails >= r8570. Closes #219.
56* Applied patch from Josh Knowles using ActiveSupport's Inflector (when available) to make 'should have' read a bit better. Closes #197.
57* Fixed regression in 1.1 that caused failing examples to fail to generate their own names. Closes #209.
58* Applied doc patch from Jens Krämer for capturing content_for
59* Applied patch from Alexander Lang to clean up story steps after each story. Closes #198.
60* Applied patch from Josh Knowles to support 'string_or_response.should have_text(...)'. Closes #193.
61* Applied patch from Ian Dees to quiet the Story Runner backtrace. Closes #183.
62* Complete support for defining steps with regexp 'names'.
63
64== Version 1.1.1
65
66Bug fix release.
67
68* Fix regression in 1.1.0 that caused transactions to not get rolled back between examples.
69* Applied patch from Bob Cotton to reintroduce ExampleGroup.description_options. Closes LH[#186]
70
171== Version 1.1.0
272
373The "tell me a story and go nest yourself" release.
7575* Applied patch from Mike Vincent to handle generators rails > 2.0.1. Closes LH[#181]
7676* Formatter.pending signature changed so it gets passed an ExampleGroup instance instead of the name ( LH[#180])
7777* Fixed LH[#180] Spec::Rails::Example::ModelExampleGroup and friends show up in rspec/rails output
78* Spec::Rails no longer loads ActiveRecord extensions if it's disablet in config/boot.rb
78* Spec::Rails no longer loads ActiveRecord extensions if it's disabled in config/boot.rb
7979* Applied LH[#178] small annoyances running specs with warnings enabled (Patch from Mikko Lehtonen)
8080* Tighter integration with Rails fixtures. Take advantage of fixture caching to get performance improvements (Thanks to Pat Maddox, Nick Kallen, Jonathan Barnes, and Curtis)
8181
109109* Applied LH[#134] Only load spec inside spec_helper.rb (Patch from Mark Van Holstyn)
110110* RSpec now bails immediately if there are examples with identical names.
111111* Applied LH[#132] Plain Text stories should support Given and Given: (Patch from Jarkko Laine)
112* Applied patch from Pat Maddox: Story Mediator - the glue that binds the plain text story parser with the rest of the system
112113* Applied LH[#16] Have SimpleMatchers expose their description for specdocs (Patch from Bryan Helmkamp)
113114* Stories now support --colour
114115* Changed the DSL modules to Example (i.e. Spec::Example instead of Spec::DSL)
toggle raw diff

vendor/plugins/rspec/README

 
3838
3939* rake # Runs the build script
4040* rcov # Verifies that the code is 100% covered by specs
41* webgen # Generates the static HTML website
42* RedCloth # Required by webgen
43* syntax # Required by our own custom webgen extension to highlight ruby code
41* webby # Generates the static HTML website
42* syntax # Required to highlight ruby code
4443* diff-lcs # Required if you use the --diff switch
4544* win32console # Required by the --colour switch if you're on Windows
4645* meta_project # Required in order to make releases at RubyForge
6565* The spec command line uses heckle when --heckle is specified.
6666* The Spec::Rake::SpecTask needs RCov if RCov is enabled in the task.
6767
68See http://rspec.rubyforge.org for further documentation.
68See http://rspec.info for further documentation.
6969
7070== Contributing
7171
toggle raw diff

vendor/plugins/rspec/Rakefile

 
77require 'rake/testtask'
88require 'spec/version'
99dir = File.dirname(__FILE__)
10$LOAD_PATH.unshift(File.expand_path("#{dir}/../pre_commit/lib"))
10$LOAD_PATH.unshift(File.expand_path("#{dir}/pre_commit/lib"))
1111require "pre_commit"
1212
1313# Some of the tasks are in separate files since they are also part of the website documentation
2222PKG_FILES = FileList[
2323 '[A-Z]*',
2424 'lib/**/*.rb',
25 'spec/**/*.rb',
25 'spec/**/*',
2626 'examples/**/*',
27 'failing_examples/**/*',
2728 'plugins/**/*',
28 'stories/**/*'
29 'stories/**/*',
30 'pre_commit/**/*',
31 'rake_tasks/**/*'
2932]
3033
3134task :default => [:verify_rcov]
3737desc "Run all specs"
3838Spec::Rake::SpecTask.new do |t|
3939 t.spec_files = FileList['spec/**/*_spec.rb']
40 t.spec_opts = ['--options', 'spec.opts']
40 t.spec_opts = ['--options', 'spec/spec.opts']
4141 unless ENV['NO_RCOV']
4242 t.rcov = true
4343 t.rcov_dir = '../doc/output/coverage'
9090 s.rdoc_options = rd.options
9191 s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$|^EXAMPLES.rd$/ }.to_a
9292
93 s.autorequire = 'spec'
9493 s.bindir = 'bin'
9594 s.executables = ['spec', 'spec_translator']
9695 s.default_executable = 'spec'
128128 core.clobber
129129end
130130
131task :release => [:clobber, :verify_committed, :verify_user, :spec, :publish_packages, :tag, :publish_website, :publish_news]
131task :release => [:clobber, :verify_committed, :verify_user, :spec, :publish_packages, :tag, :publish_news]
132132
133133desc "Verifies that there is no uncommitted code"
134134task :verify_committed do
toggle raw diff

vendor/plugins/rspec/bin/spec

 
1#!/usr/bin/env ruby
12$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
23require 'spec'
34exit ::Spec::Runner::CommandLine.run(rspec_options)
toggle raw diff

vendor/plugins/rspec/examples/pure/helper_method_example.rb

 
11require File.dirname(__FILE__) + '/spec_helper'
22
3describe "a context with helper a method" do
4 def helper_method
5 "received call"
6 end
3module HelperMethodExample
4 describe "an example group with helper a method" do
5 def helper_method
6 "received call"
7 end
78
8 it "should make that method available to specs" do
9 helper_method.should == "received call"
9 it "should make that method available to specs" do
10 helper_method.should == "received call"
11 end
1012 end
1113end
14
toggle raw diff

vendor/plugins/rspec/examples/pure/shared_example_group_example.rb

 
1919 end
2020 end
2121
22 # A SharedExampleGroup is a module, so you can assign
23 # it to a constant if you want ....
24 AllThings = shared_examples_for "All Things" do
22 # A SharedExampleGroup is an example group that doesn't get run.
23 # You can create one like this:
24 share_examples_for "most things" do
2525 def helper_method
2626 "helper method"
2727 end
3030 @thing.what_things_do.should == "stuff"
3131 end
3232 end
33
34 # TODO - it would be nice to be able to say this instead of the above:
35
36 # class AllThings < Spec::SharedExampleGroup
37 # ...
38 # end
3933
34 # A SharedExampleGroup is also module. If you create one like this
35 # it gets assigned to the constant AllThings
36 share_as :MostThings do
37 def helper_method
38 "helper method"
39 end
40
41 it "should do what things do" do
42 @thing.what_things_do.should == "stuff"
43 end
44 end
45
4046 describe OneThing do
41 # ... then you can include the example group like this, which
47 # Now you can include the shared example group like this, which
4248 # feels more like what you might say ...
43 it_should_behave_like "All Things"
49 it_should_behave_like "most things"
50
4451 before(:each) { @thing = OneThing.new }
4552
4653 it "should have access to helper methods defined in the shared example group" do
5858 describe AnotherThing do
5959 # ... or you can include the example group like this, which
6060 # feels more like the programming language we love.
61 it_should_behave_like AllThings
61 it_should_behave_like MostThings
6262
6363 before(:each) { @thing = AnotherThing.new }
64
65 it "should have access to helper methods defined in the shared example group" do
66 helper_method.should == "helper method"
67 end
6468 end
6569
6670 describe YetAnotherThing do
6771 # ... or you can include the example group like this, which
6872 # feels more like the programming language we love.
69 include AllThings
73 include MostThings
7074
7175 before(:each) { @thing = AnotherThing.new }
76
77 it "should have access to helper methods defined in the shared example group" do
78 helper_method.should == "helper method"
79 end
7280 end
7381end
toggle raw diff

vendor/plugins/rspec/examples/stories/calculator.rb

 
2727 As an accountant
2828 I want to add numbers
2929 So that I can count some beans
30}, :steps => steps do
30}, :steps_for => steps do
3131 Scenario "2 + 3" do
3232 Given "an addend of 2"
3333 And "an addend of 3"
toggle raw diff

vendor/plugins/rspec/failing_examples/README.txt

 
1"Why have failing examples?", you might ask.
2
3They allow us to see failure messages. RSpec wants to provide meaningful and helpful failure messages. The failures in this directory not only provide you a way of seeing the failure messages, but they provide RSpec's own specs a way of describing what they should look like and ensuring they stay correct.
4
5To see the types of messages you can expect, stand in this directory and run:
6
7../bin/spec ./*.rb
toggle raw diff

vendor/plugins/rspec/failing_examples/failing_autogenerated_docstrings_example.rb

 
1require File.dirname(__FILE__) + '/spec_helper'
2
3# Run spec w/ -fs to see the output of this file
4
5describe "Failing examples with no descriptions" do
6
7 # description is auto-generated as "should equal(5)" based on the last #should
8 it do
9 3.should equal(2)
10 5.should equal(5)
11 end
12
13 it { 3.should be > 5 }
14
15 it { ["a"].should include("b") }
16
17 it { [1,2,3].should_not respond_to(:size) }
18
19end
toggle raw diff

vendor/plugins/rspec/lib/autotest/rspec.rb

 
11require 'autotest'
22
3Autotest.add_hook :initialize do |at|
4 at.clear_mappings
5 # watch out: Ruby bug (1.8.6):
6 # %r(/) != /\//
7 at.add_mapping(%r%^spec/.*\.rb$%) { |filename, _|
8 filename
9 }
10 at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
11 ["spec/#{m[1]}_spec.rb"]
12 }
13 at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
14 at.files_matching %r%^spec/.*_spec\.rb$%
15 }
16end
17
318class RspecCommandError < StandardError; end
419
520class Autotest::Rspec < Autotest
6
7 def initialize(kernel=Kernel, separator=File::SEPARATOR, alt_separator=File::ALT_SEPARATOR) # :nodoc:
8 super()
9 @kernel, @separator, @alt_separator = kernel, separator, alt_separator
10 @spec_command = spec_command
1121
12 # watch out: Ruby bug (1.8.6):
13 # %r(/) != /\//
14 # since Ruby compares the REGEXP source, not the resulting pattern
15 @test_mappings = {
16 %r%^spec/.*\.rb$% => kernel.proc { |filename, _|
17 filename
18 },
19 %r%^lib/(.*)\.rb$% => kernel.proc { |_, m|
20 ["spec/#{m[1]}_spec.rb"]
21 },
22 %r%^spec/(spec_helper|shared/.*)\.rb$% => kernel.proc {
23 files_matching %r%^spec/.*_spec\.rb$%
24 }
25 }
26 end
27
28 def tests_for_file(filename)
29 super.select { |f| @files.has_key? f }
22 def initialize
23 super
24 self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m
25 self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
3026 end
3127
32 alias :specs_for_file :tests_for_file
33
34 def failed_results(results)
35 results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
36 end
37
38 def handle_results(results)
39 @files_to_test = consolidate_failures failed_results(results)
40 unless @files_to_test.empty? then
41 hook :red
42 else
43 hook :green
44 end unless $TESTING
45 @tainted = true unless @files_to_test.empty?
46 end
47
4828 def consolidate_failures(failed)
49 filters = Hash.new { |h,k| h[k] = [] }
50 failed.each do |spec, failed_trace|
51 @files.keys.select{|f| f =~ /spec\//}.each do |f|
52 if failed_trace =~ Regexp.new(f)
53 filters[f] << spec
54 break
55 end
29 filters = new_hash_of_arrays
30 failed.each do |spec, trace|
31 if trace =~ /\n(\.\/)?(.*\.rb):[\d]+:\Z?/
32 filters[$2] << spec
5633 end
5734 end
5835 return filters
5936 end
6037
6138 def make_test_cmd(files_to_test)
62 return "#{ruby} -S #{@spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
39 return "#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
6340 end
6441
65 def add_options_if_present
42 def add_options_if_present # :nodoc:
6643 File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
6744 end
6845
69 # Finds the proper spec command to use. Precendence
70 # is set in the lazily-evaluated method spec_commands. Alias + Override
71 # that in ~/.autotest to provide a different spec command
72 # then the defau