Skip to content

Commit a36fa72

Browse files
author
yamaszone
committed
Jokes CLI implementation in Bash via BDD
1 parent e23bded commit a36fa72

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

python/bdd/features/jokes.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Feature: Jokes Tool
2+
In order to make development process enjoyable,
3+
I should be able to read jokes from terminal
4+
5+
Scenario: Jokes can be read from CLI
6+
Given CLI jokes tool is installed
7+
When I execute "joke"
8+
Then I should see "Setup"
9+
And I should see "Punchline"

python/bdd/features/steps/steps.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
driver = webdriver.PhantomJS()
1212

13+
@given(u'CLI jokes tool is installed')
14+
def step_impl(context):
15+
execute('./joke_installer_bash')
16+
1317
@given(u'a Ubuntu development machine')
1418
def step_impl(context):
1519
pass

python/bdd/joke

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
API_URL="https://08ad1pao69.execute-api.us-east-1.amazonaws.com/dev/random_joke"
4+
5+
# Save jokes data
6+
OUTPUT="/tmp/random_joke.txt"
7+
curl -sS "$API_URL" > "$OUTPUT"
8+
9+
# Parse setup and punchline
10+
SETUP=`cat $OUTPUT | jq '.setup'`
11+
PUNCH=`cat $OUTPUT | jq '.punchline'`
12+
13+
# Display setup and punchline
14+
printf "Setup: $SETUP \n"
15+
printf "Punchline: $PUNCH \n"
16+
17+
# Clean up temporary file
18+
rm "$OUTPUT"

python/bdd/joke_installer_bash

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
sudo cp ./joke /usr/local/bin/joke
4+
sudo chmod +x /usr/local/bin/joke

0 commit comments

Comments
 (0)