Class: Lookout::Expectations
Defined Under Namespace
Instance Method Summary collapse
- #arg ⇒ Object
- #expect(expected, &block) ⇒ Object
-
#flush ⇒ Object
TODO: It would be great if this method wasn’t necessary.
-
#initialize(results = Lookout::Results::Unsuccessful.new, line = nil) ⇒ Expectations
constructor
A new instance of Expectations.
- #mock ⇒ Object
- #output(string) ⇒ Object
- #stub ⇒ Object
- #warning(string) ⇒ Object
- #without_arguments ⇒ Object
- #xml(string) ⇒ Object
Constructor Details
#initialize(results = Lookout::Results::Unsuccessful.new, line = nil) ⇒ Expectations
Returns a new instance of Expectations.
7 8 9 10 |
# File 'lib/lookout/expectations.rb', line 7 def initialize(results = Lookout::Results::Unsuccessful.new, line = nil) @results, @line = results, line @previous = nil end |
Instance Method Details
#arg ⇒ Object
16 17 18 |
# File 'lib/lookout/expectations.rb', line 16 def arg Lookout::Mock::Method::Arguments::Anything.new end |
#expect(expected, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/lookout/expectations.rb', line 40 def expect(expected, &block) file, line = /\A(.*):(\d+)(?::in .*)?\z/.match(caller.first)[1..2] expectation = Lookout::Expectation.on(expected, file, line, &block) if @line if @previous and @previous.line <= @line and expectation.line > @line @results << @previous.evaluate @previous = nil else @previous = expectation end else @results << expectation.evaluate end self end |
#flush ⇒ Object
TODO: It would be great if this method wasn’t necessary.
57 58 59 60 |
# File 'lib/lookout/expectations.rb', line 57 def flush @results << @previous.evaluate if @previous self end |
#mock ⇒ Object
12 13 14 |
# File 'lib/lookout/expectations.rb', line 12 def mock Lookout::Mock::Object.new end |
#output(string) ⇒ Object
28 29 30 |
# File 'lib/lookout/expectations.rb', line 28 def output(string) Lookout::Output.new(string) end |
#stub ⇒ Object
24 25 26 |
# File 'lib/lookout/expectations.rb', line 24 def stub Lookout::Stub::Object.new end |
#warning(string) ⇒ Object
32 33 34 |
# File 'lib/lookout/expectations.rb', line 32 def warning(string) Lookout::Warning.new(string) end |