Module Spec::Example::ExampleGroupMethods

  1. lib/spec/example/example_group_methods.rb

Attributes

matcher_class [RW]
options [R]
spec_path [R]

Public instance methods

backtrace ()

Provides the backtrace up to where this example_group was declared.

[show source]
# File lib/spec/example/example_group_methods.rb, line 21
      def backtrace
        @backtrace
      end
context (*args, &example_group_block)

Alias for describe

describe (*args, &example_group_block)

Makes the describe/it syntax available from a class. For example:

class StackSpec < Spec::ExampleGroup
  describe Stack, "with no elements"

  before
    @stack = Stack.new
  end

  it "should raise on pop" do
    lambda{ @stack.pop }.should raise_error
  end
end
[show source]
# File lib/spec/example/example_group_methods.rb, line 49
      def describe(*args, &example_group_block)
        if example_group_block
          Spec::Example::add_spec_path_to(args)
          options = args.last
          if options[:shared]
            ExampleGroupFactory.create_shared_example_group(*args, &example_group_block)
          else
            subclass(*args, &example_group_block)
          end
        else
          set_description(*args)
        end
      end
described_class ()
[show source]
# File lib/spec/example/example_group_methods.rb, line 128
      def described_class
        @described_class ||= Class === described_type ? described_type : nil
      end
described_type ()
[show source]
# File lib/spec/example/example_group_methods.rb, line 124
      def described_type
        @described_type ||= description_parts.reverse.find {|part| part.is_a?(Module)}
      end
description ()
[show source]
# File lib/spec/example/example_group_methods.rb, line 120
      def description
        @description ||= build_description_from(*description_parts) || to_s
      end
description_args ()
[show source]
# File lib/spec/example/example_group_methods.rb, line 132
      def description_args
        @description_args ||= []
      end
example (description=nil, options={}, backtrace=nil, &implementation)

Creates an instance of the current example group class and adds it to a collection of examples of the current example group.

[show source]
# File lib/spec/example/example_group_methods.rb, line 73
      def example(description=nil, options={}, backtrace=nil, &implementation)
        example_description = ExampleDescription.new(description, options, backtrace || caller(0)[1])
        example_descriptions << example_description
        example_implementations[example_description] = implementation || pending_implementation
        example_description
      end
example_group_backtrace ()

Deprecated - use +backtrace()+

[show source]
# File lib/spec/example/example_group_methods.rb, line 26
      def example_group_backtrace
        Kernel.warn "ExampleGroupMethods#example_group_backtrace is deprecated and will be removed\nfrom a future version. Please use ExampleGroupMethods#backtrace instead.\n"
        backtrace
      end
example_group_hierarchy ()
[show source]
# File lib/spec/example/example_group_methods.rb, line 158
      def example_group_hierarchy
        @example_group_hierarchy ||= ExampleGroupHierarchy.new(self)
      end
filtered_description (filter)
[show source]
# File lib/spec/example/example_group_methods.rb, line 162
      def filtered_description(filter)
        build_description_from(
          *nested_descriptions.collect do |description|
            description =~ filter ? $1 : description
          end
        )
      end
include_constants_in (mod)
[show source]
# File lib/spec/example/example_group_methods.rb, line 174
      def include_constants_in(mod)
        include mod if (Spec::Ruby.version.to_f >= 1.9) & (Module === mod) & !(Class === mod)
      end
it (description=nil, options={}, backtrace=nil, &implementation)

Alias for example

it_should_behave_like (*shared_example_groups)

Use this to pull in examples from shared example groups.

[show source]
# File lib/spec/example/example_group_methods.rb, line 65
      def it_should_behave_like(*shared_example_groups)
        shared_example_groups.each do |group|
          include_shared_example_group(group)
        end
      end
nested_descriptions ()
[show source]
# File lib/spec/example/example_group_methods.rb, line 170
      def nested_descriptions
        example_group_hierarchy.nested_descriptions
      end
pending_implementation ()
[show source]
# File lib/spec/example/example_group_methods.rb, line 80
      def pending_implementation
        error = Spec::Example::NotYetImplementedError.new(caller)
        lambda { raise(error) }
      end
run (run_options)
[show source]
# File lib/spec/example/example_group_methods.rb, line 96
      def run(run_options)
        examples = examples_to_run(run_options)
        notify(run_options.reporter) unless examples.empty?
        return true if examples.empty?
        return dry_run(examples, run_options) if run_options.dry_run?

        define_methods_from_predicate_matchers

        success, before_all_instance_variables = run_before_all(run_options)
        success, after_all_instance_variables  = execute_examples(success, before_all_instance_variables, examples, run_options)
        success                                = run_after_all(success, after_all_instance_variables, run_options)
      end
set_description (*args)
[show source]
# File lib/spec/example/example_group_methods.rb, line 109
      def set_description(*args)
        @description_args, @options = Spec::Example.args_and_options(*args)
        @backtrace = caller(1)
        @spec_path = File.expand_path(options[:spec_path]) if options[:spec_path]
        self
      end
specify (description=nil, options={}, backtrace=nil, &implementation)

Alias for example

xexample (description=nil, opts={}, &block)

Use this to temporarily disable an example.

[show source]
# File lib/spec/example/example_group_methods.rb, line 89
      def xexample(description=nil, opts={}, &block)
        Kernel.warn("Example disabled: #{description}")
      end
xit (description=nil, opts={}, &block)

Alias for xexample

xspecify (description=nil, opts={}, &block)

Alias for xexample