-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from NthPortal/tests
Add tests for AliasProcessor
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/test/scala/com/nthportal/shell/extensions/alias/AliasProcessorTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.nthportal.shell.extensions.alias | ||
|
||
import com.nthportal.shell.{Shell, SimpleSpec} | ||
import com.nthportal.shell.impl.{NoOpOutputProvider, TestCommand} | ||
import com.nthportal.shell.parsers.WhitespaceDelineatingParser | ||
|
||
class AliasProcessorTest extends SimpleSpec { | ||
|
||
behavior of "AliasProcessor" | ||
|
||
it should "process aliases properly" in { | ||
val command = TestCommand() | ||
val name = "alias" | ||
val alias = Alias.forCommand(name, command) | ||
val processor = AliasProcessor(alias) | ||
val shell = Shell(WhitespaceDelineatingParser, NoOpOutputProvider, List(processor), command) | ||
|
||
shell.executeLine(name) | ||
command.executed should be (true) | ||
} | ||
|
||
it should "not loop infinitely" in { | ||
val command = TestCommand() | ||
val name = "alias" | ||
val a1 = Alias(command.name, name) | ||
val a2 = Alias.forCommand(name, command) | ||
val processor = AliasProcessor(a1, a2) | ||
val shell = Shell(WhitespaceDelineatingParser, NoOpOutputProvider, List(processor), List(command)) | ||
|
||
shell.executeLine(command.name) | ||
command.executed should be (true) | ||
} | ||
} |