Module: Caliph::CommandLineExampleGroup
- Includes:
- CommandLineDSL
- Defined in:
- lib/caliph/testing/mock-command-line.rb
Defined Under Namespace
Modules: MockingExecute
Class Method Summary collapse
Instance Method Summary collapse
-
#expect_command(cmd, *result) ⇒ Object
Registers an expectation about a command being run - expectations are ordered.
-
#expect_some_commands ⇒ Object
Registers indifference as to exactly what commands get called.
Methods included from CommandLineDSL
Class Method Details
.included(group) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/caliph/testing/mock-command-line.rb', line 42 def self.included(group) group.before :each do @original_execute = Caliph::CommandLine.instance_method(:execute) unless MockingExecute > Caliph::CommandLine Caliph::CommandLine.send(:include, MockingExecute) end Caliph::CommandLine.send(:remove_method, :execute) end group.after :each do Caliph::CommandLine.send(:define_method, :execute, @original_execute) end end |
Instance Method Details
#expect_command(cmd, *result) ⇒ Object
Registers an expectation about a command being run - expectations are ordered
63 64 65 |
# File 'lib/caliph/testing/mock-command-line.rb', line 63 def expect_command(cmd, *result) Caliph::CommandLine.should_receive(:execute, :expected_from => caller(1)[0]).with(cmd).ordered.and_return(MockCommandResult.create(*result)) end |
#expect_some_commands ⇒ Object
Registers indifference as to exactly what commands get called
57 58 59 |
# File 'lib/caliph/testing/mock-command-line.rb', line 57 def expect_some_commands Caliph::CommandLine.should_receive(:execute).any_number_of_times.and_return(MockCommandResult.create(0)) end |