public
Description: RESTful Rails app for storing credit cards
Clone URL: git://github.com/joevandyk/monkeycharger.git
Upgraded to rspec trunk
joevandyk (author)
Wed Feb 20 17:36:40 -0800 2008
commit  c96e8c2ee76e873c22782b97d6057a45f2e5b71e
tree    c7435d6ec186543259d687a440420ea4bfbf62a5
parent  782f18ed6025af596d71049bbd2b08c8ac8e443f
...
1
2
3
4
5
6
7
8
9
10
11
...
1
2
3
 
 
 
 
 
 
 
4
0
@@ -1,11 +1,4 @@
0
 require File.dirname(__FILE__) + '/../spec_helper'
0
 
0
 describe RefundsHelper do
0
-
0
- #Delete this example and add some real ones or delete this file
0
- it "should include the RefundsHelper" do
0
- included_modules = self.metaclass.send :included_modules
0
- included_modules.should include(RefundsHelper)
0
- end
0
-
0
 end
...
1
2
3
4
5
6
7
8
9
10
11
...
1
2
3
 
 
 
 
 
 
 
4
0
@@ -1,11 +1,4 @@
0
 require File.dirname(__FILE__) + '/../spec_helper'
0
 
0
 describe VoidsHelper do
0
-
0
- #Delete this example and add some real ones or delete this file
0
- it "should include the VoidsHelper" do
0
- included_modules = self.metaclass.send :included_modules
0
- included_modules.should include(VoidsHelper)
0
- end
0
-
0
 end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
 
4
5
6
...
18
19
20
 
21
22
23
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
...
43
44
45
46
47
48
49
0
@@ -1,6 +1,31 @@
0
+== Version 1.1.4 (trunk)
0
+
0
+Maintenance release.
0
+Note: we've removed the metaclass method from Object. There were some generated specs that
0
+used it, and they will now break. Just replace the metaclass call with (class << self; self; end)
0
+and all will be well.
0
+
0
+* Added #helper and #assigns to helper specs.
0
+* Applied patch from Bryan Helmkamp to tweak format of generated spec.opts to be more obvious. Closes #162.
0
+* Tweaked list of exceptions (ignores) for autotest with rspec_on_rails.
0
+* Applied patch from Coda Hale to get the :red hook called in autotest. Closes #279.
0
+* Applied patch from Patrick Ritchie to support --drb in spec.opts. Closes #274, #293.
0
+* Applied patch from Rick Olson to get rspec_on_rails working with rails edge (>= 8862)
0
+* Moved metaclass method from Object to an internal module which gets included where it is needed.
0
+* Applied patch from Dayo Esho: and_yield clobbers return value from block. Closes #217.
0
+* Applied patch from Bob Cotton: ExampleGroupFactory.default resets previously registered types. Closes #222.
0
+* Applied patch from Mike Williams to support the lib directory in rails apps with the Textmate Alternate File command. Closes #276.
0
+* ExampleGroupMethods#xspecify aliases #xit
0
+* A SharedExampleGroup can be created within another ExampleGroup.
0
+* Applied patch from Bob Cotton: Nested ExampleGroups do not have a spec_path. Closes #224.
0
+* Applied patch from Wincent Colaiuta to invert sense of "spec --diff". Closes #281.
0
+* Allow any type of render in view specs. Closes #57.
0
+* Applied patch from Ian White to get rspec working with edge rails (8804). Closes #271.
0
+
0
 == Version 1.1.3
0
 
0
 Maintenance release.
0
+Notice to autotest users: you must also upgrade to ZenTest-3.9.0.
0
 
0
 * Tightened up exceptions list in autotest/rails_spec. Closes #264.
0
 * Applied patch from Ryan Davis for ZenTest-3.9.0 compatibility
0
@@ -18,6 +43,7 @@ Maintenance release.
0
 == Version 1.1.2
0
 
0
 Minor bug fixes/enhancements.
0
+Notice to autotest users: you must also upgrade to ZenTest-3.8.0.
0
 
0
 * RSpec's Autotest subclasses compatible with ZenTest-3.8.0 (thanks to Ryan Davis for making it easier on Autotest subs).
0
 * Applied patch from idl to add spec/lib to rake stats. Closes #226.
...
21
22
23
24
25
26
 
27
28
 
29
30
31
32
33
34
 
 
 
 
35
36
37
...
41
42
43
44
 
