Trait

work.martins.simon.expect.fluent

Whenable

Related Doc: package fluent

Permalink

trait Whenable[R] extends AnyRef

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Whenable
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract val whenableParent: Whenable[R]

    Permalink
    Attributes
    protected

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def addWhen[W <: When[R]](f: (ExpectBlock[R]) ⇒ W): W

    Permalink

    Add an arbitrary When to this ExpectBlock.

    Add an arbitrary When to this ExpectBlock.

    This is helpful to refactor code. For example: imagine you have an error case you want to add to multiple ExpectBlocks. You could leverage this method to do so in the following way:

    def errorCaseWhen(expectBlock: ExpectBlock[String]): When[String] = {
      expectBlock
        .when("Some error")
          .returning("Got some error")
    }
    
    def parseOutputA: Expect[String] = {
      val e = new Expect("some command", "")
      e.expect
        .when(...)
          .sendln(...)
      e.expect
        .addWhen(errorCaseWhen)
          .exit()
    }
    
    def parseOutputB: Expect[String] = {
      val e = new Expect("some command", "")
      e.expect
        .when(...)
          .sendln(..)
          .returning(...)
        .addWhen(errorCaseWhen)
    }

    This function returns the added When which allows you to add further actions, see the exit action of the parseOutputA method in the above code.

    It is possible to add more than one When using this method, however this is discouraged since it will make the code somewhat more illegible because "hidden" Whens will also be added.

    If you need to add more than one When you have two options:

    e.expect
      .when(...)
         .sendln(..)
         .returning(...)
      .addWhen(errorCaseWhen)
      .addWhen(anotherWhen)
    e.expect
      .when(...)
         .sendln(..)
         .returning(...)
      .addWhens(multipleWhens)
    f

    function that adds the When.

    returns

    the added When.

  5. def addWhens(f: (ExpectBlock[R]) ⇒ Unit): ExpectBlock[R]

    Permalink

    Add arbitrary Whens to this ExpectBlock.

    Add arbitrary Whens to this ExpectBlock.

    This method is very similar to the addWhen with the following differences:

    1. f has a more relaxed type.
    2. It returns this ExpectBlock. Which effectively prohibits you from invoking When methods.
    3. Has a more semantic name when it comes to adding multiple When's.
    f

    function that adds Whens.

    returns

    this ExpectBlock.

  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  13. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  18. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. def when(pattern: Timeout.type): TimeoutWhen[R]

    Permalink

    Adds a new TimeoutWhen that matches whenever a Timeout in thrown while trying to read text from the process output (stdOut).

    Adds a new TimeoutWhen that matches whenever a Timeout in thrown while trying to read text from the process output (stdOut).

    pattern

    the pattern to match against.

    returns

    the new TimeoutWhen.

  23. def when(pattern: EndOfFile.type): EndOfFileWhen[R]

    Permalink

    Adds a new EndOfFileWhen that matches whenever the EndOfFile in the process output (stdOut) is reached.

    Adds a new EndOfFileWhen that matches whenever the EndOfFile in the process output (stdOut) is reached.

    pattern

    the pattern to match against.

    returns

    the new EndOfFileWhen.

  24. def when(pattern: Regex): RegexWhen[R]

    Permalink

    Adds a new RegexWhen that matches whenever the regex pattern successfully matches against the text read from the process output (stdOut).

    Adds a new RegexWhen that matches whenever the regex pattern successfully matches against the text read from the process output (stdOut).

    pattern

    the pattern to match against.

    returns

    the new RegexWhen.

  25. def when(pattern: String): StringWhen[R]

    Permalink

    Adds a new StringWhen that matches whenever pattern is contained in the text read from the process output (stdOut).

    Adds a new StringWhen that matches whenever pattern is contained in the text read from the process output (stdOut).

    pattern

    the pattern to match against.

    returns

    the new StringWhen.

Inherited from AnyRef

Inherited from Any

Ungrouped