Module: RSpec::ExpectationHelper::It

Includes:
Shared
Defined in:
lib/r_spec/expectation_helper/it.rb

Overview

Dsl.it‘s expectation helper module.

Instance Method Summary collapse

Instance Method Details

#expect(value = self.class.superclass, &block) ⇒ Block, Value

Create an expectation for a spec.

Examples:

expect("foo") # => #<RSpec::ExpectationTarget::Value:0x00007fb6b82311a0 @actual="foo">
expect { Boom } # => #<RSpec::ExpectationTarget::Block:0x00007fb6b8263df8 @callable=#<Proc:0x00007fb6b8263e20>>

Parameters:

  • value (#object_id, nil) (defaults to: self.class.superclass)

    An actual value.

  • block (#call, nil)

    A code to evaluate.

Returns:

  • (Block, Value)

    The wrapped target of an expectation.



24
25
26
# File 'lib/r_spec/expectation_helper/it.rb', line 24

def expect(value = self.class.superclass, &block)
  ExpectationTarget.call(self.class.superclass, value, block)
end

#is_expectedBlock

Wraps the target of an expectation with the subject as actual value.

Examples:

is_expected # => #<RSpec::ExpectationTarget::Block:0x00007fb6b8263df8 @callable=#<Proc:0x00007fb6b8263e20>>

Returns:

  • (Block)

    The wrapped target of an expectation.



36
37
38
# File 'lib/r_spec/expectation_helper/it.rb', line 36

def is_expected
  expect { subject }
end