45
46
47
...
21
22
23
 
24
 
25
26
 
27
28
 
 
 
 
 
29
30
31
32
33
34
35
...
39
40
41
 
42
43
44
45
0
@@ -21,17 +21,15 @@ class Autotest::Rspec < Autotest
0
 
0
   def initialize
0
     super
0
-
0
     self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m
0
- self.completed_re = /\Z/ # FIX: some sort of summary line at the end?
0
+ self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
0
   end
0
-
0
+
0
   def consolidate_failures(failed)
0
- filters = Hash.new { |h,k| h[k] = [] }
0
- failed.each do |spec, failed_trace|
0
- if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } then
0
- filters[f] << spec
0
- break
0
+ filters = new_hash_of_arrays
0
+ failed.each do |spec, trace|
0
+ if trace =~ /\n(\.\/)?(.*\.rb):[\d]+:\Z?/
0
+ filters[$2] << spec
0
       end
0
     end
0
     return filters
0
@@ -41,7 +39,7 @@ class Autotest::Rspec < Autotest
0
     return "#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
0
   end
0
   
0
- def add_options_if_present
0
+ def add_options_if_present # :nodoc:
0
     File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
0
   end
0
 
...
23
24
25
26
 
27
28
29
...
36
37
38
39
40
41
42
43
44
 
 
45
46
47
...
23
24
25
 
26
27
28
29
...
36
37
38
 
 
 
 
 
 
39
40
41
42
43
0
@@ -23,7 +23,7 @@ module Spec
0
         def default(example_group_class)
0
           old = @example_group_types
0
           @example_group_types = Hash.new(example_group_class)
0
- @example_group_types.merge(old) if old
0
+ @example_group_types.merge!(old) if old
0
         end
0
 
0
         def get(id=nil)
0
@@ -36,12 +36,8 @@ module Spec
0
         
0
         def create_example_group(*args, &block)
0
           opts = Hash === args.last ? args.last : {}
0
- if opts[:shared]
0
- SharedExampleGroup.new(*args, &block)
0
- else
0
- superclass = determine_superclass(opts)
0
- superclass.describe(*args, &block)
0
- end
0
+ superclass = determine_superclass(opts)
0
+ superclass.describe(*args, &block)
0
         end
0
 
0
         protected
...
34
35
36
 
37
38
39
40
 
 
 
 
 
 
 
 
 
41
42
43
...
107
108
109
 
110
111
112
...
34
35
36
37
38
 
 
 
39
40
41
42
43
44
45
46
47
48
49
50
...
114
115
116
117
118
119
120
0
@@ -34,10 +34,17 @@ module Spec
0
       # end
0
       #
0
       def describe(*args, &example_group_block)
0
+ args << {} unless Hash === args.last
0
         if example_group_block
0
- self.subclass("Subclass") do
0
- describe(*args)
0
- module_eval(&example_group_block)
0
+ params = args.last
0
+ params[:spec_path] = eval("caller(0)[1]", example_group_block) unless params[:spec_path]
0
+ if params[:shared]
0
+ SharedExampleGroup.new(*args, &example_group_block)
0
+ else
0
+ self.subclass("Subclass") do
0
+ describe(*args)
0
+ module_eval(&example_group_block)
0
+ end
0
           end
0
         else
0
           set_description(*args)
0
@@ -107,6 +114,7 @@ module Spec
0
       def xit(description=nil, opts={}, &block)
0
         Kernel.warn("Example disabled: #{description}")
0
       end
0
+ alias_method :xspecify, :xit
0
 
0
       def run
0
         examples = examples_to_run
...
63
64
65
 
 
 
 
66
67
68
...
63
64
65
66
67
68
69
70
71
72
0
@@ -63,6 +63,10 @@ module Spec
0
       def description
0
         @_defined_description || @_matcher_description || "NO NAME"
0
       end
0
+
0
+ def __full_description
0
+ "#{self.class.description} #{self.description}"
0
+ end
0
       
0
       def set_instance_variables_from_hash(ivars)
0
         ivars.each do |variable_name, value|
...
17
18
19
20
 
21
22
23
...
17
18
19
 
20
21
22
23
0
@@ -17,7 +17,7 @@ module Spec
0
         end
0
 
0
         # This is snagged from diff/lcs/ldiff.rb (which is a commandline tool)
0
- def diff_as_string(data_old, data_new)
0
+ def diff_as_string(data_new, data_old)
0
           data_old = data_old.split(/\n/).map! { |e| e.chomp }
