-
-
Notifications
You must be signed in to change notification settings - Fork 75
Description
I am trying to mock a command.
#!/bin/bash function mock_curl_command() { curl_out=$(curl $url) curl_status=$? if [[ $curl_status -ne 0 ]]; then echo "Command execution failed with $curl_out" else echo 'curl_executed_successfully' fi
}
I am trying to mock the curl command
Describe 'mock curl command' Mock curl echo 'curl_executed_successfully' return 0 End It 'call mock curl command' When call mock_curl_command The output should eq 'curl_executed_successfully' The status should be success End End
I am trying shellspec in ubundu linux
spec file failed as the curl_status is 2
and Getting warning as
stderr:/tmp/shellspec.1692275062.70345/1/curl: line 4: return: can only `return' from a function or sourced script
how to set the value for curl_status which the previous line execution status ($?) ?