Class: Expectations::Expectation

Inherits:
Object
  • Object
show all
Includes:
Mocha::Standalone
Defined in:
lib/expectations/expectation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected, file, line, &block) ⇒ Expectation

Returns a new instance of Expectation.



5
6
7
8
9
10
11
12
# File 'lib/expectations/expectation.rb', line 5

def initialize(expected, file, line, &block)
  self.expected, self.block = expected, block
  self.file, self.line = file, line.to_i
  case
    when expected.is_a?(Expectations::Recorder) then extend(Expectations::RecordedExpectation)
    else extend(Expectations::StateBasedExpectation)
  end
end

Instance Attribute Details

#actualObject

Returns the value of attribute actual.



3
4
5
# File 'lib/expectations/expectation.rb', line 3

def actual
  @actual
end

#blockObject

Returns the value of attribute block.



3
4
5
# File 'lib/expectations/expectation.rb', line 3

def block
  @block
end

#expectedObject

Returns the value of attribute expected.



3
4
5
# File 'lib/expectations/expectation.rb', line 3

def expected
  @expected
end

#fileObject

Returns the value of attribute file.



3
4
5
# File 'lib/expectations/expectation.rb', line 3

def file
  @file
end

#lineObject

Returns the value of attribute line.



3
4
5
# File 'lib/expectations/expectation.rb', line 3

def line
  @line
end

Instance Method Details

#mock(*args) ⇒ Object



14
15
16
17
# File 'lib/expectations/expectation.rb', line 14

def mock(*args)
  Expectations::StandardError.print "mock method called from #{caller.first.chomp(":in `__instance_exec0'")}\n"
  super
end

#warn_for_expectsObject



19
20
21
22
23
24
# File 'lib/expectations/expectation.rb', line 19

def warn_for_expects
  Object.__which_expects__ = ExpectationsExpectsMethod
  yield
ensure
  Object.__which_expects__ = MochaExpectsMethod
end