Skip to content

Commit 9d5e97a

Browse files
committed
improve specs
1 parent 7c3a670 commit 9d5e97a

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
if default_environment_variables.any?
22
= view_marker
33

4-
if default_environment_variables.any?
5-
default_environment_variables.each do |env_var|
6-
> export {{ env_var.name.upcase }}="${<%= env_var.name.upcase %>:-<%= env_var.default %>}"
7-
end
4+
default_environment_variables.each do |env_var|
5+
> export {{ env_var.name.upcase }}="${<%= env_var.name.upcase %>:-<%= env_var.default %>}"
86
end
97
end

spec/approvals/fixtures/environment-variables-initialize

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ created ./cli
55
run ./cli --help to test your bash script
66
+ ./cli
77
PASS: API_KEY=must-be-available-in-initialize
8+
PASS: NESTED_VAR is empty
89
missing required environment variable: CONFIG_PATH
910
+ export CONFIG_PATH=somepath
1011
+ CONFIG_PATH=somepath
1112
+ ./cli download source
1213
PASS: API_KEY=must-be-available-in-initialize
14+
PASS: NESTED_VAR is empty
1315
# this file is located in 'src/download_command.sh'
1416
# code for 'cli download' goes here
1517
# you can edit it freely and regenerate (it will not be overwritten)
@@ -19,6 +21,7 @@ args:
1921
+ API_KEY=override-value
2022
+ ./cli
2123
PASS: API_KEY=override-value
24+
PASS: NESTED_VAR is empty
2225
cli - Sample application
2326

2427
Usage:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
cli
2-
src/*.sh
2+
src/download_command.sh

spec/fixtures/workspaces/environment-variables-initialize/src/bashly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ commands:
2222
help: "Target filename (default: same as source)"
2323

2424
environment_variables:
25-
- name: default_target_location
25+
- name: nested_var
2626
default: not-available-in-initialize
2727
help: Set the default location to download to
2828

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if [[ -n "$API_KEY" ]]; then
2+
echo "PASS: API_KEY=$API_KEY"
3+
else
4+
echo "FAIL: API_KEY is empty"
5+
fi
6+
7+
if [[ -z "$NESTED_VAR" ]]; then
8+
echo "PASS: NESTED_VAR is empty"
9+
else
10+
echo "FAIL: NESTED_VAR=$NESTED_VAR"
11+
fi
12+
13+

0 commit comments

Comments
 (0)