Permalink
Browse files

Upgraded to rspec trunk

  • Loading branch information...
1 parent 782f18e commit c96e8c2ee76e873c22782b97d6057a45f2e5b71e Joe Van Dyk committed Feb 21, 2008
Showing with 488 additions and 4,718 deletions.
  1. +0 −7 spec/helpers/refunds_helper_spec.rb
  2. +0 −7 spec/helpers/voids_helper_spec.rb
  3. +26 −0 vendor/plugins/rspec/CHANGES
  4. +0 −6 vendor/plugins/rspec/autotest/discover.rb
  5. +0 −1 vendor/plugins/rspec/autotest/rspec.rb
  6. +7 −9 vendor/plugins/rspec/lib/autotest/rspec.rb
  7. +3 −7 vendor/plugins/rspec/lib/spec/example/example_group_factory.rb
  8. +11 −3 vendor/plugins/rspec/lib/spec/example/example_group_methods.rb
  9. +4 −0 vendor/plugins/rspec/lib/spec/example/example_methods.rb
  10. +1 −1 vendor/plugins/rspec/lib/spec/expectations/differs/default.rb
  11. +1 −0 vendor/plugins/rspec/lib/spec/extensions.rb
  12. +7 −0 vendor/plugins/rspec/lib/spec/extensions/metaclass.rb
  13. +0 −4 vendor/plugins/rspec/lib/spec/extensions/object.rb
  14. +3 −1 vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb
  15. +6 −10 vendor/plugins/rspec/lib/spec/mocks/proxy.rb
  16. +2 −3 vendor/plugins/rspec/lib/spec/runner/formatter/base_formatter.rb
  17. +2 −2 vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb
  18. +6 −4 vendor/plugins/rspec/lib/spec/runner/formatter/failing_example_groups_formatter.rb
  19. +1 −1 vendor/plugins/rspec/lib/spec/runner/formatter/html_formatter.rb
  20. +1 −1 vendor/plugins/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb
  21. +1 −1 vendor/plugins/rspec/lib/spec/runner/formatter/specdoc_formatter.rb
  22. +6 −2 vendor/plugins/rspec/lib/spec/runner/option_parser.rb
  23. +4 −2 vendor/plugins/rspec/lib/spec/runner/options.rb
  24. +15 −11 vendor/plugins/rspec/lib/spec/runner/reporter.rb
  25. +1 −1 vendor/plugins/rspec/lib/spec/version.rb
  26. +0 −4,358 vendor/plugins/rspec/report.html
  27. +12 −10 vendor/plugins/rspec/spec/autotest/rspec_spec.rb
  28. +6 −0 vendor/plugins/rspec/spec/spec/example/example_group_factory_spec.rb
  29. +46 −14 vendor/plugins/rspec/spec/spec/example/example_group_methods_spec.rb
  30. +11 −0 vendor/plugins/rspec/spec/spec/example/example_methods_spec.rb
  31. +12 −0 vendor/plugins/rspec/spec/spec/example/nested_example_group_spec.rb
  32. +27 −9 vendor/plugins/rspec/spec/spec/expectations/differs/default_spec.rb
  33. +24 −0 vendor/plugins/rspec/spec/spec/matchers/be_spec.rb
  34. 0 vendor/plugins/rspec/spec/spec/mocks/{bug_report_10263.rb → bug_report_10263_spec.rb}
  35. +2 −0 vendor/plugins/rspec/spec/spec/mocks/bug_report_11545_spec.rb
  36. +7 −1 vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb
  37. +3 −2 vendor/plugins/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb
  38. +25 −19 vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html
  39. +12 −2 vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb
  40. +7 −4 vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb
  41. +29 −23 vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html
  42. +6 −0 vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb
  43. +10 −7 vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb
  44. +1 −0 vendor/plugins/rspec/spec/spec/runner/spec_drb.opts
  45. +2 −4 vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts
  46. +3 −3 vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb
  47. +4 −4 vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb
  48. +2 −2 vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb
  49. +1 −1 vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb
  50. +0 −1 vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb
  51. +1 −0 vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb
  52. +23 −9 vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb
  53. +2 −9 vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb
  54. +53 −5 vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb
  55. +0 −62 vendor/plugins/rspec_on_rails/lib/spec/rails/example/ivar_proxy.rb
  56. +10 −3 vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb
  57. +1 −1 vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb
  58. +6 −1 vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
  59. +20 −5 vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb
  60. +0 −64 vendor/plugins/rspec_on_rails/spec/rails/example/ivar_proxy_spec.rb
  61. +12 −11 vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb
