M lib/text.sh => lib/text.sh +2 -8
@@ 15,12 15,6 @@ sending() {
SEND_ME="$1"
sxmo_modemsendsms.sh "$CHEOGRAM_NUM" "$SEND_ME" > /dev/null
- # TODO: Why do I need to run the following command outside of shellspec?
- # outside of shellspec ./go-sendxmpp writes the text to file
- ./go-sendxmpp -l > sendingdat &
- sleep 4s
- killall go-sendxmpp
- killall go-sendxmpp
- sleep 2s
- tail -n 1 sendingdat
+ sleep 4s # wait for go-sendxmpp to receive the message
+ tail -n 1 /tmp/recv
}
M spec/text_spec.sh => spec/text_spec.sh +18 -3
@@ 3,14 3,29 @@
%const NAME: value
% DATE: "$(date) $(cat /dev/urandom | base64 | head -n 1)"
-Describe 'text.sh'
+Describe "receiving"
Include lib/text.sh
- It 'Can receive plaintext message pinephone'
+ It 'Can receive plaintext message on pinephone'
When call recieving "Receiving plain text at $DATE" ShellSpec
The output should equal "Receiving plain text at $DATE"
End
+End
+Describe "sending"
+ Include lib/text.sh
+ setup() {
+ . ./.secrets
+ ./go-sendxmpp -l > /tmp/recv &
+ sleep 1
+ pid=$!
+ }
+ BeforeRun setup
+ cleanup() {
+ kill -TERM "$pid"
+ wait "$pid"
+ }
+ AfterRun cleanup
It 'Can send plaintext message from pinephone'
- When call sending "Sending plain text at $DATE" ShellSpec
+ When run sending "Sending plain text at $DATE" ShellSpec
The output should equal "Sending plain text at $DATE"
End
End