0
           data_new = data_new.split(/\n/).map! { |e| e.chomp }
0
           output = ""
...
1
2
3
 
...
1
2
3
4
0
@@ -1,3 +1,4 @@
0
 require 'spec/extensions/object'
0
 require 'spec/extensions/class'
0
 require 'spec/extensions/main'
0
+require 'spec/extensions/metaclass'
...
3
4
5
6
7
8
9
10
...
3
4
5
 
 
 
 
6
0
@@ -3,8 +3,4 @@ class Object
0
     options = Hash === args.last ? args.pop : {}
0
     return args, options
0
   end
0
-
0
- def metaclass
0
- class << self; self; end
0
- end
0
 end
...
112
113
114
 
115
116
117
118
119
 
120
 
121
122
123
...
112
113
114
115
116
117
118
119
 
120
121
122
123
124
125
0
@@ -112,12 +112,14 @@ module Spec
0
         if block.nil?
0
           @error_generator.raise_missing_block_error @args_to_yield
0
         end
0
+ value = nil
0
         @args_to_yield.each do |args_to_yield_this_time|
0
           if block.arity > -1 && args_to_yield_this_time.length != block.arity
0
             @error_generator.raise_wrong_arity_error args_to_yield_this_time, block.arity
0
           end
0
- block.call(*args_to_yield_this_time)
0
+ value = block.call(*args_to_yield_this_time)
0
         end
0
+ value
0
       end
0
       
0
       def invoke_consecutive_return_block(args, block)
...
88
89
90
91
 
92
93
 
94
95
96
97
98
99
 
100
101
102
...
125
126
127
128
129
130
131
132
133
 
 
134
135
136
...
142
143
144
145
 
146
147
148
...
88
89
90
 
91
92
 
93
94
95
96
97
98
 
99
100
101
102
...
125
126
127
 
 
 
 
 
 
128
129
130
131
132
...
138
139
140
 
141
142
143
144
0
@@ -88,15 +88,15 @@ module Spec
0
       end
0
       
0
       def define_expected_method(sym)
0
- if target_responds_to?(sym) && !metaclass.method_defined?(munge(sym))
0
+ if target_responds_to?(sym) && !target_metaclass.method_defined?(munge(sym))
0
           munged_sym = munge(sym)
0
- metaclass.instance_eval do
0
+ target_metaclass.instance_eval do
0
             alias_method munged_sym, sym if method_defined?(sym.to_s)
0
           end
0
           @proxied_methods << sym
0
         end
0
         
0
- metaclass_eval(<<-EOF, __FILE__, __LINE__)
0
+ target_metaclass.class_eval(<<-EOF, __FILE__, __LINE__)
0
           def #{sym}(*args, &block)
0
             __mock_proxy.message_received :#{sym}, *args, &block
0
           end
0
@@ -125,12 +125,8 @@ module Spec
0
         @proxied_methods.clear
0
       end
0
 
0
- def metaclass_eval(str, filename, lineno)
0
- metaclass.class_eval(str, filename, lineno)
0
- end
0
-
0
- def metaclass
0
- (class << @target; self; end)
0
+ def target_metaclass
0
+ class << @target; self; end
0
       end
0
 
0
       def verify_expectations
0
@@ -142,7 +138,7 @@ module Spec
0
       def reset_proxied_methods
0
         @proxied_methods.each do |sym|
0
           munged_sym = munge(sym)
0
- metaclass.instance_eval do
0
+ target_metaclass.instance_eval do
0
             if method_defined?(munged_sym.to_s)
0
               alias_method sym, munged_sym
0
               undef_method munged_sym
...
19
20
21
22
23
 
24
25
26
...
46
47
48
49
 
50
51
52
...
19
20
21
 
 
22
23
24
25
...
45
46
47
 
48
49
50
51
0
@@ -19,8 +19,7 @@ module Spec
0
         end
0
 
0
         # This method is invoked at the beginning of the execution of each example_group.
0
- # +name+ is the name of the example_group and +first+ is true if it is the
0
- # first example_group - otherwise it's false.
0
+ # +example_group+ is the example_group.
0
         #
0
         # The next method to be invoked after this is #example_failed or #example_finished
0
         def add_example_group(example_group)
0
@@ -46,7 +45,7 @@ module Spec
0
         # been provided a block), or when an ExamplePendingError is raised.
