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
7c9d660f
Commit
7c9d660f
authored
Jan 10, 2015
by
Bruno Pinto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests using fish-spec
parent
13051d01
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
39 deletions
+83
-39
plugins/fish-spec/expect.fish
plugins/fish-spec/expect.fish
+24
-0
plugins/fish-spec/fish-spec.load
plugins/fish-spec/fish-spec.load
+1
-0
plugins/fish-spec/function.fish
plugins/fish-spec/function.fish
+0
-0
plugins/fish-spec/run_spec.fish
plugins/fish-spec/run_spec.fish
+11
-0
plugins/fish-spec/run_specs.fish
plugins/fish-spec/run_specs.fish
+17
-0
test/test_oh-my-fish.fish
test/test_oh-my-fish.fish
+30
-39
No files found.
plugins/fish-spec/expect.fish
0 → 100644
View file @
7c9d660f
function expect
set -l expected $argv[1..-3]
set -l comparison $argv[-2]
set -l actual $argv[-1]
switch $comparison
case 'to_equal'
if test "$expected" = "$actual"
emit assertion_success
else
emit assertion_failure "Expected: \"$expected\""\n" Actual: \"$actual\""
end
case 'to_include'
set -l item $actual
set -l list $expected
if contains -- "$item" $list
emit assertion_success
else
emit assertion_failure "Expected \"$list\" to include \"$item\""
end
end
end
plugins/fish-spec/fish-spec.load
0 → 100644
View file @
7c9d660f
run_specs
plugins/fish-spec/function.fish
0 → 100644
View file @
7c9d660f
plugins/fish-spec/run_spec.fish
0 → 100644
View file @
7c9d660f
function run_spec -a test
eval $test
end
function run_spec._.results.assertion_success -e assertion_success
printf '.'
end
function run_spec._.results.assertion_failure -e assertion_failure
echo $argv
end
plugins/fish-spec/run_specs.fish
0 → 100644
View file @
7c9d660f
function run_specs
# Run each describe function
for describe in (functions -n | grep describe_)
eval $describe
end
# Run before all block
eval "before_all"
# Run tests
for test in (functions -n | grep it_)
run_spec $test
end
# Run after all block
eval "after_all"
end
test/test_oh-my-fish.fish
View file @
7c9d660f
function
suite_oh-my-
fish
function
setup
function
describe_oh_my_
fish
function
before_all
set -g fish_custom_bak $fish_custom
set -g fish_function_path_bak $fish_function_path
set -g fish_plugins_bak $fish_plugins
end
function
teardown
function
after_all
set fish_custom $fish_custom_bak
set fish_function_path $fish_function_path_bak
set fish_plugins $fish_plugins_bak
end
#
# tests
#
function test_default_custom_folder
function it_has_a_default_custom_folder
set -e fish_custom
load_oh_my_fish
assert_equal ~/.oh-my-fish/custom $fish_custom
expect $fish_custom to_equal "$HOME/.oh-my-fish/custom"
end
function
test_custom_folder
function
it_allows_the_custom_folder_location_to_be_customized
set fish_custom /tmp
load_oh_my_fish
assert_equal /tmp $fish_custom
expect $fish_custom to_equal '/tmp'
end
function
test_load
_custom_files
function
it_loads_all
_custom_files
set fish_custom /tmp
echo 'set -gx TEST_LOAD_CUSTOM_FILE test_load' > $fish_custom/test.load
echo 'set -gx TEST_LOAD_CUSTOM_FILE file_loaded' > $fish_custom/test.load
load_oh_my_fish
assert_equal test_load $TEST_LOAD_CUSTOM_FILE
expect $TEST_LOAD_CUSTOM_FILE to_equal 'file_loaded'
end
function
test
_oh_my_fish_functions
function
it_loads_all
_oh_my_fish_functions
remove_from_array "$fish_path/functions/" fish_function_path
load_oh_my_fish
assert_includes $fish_path/functions/ $fish_function_path
expect $fish_function_path to_include $fish_path/functions/
end
function
test_oh_my_fish
_plugins
function
it_loads_all_selected
_plugins
remove_from_array "$fish_path/plugins/z" fish_function_path
set fish_plugins z
set fish_plugins
bak
z
load_oh_my_fish
assert_includes $fish_path/plugins/z $fish_function_path
expect $fish_function_path to_include $fish_path/plugins/bak and
expect $fish_function_path to_include $fish_path/plugins/z
end
function
test_oh_my_fish_themes
function
it_loads_the_selected_theme
remove_from_array "$fish_path/themes/l" fish_function_path
set fish_theme l
load_oh_my_fish
assert_includes $fish_path/themes/l $fish_function_path
expect $fish_function_path to_include $fish_path/themes/l
end
end
#
# helper functions
#
function load_oh_my_fish
. $fish_path/oh-my-fish.fish
end
function load_oh_my_fish
. $fish_path/oh-my-fish.fish
end
function remove_from_array
set -l element $argv[1]
function remove_from_array
set -l element $argv[1]
for i in (seq (count $$argv[2]))
if test $$argv[2][$i] = $element
set -e $argv[2][$i]
break
end
for i in (seq (count $$argv[2]))
if test $$argv[2][$i] = $element
set -e $argv[2][$i]
break
end
end
end
if not set -q tank_running
source (dirname (status -f))/helper.fish
tank_run
end
import plugins/fish-spec
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