Sha256: b254c948fcf14ad00e002727ffd11a449494010f46b8bafc85038bbdcb22877a

Contents?: true

Size: 1.52 KB

Versions: 34

Compression:

Stored size: 1.52 KB

Contents

module Spec
  module Example
    class ExampleGroupHierarchy < Array
      def initialize(example_group_class)
        push example_group_class
        if example_group_class.respond_to?(:superclass) && example_group_class.superclass.respond_to?(:example_group_hierarchy)
          unshift example_group_class.superclass.example_group_hierarchy
          flatten!
        end
      end

      def run_before_all(example)
        example.eval_each_fail_fast(before_all_parts)
      end

      def run_before_each(example)
        example.eval_each_fail_fast(before_each_parts)
      end

      def run_after_each(example)
        example.eval_each_fail_slow(after_each_parts)
      end

      def run_after_all(example)
        example.eval_each_fail_slow(after_all_parts)
      end

      def before_all_parts
        @before_all_parts ||= collect {|klass| klass.before_all_parts}.flatten
      end

      def before_each_parts
        @before_each_parts ||= collect {|klass| klass.before_each_parts}.flatten
      end

      def after_each_parts
        @after_each_parts ||= reverse.collect {|klass| klass.after_each_parts}.flatten
      end

      def after_all_parts
        @after_all_parts ||= reverse.collect {|klass| klass.after_all_parts}.flatten
      end

      def nested_descriptions
        @nested_descriptions ||= collect {|eg| nested_description_from(eg) == "" ? nil : nested_description_from(eg) }.compact
      end

      def nested_description_from(example_group)
        example_group.description_args.join
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 11 rubygems

Version Path
rspec-instructure-1.3.3 lib/spec/example/example_group_hierarchy.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/lib/spec/example/example_group_hierarchy.rb
rspec-1.3.2 lib/spec/example/example_group_hierarchy.rb
rspec-1.3.1 lib/spec/example/example_group_hierarchy.rb
rspec-1.3.1.rc lib/spec/example/example_group_hierarchy.rb
rspec-1.3.0 lib/spec/example/example_group_hierarchy.rb
hubbub-0.0.11 lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb
hubbub-0.0.10 lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb
hubbub-0.0.9 lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb
hubbub-0.0.8 lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb
hubbub-0.0.6 lib/vendor/plugins/rspec/lib/spec/example/example_group_hierarchy.rb
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/lib/spec/example/example_group_hierarchy.rb
media-path-0.1.2 vendor/rspec/lib/spec/example/example_group_hierarchy.rb
simple-templater-0.0.1.3 vendor/rspec/lib/spec/example/example_group_hierarchy.rb
pupu-0.0.2.pre vendor/rspec/lib/spec/example/example_group_hierarchy.rb
media-path-0.1.1.pre vendor/rspec/lib/spec/example/example_group_hierarchy.rb
simple-templater-0.0.1.2 vendor/rspec/lib/spec/example/example_group_hierarchy.rb
media-path-0.1.1 vendor/rspec/lib/spec/example/example_group_hierarchy.rb
simple-templater-0.0.1.1 vendor/rspec/lib/spec/example/example_group_hierarchy.rb
pupu-0.0.2 vendor/rspec/lib/spec/example/example_group_hierarchy.rb