0
         # +message+ is the message from the ExamplePendingError, if it exists, or the
0
         # default value of "Not Yet Implemented"
0
- def example_pending(example_group_description, example, message)
0
+ def example_pending(example, message)
0
         end
0
 
0
         # This method is invoked after all of the examples have executed. The next method
...
26
27
28
29
30
 
 
31
32
33
...
26
27
28
 
 
29
30
31
32
33
0
@@ -26,8 +26,8 @@ module Spec
0
           @pending_examples = []
0
         end
0
         
0
- def example_pending(example_group_description, example, message)
0
- @pending_examples << ["#{example_group_description} #{example.description}", message]
0
+ def example_pending(example, message)
0
+ @pending_examples << [example.__full_description, message]
0
         end
0
         
0
         def dump_failure(counter, failure)
...
4
5
6
 
7
8
9
 
10
11
12
13
14
 
 
15
16
17
 
18
19
 
20
21
22
...
4
5
6
7
8
9
 
10
11
12
13
 
 
14
15
16
17
18
19
20
 
21
22
23
24
0
@@ -4,19 +4,21 @@ module Spec
0
   module Runner
0
     module Formatter
0
       class FailingExampleGroupsFormatter < BaseTextFormatter
0
+ attr_reader :example_group
0
         def add_example_group(example_group)
0
           super
0
- @example_group_description_parts = example_group.description_parts
0
+ @example_group = example_group
0
         end
0
 
0
         def example_failed(example, counter, failure)
0
- if @example_group_description_parts
0
- description_parts = @example_group_description_parts.collect do |description|
0
+ if @example_group
0
+ description_parts = @example_group.description_parts.collect do |description|
0
               description =~ /(.*) \(druby.*\)$/ ? $1 : description
0
             end
0
             @output.puts ::Spec::Example::ExampleGroupMethods.description_text(*description_parts)
0
+
0
             @output.flush
0
- @example_group_description_parts = nil
0
+ @example_group = nil
0
           end
0
         end
0
 
...
81
82
83
84
 
85
86
87
...
81
82
83
 
84
85
86
87
0
@@ -81,7 +81,7 @@ module Spec
0
           @output.flush
0
         end
0
 
0
- def example_pending(example_group_description, example, message)
0
+ def example_pending(example, message)
0
           @output.puts " <script type=\"text/javascript\">makeYellow('rspec-header');</script>" unless @header_red
0
           @output.puts " <script type=\"text/javascript\">makeYellow('example_group_#{current_example_group_number}');</script>" unless @example_group_red
0
           move_progress
...
14
15
16
17
 
18
19
20
...
14
15
16
 
17
18
19
20
0
@@ -14,7 +14,7 @@ module Spec
0
           @output.flush
0
         end
0
       
0
- def example_pending(example_group_description, example, message)
0
+ def example_pending(example, message)
0
           super
0
           @output.print yellow('P')
0
           @output.flush
...
28
29
30
31
 
32
33
34
...
28
29
30
 
31
32
33
34
0
@@ -28,7 +28,7 @@ module Spec
0
           output.flush
0
         end
0
         
0
- def example_pending(example_group_description, example, message)
0
+ def example_pending(example, message)
0
           super
0
           output.puts yellow("- #{example.description} (PENDING: #{message})")
0
           output.flush
...
141
142
143
 
 
 
 
144
145
146
...
170
171
172
173
 
 
174
175
176
177
178
...
141
142
143
144
145
146
147
148
149
150
...
174
175
176
 
177
178
179
 
180
181
182
0
@@ -141,6 +141,10 @@ module Spec
0
       def parse_options_file(options_file)
0
         option_file_args = IO.readlines(options_file).map {|l| l.chomp.split " "}.flatten
0
         @argv.push(*option_file_args)
0
+ # TODO - this is a brute force solution to http://rspec.lighthouseapp.com/projects/5645/tickets/293.
0
+ # Let's look for a cleaner way. Might not be one. But let's look. If not, perhaps
0
+ # this can be moved to a different method to indicate the special handling for drb?
0
+ parse_drb(@argv)
0
       end
0
 
0
       def parse_generate_options
0
@@ -170,9 +174,9 @@ module Spec
0
         @options.examples_should_not_be_run
0
       end
0
 
