# File lib/rspec/core/example_group.rb, line 270 def self.all_apply?(filters) metadata.all_apply?(filters) end
# File lib/rspec/core/example_group.rb, line 142 def self.ancestors @_ancestors ||= super().select {|a| a < RSpec::Core::ExampleGroup} end
# File lib/rspec/core/example_group.rb, line 216 def self.around_hooks @around_hooks ||= (world.find_hook(:around, :each, self) + ancestors.reverse.inject([]){|l,a| l + a.find_hook(:around, :each, self)}) end
# File lib/rspec/core/example_group.rb, line 166 def self.assign_before_all_ivars(ivars, example_group_instance) return if ivars.empty? ivars.each { |ivar, val| example_group_instance.instance_variable_set(ivar, val) } end
# File lib/rspec/core/example_group.rb, line 155 def self.before_all_ivars @before_all_ivars ||= {} end
# File lib/rspec/core/example_group.rb, line 134 def self.children @children ||= [] end
# File lib/rspec/core/example_group.rb, line 288 def self.clear_ivars(instance) instance.instance_variables.each { |ivar| instance.send(:remove_instance_variable, ivar) } end
# File lib/rspec/core/example_group.rb, line 292 def self.clear_memoized(instance) instance.__memoized.clear end
# File lib/rspec/core/example_group.rb, line 274 def self.declaration_line_numbers @declaration_line_numbers ||= [metadata[:example_group][:line_number]] + examples.collect {|e| e.metadata[:line_number]} + children.inject([]) {|l,c| l + c.declaration_line_numbers} end
# File lib/rspec/core/example_group.rb, line 41 def self.define_example_method(name, extra_options={}) module_eval( def self.#{name}(desc=nil, options={}, &block) options.update(:pending => true) unless block options.update(#{extra_options.inspect}) examples << RSpec::Core::Example.new(self, desc, options, block) examples.last end, __FILE__, __LINE__) end
# File lib/rspec/core/example_group.rb, line 28 def self.delegate_to_metadata(*names) names.each do |name| define_method name do metadata[:example_group][name] end end end
# File lib/rspec/core/example_group.rb, line 96 def self.descendant_filtered_examples @descendant_filtered_examples ||= filtered_examples + children.inject([]){|l,c| l + c.descendant_filtered_examples} end
# File lib/rspec/core/example_group.rb, line 138 def self.descendants @_descendants ||= [self] + children.inject([]) {|list, c| list + c.descendants} end
# File lib/rspec/core/example_group.rb, line 108 def self.describe(*args, &example_group_block) @_subclass_count ||= 0 @_subclass_count += 1 args << {} unless args.last.is_a?(Hash) args.last.update(:example_group_block => example_group_block) # TODO 2010-05-05: Because we don't know if const_set is thread-safe child = const_set( "Nested_#{@_subclass_count}", subclass(self, args, &example_group_block) ) children << child child end
# File lib/rspec/core/example_group.rb, line 196 def self.eval_after_alls(example_group_instance) return if descendant_filtered_examples.empty? assign_before_all_ivars(before_all_ivars, example_group_instance) begin run_hook!(:after, :all, example_group_instance) rescue => e # TODO: come up with a better solution for this. RSpec.configuration.reporter.message An error occurred in an after(:all) hook. #{e.class}: #{e.message} occurred at #{e.backtrace.first} end world.run_hook_filtered(:after, :all, self, example_group_instance) if top_level? end
# File lib/rspec/core/example_group.rb, line 191 def self.eval_after_eachs(example_group_instance) ancestors.each { |ancestor| ancestor.run_hook(:after, :each, example_group_instance) } world.run_hook_filtered(:after, :each, self, example_group_instance) end
# File lib/rspec/core/example_group.rb, line 179 def self.eval_around_eachs(example_group_instance, wrapped_example) around_hooks.reverse.inject(wrapped_example) do |wrapper, hook| def wrapper.run; call; end lambda { example_group_instance.instance_eval_with_args(wrapper, &hook) } end end
# File lib/rspec/core/example_group.rb, line 171 def self.eval_before_alls(example_group_instance) return if descendant_filtered_examples.empty? assign_before_all_ivars(superclass.before_all_ivars, example_group_instance) world.run_hook_filtered(:before, :all, self, example_group_instance) if top_level? run_hook!(:before, :all, example_group_instance) store_before_all_ivars(example_group_instance) end
# File lib/rspec/core/example_group.rb, line 186 def self.eval_before_eachs(example_group_instance) world.run_hook_filtered(:before, :each, self, example_group_instance) ancestors.reverse.each { |ancestor| ancestor.run_hook(:before, :each, example_group_instance) } end
# File lib/rspec/core/example_group.rb, line 88 def self.examples @examples ||= [] end
# File lib/rspec/core/example_group.rb, line 251 def self.fail_fast? RSpec.configuration.fail_fast? end
# File lib/rspec/core/example_group.rb, line 241 def self.fail_filtered_examples(exception, reporter) filtered_examples.each { |example| example.fail_fast(reporter, exception) } children.each do |child| reporter.example_group_started(child) child.fail_filtered_examples(exception, reporter) reporter.example_group_finished(child) end end
# File lib/rspec/core/example_group.rb, line 92 def self.filtered_examples world.filtered_examples[self] end
# File lib/rspec/core/example_group.rb, line 22 def self.inherited(klass) RSpec::Core::Runner.autorun world.example_groups << klass if klass.top_level? end
# File lib/rspec/core/example_group.rb, line 100 def self.metadata @metadata if defined?(@metadata) end
# File lib/rspec/core/example_group.rb, line 220 def self.run(reporter) if RSpec.wants_to_quit RSpec.clear_remaining_example_groups if top_level? return end example_group_instance = new reporter.example_group_started(self) begin eval_before_alls(example_group_instance) result_for_this_group = run_examples(example_group_instance, reporter) results_for_descendants = children.map {|child| child.run(reporter)}.all? result_for_this_group && results_for_descendants rescue Exception => ex fail_filtered_examples(ex, reporter) ensure eval_after_alls(example_group_instance) reporter.example_group_finished(self) end end
# File lib/rspec/core/example_group.rb, line 255 def self.run_examples(instance, reporter) filtered_examples.map do |example| next if RSpec.wants_to_quit begin set_ivars(instance, before_all_ivars) succeeded = example.run(instance, reporter) RSpec.wants_to_quit = true if fail_fast? && !succeeded succeeded ensure clear_ivars(instance) clear_memoized(instance) end end.all? end
# File lib/rspec/core/example_group.rb, line 150 def self.set_it_up(*args) @metadata = RSpec::Core::Metadata.new(superclass_metadata).process(*args) world.configure_group(self) end
# File lib/rspec/core/example_group.rb, line 284 def self.set_ivars(instance, ivars) ivars.each {|name, value| instance.instance_variable_set(name, value)} end
# File lib/rspec/core/example_group.rb, line 159 def self.store_before_all_ivars(example_group_instance) return if example_group_instance.instance_variables.empty? example_group_instance.instance_variables.each { |ivar| before_all_ivars[ivar] = example_group_instance.instance_variable_get(ivar) } end
# File lib/rspec/core/example_group.rb, line 127 def self.subclass(parent, args, &example_group_block) subclass = Class.new(parent) subclass.set_it_up(*args) subclass.module_eval(&example_group_block) if example_group_block subclass end
# File lib/rspec/core/example_group.rb, line 104 def self.superclass_metadata @superclass_metadata ||= self.superclass.respond_to?(:metadata) ? self.superclass.metadata : nil end
# File lib/rspec/core/example_group.rb, line 146 def self.top_level? @top_level ||= superclass == ExampleGroup end
# File lib/rspec/core/example_group.rb, line 296 def described_class self.class.described_class end
Generated with the Darkfish Rdoc Generator 2.