Class: Expectations::Expectation
- Includes:
- Mocha::API
- Defined in:
- lib/expectations/expectation.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
Returns the value of attribute actual.
-
#block ⇒ Object
Returns the value of attribute block.
-
#expected ⇒ Object
Returns the value of attribute expected.
-
#file ⇒ Object
Returns the value of attribute file.
-
#line ⇒ Object
Returns the value of attribute line.
Instance Method Summary collapse
-
#initialize(expected, file, line, &block) ⇒ Expectation
constructor
A new instance of Expectation.
- #mock(*args) ⇒ Object
- #warn_for_expects ⇒ Object
Constructor Details
#initialize(expected, file, line, &block) ⇒ Expectation
Returns a new instance of Expectation.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/expectations/expectation.rb', line 5 def initialize(expected, file, line, &block) self.expected = expected self.block = block self.file, self.line = file, line.to_i if expected.is_a?(Expectations::Recorder) extend(Expectations::RecordedExpectation) elsif !block extend(Expectations::RecordedExpectation) self.expected = Expectations::Recorder.new(self.expected) self.expected.extend(Expectations::StateBasedRecorder) self.expected.extend(Expectations::StateBasedRecorderForExpectationsWithoutBlock) self.expected.file = file self.expected.line = line else extend(Expectations::StateBasedExpectation) end end |
Instance Attribute Details
#actual ⇒ Object
Returns the value of attribute actual.
3 4 5 |
# File 'lib/expectations/expectation.rb', line 3 def actual @actual end |
#block ⇒ Object
Returns the value of attribute block.
3 4 5 |
# File 'lib/expectations/expectation.rb', line 3 def block @block end |
#expected ⇒ Object
Returns the value of attribute expected.
3 4 5 |
# File 'lib/expectations/expectation.rb', line 3 def expected @expected end |
#file ⇒ Object
Returns the value of attribute file.
3 4 5 |
# File 'lib/expectations/expectation.rb', line 3 def file @file end |
#line ⇒ Object
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
24 25 26 27 |
# File 'lib/expectations/expectation.rb', line 24 def mock(*args) Expectations::StandardError.print "mock method called from #{caller.first.chomp(":in `__instance_exec0'")}\n" super end |
#warn_for_expects ⇒ Object
29 30 31 32 33 34 |
# File 'lib/expectations/expectation.rb', line 29 def warn_for_expects Object.__which_expects__ = ExpectationsExpectsMethod yield ensure Object.__which_expects__ = MochaExpectsMethod end |