0
- def parse_drb
0
+ def parse_drb(argv = nil)
0
+ argv ||= @options.argv # TODO - see note about about http://rspec.lighthouseapp.com/projects/5645/tickets/293
0
         is_drb = false
0
- argv = @options.argv
0
         is_drb ||= argv.delete(OPTIONS[:drb][0])
0
         is_drb ||= argv.delete(OPTIONS[:drb][1])
0
         return nil unless is_drb
...
177
178
179
180
181
 
 
 
182
 
183
184
185
...
177
178
179
 
 
180
181
182
183
184
185
186
187
0
@@ -177,9 +177,11 @@ module Spec
0
       end
0
 
0
       def number_of_examples
0
- @example_groups.inject(0) do |sum, example_group|
0
- sum + example_group.number_of_examples
0
+ total = 0
0
+ @example_groups.each do |example_group|
0
+ total += example_group.number_of_examples
0
         end
0
+ total
0
       end
0
 
0
       def files_to_load
...
26
27
28
29
 
30
31
32
...
34
35
36
37
38
 
39
40
41
...
91
92
93
 
94
95
96
...
104
105
106
107
 
108
109
110
 
111
112
113
114
115
 
116
117
118
 
 
119
120
121
122
123
124
 
125
126
 
127
128
 
129
130
131
...
137
138
139
 
 
 
 
140
141
142
...
26
27
28
 
29
30
31
32
...
34
35
36
 
 
37
38
39
40
...
90
91
92
93
94
95
96
...
104
105
106
 
107
108
109
 
110
111
112
113
114
 
115
116
 
 
117
118
119
120
121
122
123
 
124
125
 
126
127
 
128
129
130
131
...
137
138
139
140
141
142
143
144
145
146
0
@@ -26,7 +26,7 @@ module Spec
0
         if error.nil?
0
           example_passed(example)
0
         elsif Spec::Example::ExamplePendingError === error
0
- example_pending(example_groups.last, example, error.message)
0
+ example_pending(example, error.message)
0
         else
0
           example_failed(example, error)
0
         end
0
@@ -34,8 +34,7 @@ module Spec
0
 
0
       def failure(example, error)
0
         backtrace_tweaker.tweak_backtrace(error)
0
- example_name = "#{example_groups.last.description} #{example.description}"
0
- failure = Failure.new(example_name, error)
0
+ failure = Failure.new(example, error)
0
         @failures << failure
0
         formatters.each do |f|
0
           f.example_failed(example, @failures.length, failure)
0
@@ -91,6 +90,7 @@ module Spec
0
           index + 1
0
         end
0
       end
0
+
0
       def dump_pending
0
         formatters.each{|f| f.dump_pending}
0
       end
0
@@ -104,28 +104,28 @@ module Spec
0
         formatters.each{|f| f.example_passed(example)}
0
       end
0
       
0
- def example_pending(example_group, example, message="Not Yet Implemented")
0
+ def example_pending(example, message="Not Yet Implemented")
0
         @pending_count += 1
0
         formatters.each do |f|
0
- f.example_pending(example_group.description, example, message)
0
+ f.example_pending(example, message)
0
         end
0
       end
0
       
0
       class Failure
0
- attr_reader :exception
0
+ attr_reader :example, :exception
0
         
0
- def initialize(example_name, exception)
0
- @example_name = example_name
0
+ def initialize(example, exception)
0
+ @example = example
0
           @exception = exception
0
         end
0
 
0
         def header
0
           if expectation_not_met?
0
- "'#{@example_name}' FAILED"
0
+ "'#{example_name}' FAILED"
0
           elsif pending_fixed?
0
- "'#{@example_name}' FIXED"
0
+ "'#{example_name}' FIXED"
0
           else
0
- "#{@exception.class.name} in '#{@example_name}'"
0
+ "#{@exception.class.name} in '#{example_name}'"
0
           end
0
         end
0
         
0
@@ -137,6 +137,10 @@ module Spec
0
           @exception.is_a?(Spec::Expectations::ExpectationNotMetError)
0
         end
0
 
0
+ protected
0
+ def example_name
0
+ @example.__full_description
0
+ end
0
       end
0
     end
0
   end
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ module Spec
0
       TINY = 3
0
       RELEASE_CANDIDATE = nil
0
 
0
- BUILD_TIME_UTC = 20080131122909
0
+ BUILD_TIME_UTC = 20080218031844
0
 
0
       STRING = [MAJOR, MINOR, TINY].join('.')
0
       TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')