Module Spec::Example::ExampleMethods

  1. lib/spec/example/example_methods.rb

Methods

public class

  1. new

public instance

  1. description
  2. expect
  3. run_after_each
  4. run_before_each
  5. violated

Classes and Modules

Module Spec::Example::ExampleMethods::BlockAliases

Public class methods

new (example_proxy, &implementation)
[show source]
# File lib/spec/example/example_methods.rb, line 111
      def initialize(example_proxy, &implementation)
        @_proxy = example_proxy
        @_implementation = implementation
        @_backtrace = caller
      end

Public instance methods

description ()

Declared description for this example:

describe Account do
  it "should start with a balance of 0" do
  ...

description
=> "should start with a balance of 0"
[show source]
# File lib/spec/example/example_methods.rb, line 20
      def description
        if description = @_proxy.description || ::Spec::Matchers.generated_description
          description
        else
          Spec.warn Spec::Example::NoDescriptionError.message("example", @_proxy.location)
        end
      end
expect (&block)

Extends the submitted block with aliases to and to_not for should and should_not. Allows expectations like this:

expect { this_block }.to change{this.expression}.from(old_value).to(new_value)
expect { this_block }.to raise_error
[show source]
# File lib/spec/example/example_methods.rb, line 65
      def expect(&block)
        block.extend BlockAliases
      end
run_after_each ()

Run all the after(:each) blocks for this example

[show source]
# File lib/spec/example/example_methods.rb, line 107
      def run_after_each
        example_group_hierarchy.run_after_each(self)
      end
run_before_each ()

Run all the before(:each) blocks for this example

[show source]
# File lib/spec/example/example_methods.rb, line 102
      def run_before_each
        example_group_hierarchy.run_before_each(self)
      end
violated (message="")
[show source]
# File lib/spec/example/example_methods.rb, line 8
      def violated(message="")
        raise Spec::Expectations::ExpectationNotMetError.new(message)
      end