Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
O
oh-my-fish
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
oh-my-fish
Commits
fcc15fc1
Commit
fcc15fc1
authored
Jan 17, 2015
by
Bruno Pinto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow debugging messages to be echoed inside a test
parent
5c81cfbf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
49 deletions
+61
-49
plugins/fish-spec/expect.fish
plugins/fish-spec/expect.fish
+2
-2
plugins/fish-spec/spec.eval.fish
plugins/fish-spec/spec.eval.fish
+7
-2
plugins/fish-spec/spec.run.fish
plugins/fish-spec/spec.run.fish
+1
-1
plugins/fish-spec/spec/spec.spec.fish
plugins/fish-spec/spec/spec.spec.fish
+51
-44
No files found.
plugins/fish-spec/expect.fish
View file @
fcc15fc1
...
@@ -85,10 +85,10 @@ function expect
...
@@ -85,10 +85,10 @@ function expect
set result $status
set result $status
if [ $result -eq 0 ]
if [ $result -eq 0 ]
# Return a non-empty string to indicate success.
# Return a non-empty string to indicate success.
printf "$result"
set -g _spec_current_test_ouput (printf "$result")
else
else
# Return error information separated by \t and tested condition.
# Return error information separated by \t and tested condition.
printf "%s\n" $expected \t $condition $actual
set -g _spec_current_test_ouput (printf "%s\n" $expected \t $condition $actual)
end
end
return $result
return $result
end
end
plugins/fish-spec/spec.eval.fish
View file @
fcc15fc1
...
@@ -19,11 +19,16 @@ function spec.eval
...
@@ -19,11 +19,16 @@ function spec.eval
set -e argv[1]
set -e argv[1]
if functions -q $test
if functions -q $test
# Erase previous test output
set -e _spec_current_test_ouput
# Run the test yielding control to the user defined spec.
# Run the test yielding control to the user defined spec.
set -l output (eval $test)
eval $test
set result $status
set result $status
# Display test results.
# Display test results.
spec.view $test $result $argv -- $
out
put
spec.view $test $result $argv -- $
_spec_current_test_ou
put
end
end
return $result
return $result
end
end
plugins/fish-spec/spec.run.fish
View file @
fcc15fc1
...
@@ -88,6 +88,6 @@ function spec.run
...
@@ -88,6 +88,6 @@ function spec.run
end
end
spec.functions -e describe_
spec.functions -e describe_
return $result
return $result
end
end
plugins/fish-spec/spec/spec.spec.fish
View file @
fcc15fc1
...
@@ -12,40 +12,31 @@ function describe_fish-spec
...
@@ -12,40 +12,31 @@ function describe_fish-spec
function it_has_an_output_if_there_are_no_tests
function it_has_an_output_if_there_are_no_tests
set -l suite "
set -l suite "
import plugins/fish-spec
import plugins/fish-spec
function describe_blank_suite
function describe_blank_suite
end
end
spec.run
spec.run
"
"
expect (run_nested_suite $suite) --to-equal "No tests found."
expect (run_nested_suite $suite) --to-equal "No tests found."
end
end
function it_runs_all_describe_blocks
function it_runs_all_describe_blocks
set -l describe_one 0 1 0
set -l suite "
set -l describe_two 1 0 0
import plugins/fish-spec
set -l describe_expects 1 1 0
set -l suites
function describe_blank_suite
echo 'first describe'
for return_code_index in (seq (count $describe_one))
end
set suites $suites "
import plugins/fish-spec
function describe_another_blank_suite
function describe_blank_suite
echo 'second describe'
function it_returns_0_1_0_1_in_that_order
end
return $describe_one[$return_code_index]
end
spec.run
end
"
function describe_another_blank_suite
function it_returns_1_0_0_1_in_that_order
expect (run_nested_suite $suite) --to-contain-all 'first describe' 'second describe'
return $describe_two[$return_code_index]
end
end
spec.run
"
end
for index in (seq (count $suites))
run_nested_suite $suites[$index]
expect $status --to-equal $describe_expects[$index]
or return 1
end
end
end
function it_runs_all_it_blocks
function it_runs_all_it_blocks
...
@@ -53,23 +44,21 @@ function describe_fish-spec
...
@@ -53,23 +44,21 @@ function describe_fish-spec
import plugins/fish-spec
import plugins/fish-spec
function describe_suite
function describe_suite
function it_is_executed
function it_a_test
return 0
echo 'first test'
end
function it_is_also_executed
return 0
end
end
end
function it_is_also_executed
function describe_another_suite
return 1
function it_another_test
echo 'second test'
end
end
end
end
spec.run
spec.run
"
"
run_nested_suite $suite
expect
$status --to-equal 1
expect
(run_nested_suite $suite) --to-contain-all 'first test' 'second test'
end
end
function it_adds_a_dot_for_a_successful_expectation
function it_adds_a_dot_for_a_successful_expectation
...
@@ -84,9 +73,8 @@ function describe_fish-spec
...
@@ -84,9 +73,8 @@ function describe_fish-spec
spec.run
spec.run
"
"
set -l output (run_nested_suite $suite)
set -l dot (echo -ne (set_color 00FF7F).)
expect (run_nested_suite $suite) --to-equal (dot)
expect "$output" --to-equal $dot
end
end
function it_adds_a_dot_for_each_successful_test
function it_adds_a_dot_for_each_successful_test
...
@@ -97,6 +85,7 @@ function describe_fish-spec
...
@@ -97,6 +85,7 @@ function describe_fish-spec
function it_is_executed
function it_is_executed
expect 'success' --to-equal 'success'
expect 'success' --to-equal 'success'
end
end
function it_is_executed_again
function it_is_executed_again
expect 'success' --to-equal 'success'
expect 'success' --to-equal 'success'
end
end
...
@@ -104,9 +93,8 @@ function describe_fish-spec
...
@@ -104,9 +93,8 @@ function describe_fish-spec
spec.run
spec.run
"
"
set -l output (run_nested_suite $suite)
set -l dot (echo -ne (set_color 00FF7F).)
expect (run_nested_suite $suite) --to-equal (dot)(dot)
expect "$output" --to-equal $dot$dot
end
end
function it_only_adds_a_dot_once_for_each_successful_test
function it_only_adds_a_dot_once_for_each_successful_test
...
@@ -120,11 +108,26 @@ function describe_fish-spec
...
@@ -120,11 +108,26 @@ function describe_fish-spec
end
end
end
end
spec.run
"
expect (run_nested_suite $suite) --to-equal (dot)
end
function it_allows_debugging_messages_to_be_echoed_inside_a_test
set -l suite "
import plugins/fish-spec
function describe_suite
function it_is_executed
echo 'I can see this'
end
end
spec.run
spec.run
"
"
set -l output (run_nested_suite $suite)
set -l output (run_nested_suite $suite)
set -l dot (echo -ne (set_color 00FF7F).)
expect "$output" --to-contain-all 'I can see this'
expect "$output" --to-equal $dot
end
end
end
end
...
@@ -145,4 +148,8 @@ function run_nested_suite -a suite
...
@@ -145,4 +148,8 @@ function run_nested_suite -a suite
return $result
return $result
end
end
function dot
echo -ne (set_color 00FF7F).
end
spec.run $argv
spec.run $argv
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment