Outthentic interactive tests for bash-snippets tools (#89)
This commit is contained in:
parent
c60796282b
commit
115cf2f47b
|
@ -6,5 +6,10 @@ before_install:
|
|||
- sudo apt-get install -qq bats
|
||||
- sudo apt-get install -qq vlc
|
||||
- sudo apt-get install -qq openssl
|
||||
- cpanm Sparrow --sudo --notest -q
|
||||
- sparrow index update
|
||||
- sparrow plg install bash-snippets-interactive-test
|
||||
|
||||
script:
|
||||
- bats tests
|
||||
- sparrow plg run bash-snippets-interactive-test --param dir=$PWD
|
||||
- bats tests
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# SYNOPSIS
|
||||
|
||||
Run tests against BashSnippets tools with interactive prompt.
|
||||
|
||||
# INSTALL
|
||||
|
||||
$ sparrow plg install bash-snippets-interactive-test
|
||||
|
||||
# USAGE
|
||||
|
||||
$ sparrow plg run bash-snippets-interactive-test --param dir=/path/to/bash-snippets/tools/directory
|
||||
|
||||
|
||||
![report](https://raw.githubusercontent.com/melezhik/images/master/report.png)
|
||||
|
||||
# Authors
|
||||
|
||||
* The plugin maintainer is [Alexey Melezhik](https://github.com/melezhik/)
|
||||
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
requires "Expect";
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
run_story 'currency/example1'
|
||||
run_story 'currency/example2'
|
|
@ -0,0 +1,15 @@
|
|||
begin:
|
||||
What is the base currency: USD
|
||||
What currency to exchange to: RUB
|
||||
What is the amount being exchanged: 0
|
||||
end:
|
||||
|
||||
begin:
|
||||
=========================
|
||||
| USD to RUB
|
||||
regexp: ^\|\s+Rate:\s+\d+\.\d+\s*$
|
||||
| USD: 0
|
||||
| RUB: 0
|
||||
=========================
|
||||
end:
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use Expect;
|
||||
|
||||
use strict;
|
||||
|
||||
my $tools_dir = config()->{dir};
|
||||
|
||||
|
||||
|
||||
my $exp = Expect->new;
|
||||
|
||||
$exp->spawn("$tools_dir/currency/currency")
|
||||
or die "Cannot spawn command: bash $tools_dir/currency/currency: $!\n";
|
||||
|
||||
|
||||
$exp->expect(120,
|
||||
[
|
||||
qr/What is the base currency/ => sub {
|
||||
my $exp = shift;
|
||||
$exp->send("USD\n");
|
||||
exp_continue;
|
||||
}
|
||||
],
|
||||
[
|
||||
qr/What currency to exchange to/ => sub {
|
||||
my $exp = shift;
|
||||
$exp->send("RUB\n");
|
||||
exp_continue;
|
||||
}
|
||||
],
|
||||
[
|
||||
qr/What is the amount being exchanged/ => sub {
|
||||
my $exp = shift;
|
||||
$exp->send("0\n");
|
||||
exp_continue;
|
||||
}
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
$exp->hard_close();
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
begin:
|
||||
What is the base currency: USD
|
||||
What currency to exchange to: RUB
|
||||
What is the amount being exchanged: 100
|
||||
end:
|
||||
|
||||
begin:
|
||||
=========================
|
||||
| USD to RUB
|
||||
regexp: ^\|\s+Rate:\s+\d+\.\d+\s*$
|
||||
| USD: 100
|
||||
regexp: ^\|\s+RUB:\s+\d+\.\d+\s*$
|
||||
=========================
|
||||
end:
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use Expect;
|
||||
|
||||
use strict;
|
||||
|
||||
my $tools_dir = config()->{dir};
|
||||
|
||||
|
||||
|
||||
my $exp = Expect->new;
|
||||
|
||||
$exp->spawn("$tools_dir/currency/currency")
|
||||
or die "Cannot spawn command: bash $tools_dir/currency/currency: $!\n";
|
||||
|
||||
|
||||
$exp->expect(120,
|
||||
[
|
||||
qr/What is the base currency/ => sub {
|
||||
my $exp = shift;
|
||||
$exp->send("USD\n");
|
||||
exp_continue;
|
||||
}
|
||||
],
|
||||
[
|
||||
qr/What currency to exchange to/ => sub {
|
||||
my $exp = shift;
|
||||
$exp->send("RUB\n");
|
||||
exp_continue;
|
||||
}
|
||||
],
|
||||
[
|
||||
qr/What is the amount being exchanged/ => sub {
|
||||
my $exp = shift;
|
||||
$exp->send("100\n");
|
||||
exp_continue;
|
||||
}
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
$exp->hard_close();
|
||||
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 69 KiB |
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name" : "bash-snippets-interactive-test",
|
||||
"description" : "Run tests against BashSnippets tools with interactive prompt",
|
||||
"version" : "0.0.2",
|
||||
"url" : "https://github.com/alexanderepstein/Bash-Snippets",
|
||||
"category": "utilities",
|
||||
"sparrow_version" : "0.2.48",
|
||||
"doc" : "README.md"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
dir: "../"
|
Loading…
Reference in New Issue