Sha256: fc8f4e2ca6da032c407a773e45ea773f6809c043b97446df720bb30883f3fb92

Contents?: true

Size: 1.8 KB

Versions: 10

Compression:

Stored size: 1.8 KB

Contents

[<< back](../README.md)

1. [Description](#description)
2. [Usage](#usage)
3. [Example](#example)
4. [Basic](#basic)
5. [Advanced](#advanced)

## Description

Compare the obtained result with the expected one. This comparation process is registered into final report.

## Usage

```ruby
target 'Exist user obiwan'
run 'cat /etc/passwd'
expect 'root'
```

Use `expect` keyword to check output (from previous execution).

## Example

Let's see some examples:

```ruby
target 'Exist user obiwan'
run 'id obiwan'
expect 'obiwan' # Expect previous command output contains obiwan text
```

## Basic

* **expect 'obiwan'**, expect line/s with "obiwan".
* **expect ['obiwan', 'kenobi'**, expect line/s with "obiwan" and kenobi".
* **expect_one 'obiwan'**, expect only one line with "obiwan".
* **expect_one ['obiwan','kenobi']**, expect only one line with "obiwan" and "kenobi".
* **expect_none 'obiwan'**, expect no line with "obiwan".
* **expect_none ['obiwan', 'kenobi']**, expect no line with "obiwan" and "kenobi".
* **expect /Obiwan|obi-wan/**, Expect line/s with Obiwan or obi-wan. This example uses regular expresions.

## Advanced

After every execution keyword (`run`, `on` or `goto`), command outputs is saved by **result** object. Use **result** to create more complex evaluations.

For example, if we have this execution

```ruby
target 'Exist user vader'
run    'cat /etc/passwd'
```

Then we check result with:

* **expect result.find("vader").count.eq(1)**, expect there exists only 1 line with "vader" text.
* **expect result.find(/Darth|darth/).find(/Vader|vader/).count.gt(2)**, expect there exists more than 2 lines with texts "Darth" and "Vader".
* **expect result.not_find('#').find('vader').count.lt(3)**, expects there exists less than 3 lines with text "vader" and without "#" symbol.

Read [result](result.md) documentation.

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
teuton-2.3.6 docs/dsl/definition/expect.md
teuton-2.3.5 docs/dsl/definition/expect.md
teuton-2.3.4 docs/dsl/definition/expect.md
teuton-2.3.3 docs/dsl/definition/expect.md
teuton-2.3.2 docs/dsl/definition/expect.md
teuton-2.3.1 docs/dsl/definition/expect.md
teuton-2.2.2 docs/dsl/definition/expect.md
teuton-2.1.11 docs/dsl/definition/expect.md
teuton-2.1.10 docs/dsl/definition/expect.md
teuton-2.1.9 docs/dsl/definition/expect.md