Skip to content

Commit

Permalink
Fix RSpec (#175)
Browse files Browse the repository at this point in the history
* Make rspec green again
* Enable rspec in travis
  • Loading branch information
skryukov authored May 4, 2021
1 parent 3a5d000 commit 942e109
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 18 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ go:
notifications:
email: false

# before_script:
# - sudo apt-get -q install ruby
# - gem install bundler
# - bundle install
before_script:
- sudo apt-get -q install ruby
- gem install bundler
- bundle install

script:
# - bundle exec rspec
- bundle exec rspec
- go test ./cmd
35 changes: 29 additions & 6 deletions spec/fixtures/pre-commit
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
#!/bin/bash
#!/bin/sh

# If can't find lefthook in global scope
# we suppose it in local npm package
if ! type lefthook >/dev/null
if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi

if [ -t 1 ] ; then
exec < /dev/tty ; # <- enables interactive shell
fi

dir="$(cd "$(dirname "$(dirname "$(dirname "$0")")")" >/dev/null 2>&1 || exit ; pwd -P)"


cmd="lefthook run pre-commit $@"

if lefthook -h >/dev/null 2>&1
then
eval $cmd
elif test -f "$dir/node_modules/@arkweid/lefthook/bin/lefthook"
then
eval $dir/node_modules/@arkweid/lefthook/bin/$cmd
elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec $cmd
elif npx lefthook -h >/dev/null 2>&1
then
npx $cmd
elif yarn lefthook -h >/dev/null 2>&1
then
exec npx lefthook run pre-commit $@
yarn $cmd
else
exec lefthook run pre-commit $@
echo "Can't find lefthook in PATH"
fi
35 changes: 29 additions & 6 deletions spec/fixtures/pre-push
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
#!/bin/bash
#!/bin/sh

# If can't find lefthook in global scope
# we suppose it in local npm package
if ! type lefthook >/dev/null
if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi

if [ -t 1 ] ; then
exec < /dev/tty ; # <- enables interactive shell
fi

dir="$(cd "$(dirname "$(dirname "$(dirname "$0")")")" >/dev/null 2>&1 || exit ; pwd -P)"


cmd="lefthook run pre-push $@"

if lefthook -h >/dev/null 2>&1
then
eval $cmd
elif test -f "$dir/node_modules/@arkweid/lefthook/bin/lefthook"
then
eval $dir/node_modules/@arkweid/lefthook/bin/$cmd
elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec $cmd
elif npx lefthook -h >/dev/null 2>&1
then
npx $cmd
elif yarn lefthook -h >/dev/null 2>&1
then
exec npx lefthook run pre-push $@
yarn $cmd
else
exec lefthook run pre-push $@
echo "Can't find lefthook in PATH"
fi
3 changes: 2 additions & 1 deletion spec/support/file_structure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class << self
attr_accessor :root

def have_git
FileUtils.mkdir_p(File.join(tmp, '.git', 'hooks'))
FileUtils.mkdir_p(File.join(tmp))
_, _, _ = Open3.capture3('git init', chdir: tmp)
end

def make_scripts_preset
Expand Down

0 comments on commit 942e109

Please sign in to comment.