Sha256: 38385bcc978525e472fa4c102eedb9ed5ca9a6719220ab7950680ed790b6999f

Contents?: true

Size: 1.25 KB

Versions: 16

Compression:

Stored size: 1.25 KB

Contents

[<< back](README.md)

# Example: 14-alias

By using aliases we can adapt a configuration file, so that it can be used with many different tests.

## Exanation

Suppose we have a test like the following:

```ruby
group "Using alias" do
  target "Verify user #{get(:super)} with key alias."
  run "id #{get(:super)}"
  expect get(:super)

  target "Verify user #{_username} with method alias."
  run "id #{_username}"
  expect _username
end
```

> REMEMBER:
> * We only have 2 targets but we could have many more.
> * `_username` is equivalent to `get(:username)`

Our test requires the `super` parameter but the configuration file has named it as `superuser`. Our configuration file define values for `supername` and `username` parameters. Let's see:

```yaml
# First version
# File: config.yaml
global:
cases:
- tt_members: Anonymous
  superuser: root
  username: obiwan
```

We would like to take advantage of a configuration file that we already had from another test, without big changes. So we add an `alias`:

```yaml
# Alias Version
# File: config.yaml
alias:
  super: :superuser
global:
cases:
- tt_members: Anonymous
  superuser: root
  username: obiwan
```

Now our test will work correctly. Calling `get(:super)` will return the same value as doing `get(:superuser).

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
teuton-2.9.2 docs/learn/17-alias.md
teuton-2.9.1 docs/learn/17-alias.md
teuton-2.9.0 docs/learn/17-alias.md
teuton-2.8.0 docs/learn/17-alias.md
teuton-2.7.3 docs/learn/17-alias.md
teuton-2.7.2 docs/learn/17-alias.md
teuton-2.7.1 docs/learn/17-alias.md
teuton-2.7.0 docs/learn/17-alias.md
teuton-2.6.0 docs/learn/17-alias.md
teuton-2.5.0 docs/learn/17-alias.md
teuton-2.4.5 docs/learn/17-alias.md
teuton-2.4.4 docs/learn/17-alias.md
teuton-2.4.3 docs/learn/17-alias.md
teuton-2.4.2 docs/learn/17-alias.md
teuton-2.4.1 docs/learn/14-alias.md
teuton-2.4.0 docs/learn/14-alias.md