@@ -1,11 +1,4 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe RefundsHelper do
-
- #Delete this example and add some real ones or delete this file
- it "should include the RefundsHelper" do
- included_modules = self.metaclass.send :included_modules
- included_modules.should include(RefundsHelper)
- end
-
end
@@ -1,11 +1,4 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe VoidsHelper do
-
- #Delete this example and add some real ones or delete this file
- it "should include the VoidsHelper" do
- included_modules = self.metaclass.send :included_modules
- included_modules.should include(VoidsHelper)
- end
-
end
@@ -1,6 +1,31 @@
+== Version 1.1.4 (trunk)
+
+Maintenance release.
+Note: we've removed the metaclass method from Object. There were some generated specs that
+used it, and they will now break. Just replace the metaclass call with (class << self; self; end)
+and all will be well.
+
+* Added #helper and #assigns to helper specs.
+* Applied patch from Bryan Helmkamp to tweak format of generated spec.opts to be more obvious. Closes #162.
+* Tweaked list of exceptions (ignores) for autotest with rspec_on_rails.
+* Applied patch from Coda Hale to get the :red hook called in autotest. Closes #279.
+* Applied patch from Patrick Ritchie to support --drb in spec.opts. Closes #274, #293.
+* Applied patch from Rick Olson to get rspec_on_rails working with rails edge (>= 8862)
+* Moved metaclass method from Object to an internal module which gets included where it is needed.
+* Applied patch from Dayo Esho: and_yield clobbers return value from block. Closes #217.
+* Applied patch from Bob Cotton: ExampleGroupFactory.default resets previously registered types. Closes #222.
+* Applied patch from Mike Williams to support the lib directory in rails apps with the Textmate Alternate File command. Closes #276.
+* ExampleGroupMethods#xspecify aliases #xit
+* A SharedExampleGroup can be created within another ExampleGroup.
+* Applied patch from Bob Cotton: Nested ExampleGroups do not have a spec_path. Closes #224.
+* Applied patch from Wincent Colaiuta to invert sense of "spec --diff". Closes #281.
+* Allow any type of render in view specs. Closes #57.
+* Applied patch from Ian White to get rspec working with edge rails (8804). Closes #271.
+
== Version 1.1.3
Maintenance release.
+Notice to autotest users: you must also upgrade to ZenTest-3.9.0.
* Tightened up exceptions list in autotest/rails_spec. Closes #264.
* Applied patch from Ryan Davis for ZenTest-3.9.0 compatibility
@@ -18,6 +43,7 @@ Maintenance release.
== Version 1.1.2
Minor bug fixes/enhancements.
+Notice to autotest users: you must also upgrade to ZenTest-3.8.0.
* RSpec's Autotest subclasses compatible with ZenTest-3.8.0 (thanks to Ryan Davis for making it easier on Autotest subs).
* Applied patch from idl to add spec/lib to rake stats. Closes #226.
@@ -1,6 +0,0 @@
-# Used just for us to develop rspec with Autotest
-# We could symbolic link rspec/vendor/plugins/rspec => rspec/., but
-# this leads to a problem with subversion on windows. Autotest
-# uses Ruby's load path, which contains ".", so this is a workaround
-# (albeit, an unclean one)
-require File.dirname(__FILE__) + "/../lib/autotest/discover.rb"
@@ -1 +0,0 @@
-require File.dirname(__FILE__) + "/../lib/autotest/rspec.rb"
@@ -21,17 +21,15 @@ class Autotest::Rspec < Autotest
def initialize
super
-
self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m
- self.completed_re = /\Z/ # FIX: some sort of summary line at the end?
+ self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
end
-
+
def consolidate_failures(failed)
- filters = Hash.new { |h,k| h[k] = [] }
- failed.each do |spec, failed_trace|
- if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } then
- filters[f] << spec
- break
+ filters = new_hash_of_arrays
+ failed.each do |spec, trace|
+ if trace =~ /\n(\.\/)?(.*\.rb):[\d]+:\Z?/
+ filters[$2] << spec
end
end
return filters
@@ -41,7 +39,7 @@ def make_test_cmd(files_to_test)
return "#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
end
- def add_options_if_present
+ def add_options_if_present # :nodoc:
File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
end
@@ -23,7 +23,7 @@ def register(id, example_group_class)
def default(example_group_class)
old = @example_group_types
@example_group_types = Hash.new(example_group_class)
- @example_group_types.merge(old) if old
+ @example_group_types.merge!(old) if old
end
def get(id=nil)
@@ -36,12 +36,8 @@ def get(id=nil)
def create_example_group(*args, &block)
opts = Hash === args.last ? args.last : {}
- if opts[:shared]
- SharedExampleGroup.new(*args, &block)
- else
- superclass = determine_superclass(opts)
- superclass.describe(*args, &block)
- end
+ superclass = determine_superclass(opts)
+ superclass.describe(*args, &block)
end
protected
@@ -34,10 +34,17 @@ def inherited(klass)
# end
#
def describe(*args, &example_group_block)
+ args << {} unless Hash === args.last
if example_group_block
- self.subclass("Subclass") do
- describe(*args)
- module_eval(&example_group_block)
+ params = args.last
+ params[:spec_path] = eval("caller(0)[1]", example_group_block) unless params[:spec_path]
+ if params[:shared]
+ SharedExampleGroup.new(*args, &example_group_block)
+ else
+ self.subclass("Subclass") do
+ describe(*args)
+ module_eval(&example_group_block)
+ end
end
else
set_description(*args)
@@ -107,6 +114,7 @@ def it(description=nil, &implementation)
def xit(description=nil, opts={}, &block)
Kernel.warn("Example disabled: #{description}")
end
+ alias_method :xspecify, :xit
def run
examples = examples_to_run
@@ -63,6 +63,10 @@ def eval_each_fail_slow(procs) #:nodoc:
def description
@_defined_description || @_matcher_description || "NO NAME"
end
+
+ def __full_description
+ "#{self.class.description} #{self.description}"
+ end
def set_instance_variables_from_hash(ivars)
ivars.each do |variable_name, value|
@@ -17,7 +17,7 @@ def initialize(options)
end
# This is snagged from diff/lcs/ldiff.rb (which is a commandline tool)
- def diff_as_string(data_old, data_new)
+ def diff_as_string(data_new, data_old)
data_old = data_old.split(/\n/).map! { |e| e.chomp }
data_new = data_new.split(/\n/).map! { |e| e.chomp }
output = ""
@@ -1,3 +1,4 @@
require 'spec/extensions/object'
require 'spec/extensions/class'
require 'spec/extensions/main'
+require 'spec/extensions/metaclass'
@@ -0,0 +1,7 @@
+module Spec
+ module MetaClass
+ def metaclass
+ class << self; self; end
+ end
+ end
+end
@@ -3,8 +3,4 @@ def args_and_options(*args)
options = Hash === args.last ? args.pop : {}
return args, options
end
-
- def metaclass
- class << self; self; end
- end
end
@@ -112,12 +112,14 @@ def invoke_with_yield(block)
if block.nil?
@error_generator.raise_missing_block_error @args_to_yield
end
+ value = nil
@args_to_yield.each do |args_to_yield_this_time|
if block.arity > -1 && args_to_yield_this_time.length != block.arity
@error_generator.raise_wrong_arity_error args_to_yield_this_time, block.arity
end
- block.call(*args_to_yield_this_time)
+ value = block.call(*args_to_yield_this_time)
end
+ value
end
def invoke_consecutive_return_block(args, block)
@@ -88,15 +88,15 @@ def __add(sym)
end
def define_expected_method(sym)
- if target_responds_to?(sym) && !metaclass.method_defined?(munge(sym))
+ if target_responds_to?(sym) && !target_metaclass.method_defined?(munge(sym))
munged_sym = munge(sym)
- metaclass.instance_eval do
+ target_metaclass.instance_eval do
alias_method munged_sym, sym if method_defined?(sym.to_s)
end
@proxied_methods << sym
end
- metaclass_eval(<<-EOF, __FILE__, __LINE__)
+ target_metaclass.class_eval(<<-EOF, __FILE__, __LINE__)
def #{sym}(*args, &block)
__mock_proxy.message_received :#{sym}, *args, &block
end
@@ -125,12 +125,8 @@ def clear_proxied_methods
@proxied_methods.clear
end
- def metaclass_eval(str, filename, lineno)
- metaclass.class_eval(str, filename, lineno)
- end
-
- def metaclass
- (class << @target; self; end)
+ def target_metaclass
+ class << @target; self; end
end
def verify_expectations
@@ -142,7 +138,7 @@ def verify_expectations
def reset_proxied_methods
@proxied_methods.each do |sym|
munged_sym = munge(sym)
- metaclass.instance_eval do
+ target_metaclass.instance_eval do
if method_defined?(munged_sym.to_s)
alias_method sym, munged_sym
undef_method munged_sym
@@ -19,8 +19,7 @@ def start(example_count)
end
# This method is invoked at the beginning of the execution of each example_group.
- # +name+ is the name of the example_group and +first+ is true if it is the
- # first example_group - otherwise it's false.
+ # +example_group+ is the example_group.
#
# The next method to be invoked after this is #example_failed or #example_finished
def add_example_group(example_group)
@@ -46,7 +45,7 @@ def example_failed(example, counter, failure)
# been provided a block), or when an ExamplePendingError is raised.
# +message+ is the message from the ExamplePendingError, if it exists, or the
# default value of "Not Yet Implemented"
- def example_pending(example_group_description, example, message)
+ def example_pending(example, message)
end
# This method is invoked after all of the examples have executed. The next method
@@ -26,8 +26,8 @@ def @output.flush
@pending_examples = []
end
- def example_pending(example_group_description, example, message)
- @pending_examples << ["#{example_group_description} #{example.description}", message]
+ def example_pending(example, message)
+ @pending_examples << [example.__full_description, message]
end
def dump_failure(counter, failure)
@@ -4,19 +4,21 @@ module Spec
module Runner
module Formatter
class FailingExampleGroupsFormatter < BaseTextFormatter
+ attr_reader :example_group
def add_example_group(example_group)
super
- @example_group_description_parts = example_group.description_parts
+ @example_group = example_group
end
def example_failed(example, counter, failure)
- if @example_group_description_parts
- description_parts = @example_group_description_parts.collect do |description|
+ if @example_group
+ description_parts = @example_group.description_parts.collect do |description|
description =~ /(.*) \(druby.*\)$/ ? $1 : description
end
@output.puts ::Spec::Example::ExampleGroupMethods.description_text(*description_parts)
+
@output.flush
- @example_group_description_parts = nil
+ @example_group = nil
end
end
@@ -81,7 +81,7 @@ def example_failed(example, counter, failure)
@output.flush
end
- def example_pending(example_group_description, example, message)
+ def example_pending(example, message)
@output.puts " <script type=\"text/javascript\">makeYellow('rspec-header');</script>" unless @header_red
@output.puts " <script type=\"text/javascript\">makeYellow('example_group_#{current_example_group_number}');</script>" unless @example_group_red
move_progress
@@ -14,7 +14,7 @@ def example_passed(example)
@output.flush
end
- def example_pending(example_group_description, example, message)
+ def example_pending(example, message)
super
@output.print yellow('P')
@output.flush
@@ -28,7 +28,7 @@ def example_passed(example)
output.flush
end
- def example_pending(example_group_description, example, message)
+ def example_pending(example, message)
super
output.puts yellow("- #{example.description} (PENDING: #{message})")
output.flush
@@ -141,6 +141,10 @@ def invoke_requires(requires)
def parse_options_file(options_file)
option_file_args = IO.readlines(options_file).map {|l| l.chomp.split " "}.flatten
@argv.push(*option_file_args)
+ # TODO - this is a brute force solution to http://rspec.lighthouseapp.com/projects/5645/tickets/293.
+ # Let's look for a cleaner way. Might not be one. But let's look. If not, perhaps
+ # this can be moved to a different method to indicate the special handling for drb?
+ parse_drb(@argv)
end
def parse_generate_options
@@ -170,9 +174,9 @@ def write_generated_options(options_file)
@options.examples_should_not_be_run
end
- def parse_drb
+ def parse_drb(argv = nil)
+ argv ||= @options.argv # TODO - see note about about http://rspec.lighthouseapp.com/projects/5645/tickets/293
is_drb = false
- argv = @options.argv
is_drb ||= argv.delete(OPTIONS[:drb][0])
is_drb ||= argv.delete(OPTIONS[:drb][1])
return nil unless is_drb
@@ -177,9 +177,11 @@ def load_heckle_runner(heckle)
end
def number_of_examples
- @example_groups.inject(0) do |sum, example_group|
- sum + example_group.number_of_examples
+ total = 0
+ @example_groups.each do |example_group|
+ total += example_group.number_of_examples
end
+ total
end
def files_to_load
Oops, something went wrong.

0 comments on commit c96e8c2

Please sign in to comment.