diff --git a/.circleci/config.yml b/.circleci/config.yml index e199398..74459c9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,6 +8,10 @@ jobs: docker: # specify the version you desire here - image: circleci/ruby:2.4.1-node-browsers + environment: + TEST_DRB: false + + - image: memcached:1.4-alpine working_directory: ~/repo @@ -28,25 +32,22 @@ jobs: key: v1-dependencies-{{ checksum "Gemfile" }} - run: - name: install memcached - command: | - sudo apt-get update && sudo apt-get install -y memcached - sudo service start memcached || true - memcached -d || true - echo "checking if memcached is running...." - ps -ef | grep [m]emcached + name: install dockerize + command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz + environment: + DOCKERIZE_VERSION: v0.3.0 - run: - name: install sym bash helpers - command: | - bundle exec exe/sym -B ~/.bash_profile - [[ -f ~/.sym.completion.bash ]] || exit 1 - [[ -f ~/.sym.symit.bash ]] || exit 1 + name: Wait for memcached + command: dockerize -wait tcp://localhost:11211 -timeout 1m - run: name: run tests command: | bundle exec rspec --version bundle exec exe/sym --version - echo password | bundle exec rspec --backtrace --format documentation + if [[ -t 1 ]]; then echo "this is a TTY!"; else echo "this is NOT a tty"; fi + if [[ -p /dev/stdout ]]; then echo "this is a PIPE!"; else echo "this is NOT a pipe"; fi + if [[ ! -t 1 && ! -p /dev/stdout ]]; then echo "this is a REDIRECT!"; else echo "this is NOT a redirect"; fi + CI=true timeout -k 2 -s HUP 30 bundle exec rspec --order random --format documentation --backtrace diff --git a/.travis.yml b/.travis.yml index 782b2fd..ef3cb6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: ruby env: -- CODECLIMATE_REPO_TOKEN=c71874cc22acffe1e2543d3388d3a96c73a65f0cfe17169dadd8de4a6c062c39 TEST_DRB=true HOME=/home/travis USER=travis SYMIT__KEY="W84hsxsELLGrTammtin3cwPkuv9q_3vksjhI-PbAFVM=" + global: + secure: TQeUpdDH/j5AefVh2NRvU8t/ftxXQqaIO5m0ir7vzJgEBuP8twTqx/CFeZWogd/u0McMgL48NHgQZGXz1n04ZZasovcrk4wd7kMwSyNTtyAa/0D5u6k1JyiynNV26MWvxXGBw4OCCfVCa4WXIM0s7YI2S/q9ZYKSWWYtw/Lo+MDHjJEIaM4EdL+b9SxF94y8DcDXy2qt7H58nUJV/RVz9uG++kuDbpoobwO8mEGGuUIcxubgFoKqOCjXkX1Qe2vY2LgJGb7OZsVDj7QhARwm1NwspxTZDgfQzeSHM5uCW5JJ40Ur4bAb4bFXDPV2yF64cagYWcQow20To1qO17UR+xIFMMV+pxnhTiiRtGzyDCoYLCc5ldXyrnVskQYtXLwrY92Na4avdWCalL8fBO7IfBVHHADowED2AW8thExf4ljVR1wzjs0vIeVmVz9ApJr25sgZjKawaosv7BHt9MDKruK7tQBY8HIAjEsP50cb42VOucY+vabWtTG6QzX+//tjsDlM0rOhSiMlqxpbrwpWxpnhc+kn3TeMPr1oU0j9gDCRMghcaCVD18JKwZMx45LEX7LZY2lQcnLmJJOwnwamuReLc/w6cMO1ORjBgRsDkyz0Jila90cTUSJq21I41srDauprolfrqT1igZ3rB/C++vA/SiG+hz7WzvMWXBv/fzs= services: - memcached rvm: @@ -17,18 +18,16 @@ notifications: slack: rooms: secure: GcACCHmcmo99lYE5dgt2TmY4YIPMWr75q0Bkm4Lddegq/1eMXgcZDz00j8iHWtnveyJSjEUpZFQ9uyx+P7dvxT7D5gl43arKZEylS4vMRg9QRgZu7/ROrXbJtrUyKulFRUTdFrmOiK9nDKpAzlvLvMKC4kaQnn88Xtu9pYMU8y4n5fCtl29gZM9ZjVbrBBvV/SumnTDLla2oQ7oFgUZdZhQZ1qsevYknxNq4eIcvPDjbon+bovfsIISEVRSNo2C3yjO+mqWKed3jfuCA4taAZ8/aVVFEKURMH10HFms1CiC3lE/gF4YfBXsqKpjnB+bKjBcWox2FQrp96FulMEIfkKQrnuncO96o7MGHX9oNqKSMoycf3+SZFwNa+5Mfq7SBepbHYCoU7/ow31UTyStrc5idG19XzYgI85yjQHdzQN299Xf0O8cGf9q9qAu7rS7JlM3ekR+3rZYO+OxNYTF8rcW1fYIj6GKcbsV8BvuhAVQRFOsk/ibcIb2N7rGVd/ZbU4HAk3RE1ywt+XowinpIHktu2PQUPDNpgRQwM6xqZHO/7s9r7oW0ULmZCMLZ9CMKNjKzrQ9wfh90+v+FiEiUKsaVj4cCwF3PvhVYvxU2AKbCeHtSEb7K6to86+DYNoIKnGH1ryKoyCtyOTZpNMLGFt34Msv7WfEylhG+DpVMvkM= -addons: - code_climate: - repo_token: c71874cc22acffe1e2543d3388d3a96c73a65f0cfe17169dadd8de4a6c062c39 -# regular test configuration -after_success: - - bundle exec codeclimate-test-reporter before_script: - - echo stats | nc localhost 11211 -script: + - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + - chmod +x ./cc-test-reporter + - ./cc-test-reporter before-build - bundle exec exe/sym -B ~/.bash_profile -vTD - source ~/.sym.symit.bash - ls -alF ~/.sym* - ls -alF . - mkdir -p temp - - bundle exec rspec --format documentation +after_script: + - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT +script: + - USER=travis bundle exec rspec --format documentation --order random diff --git a/Rakefile b/Rakefile index 666aa49..e7582d6 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'yard' - +require 'timeout' def shell(*args) puts "running: #{args.join(' ')}" @@ -34,3 +34,5 @@ RSpec::Core::RakeTask.new(:spec) task :default => :spec + + diff --git a/lib/sym/app/input/handler.rb b/lib/sym/app/input/handler.rb index da166fa..3180784 100644 --- a/lib/sym/app/input/handler.rb +++ b/lib/sym/app/input/handler.rb @@ -27,7 +27,13 @@ def puts(*args) end def prompt(message, color) - raise Sym::Errors::CantReadPasswordNoTTY.new('key requires a password, however STDIN is not a TTY') unless stdin.tty? + unless STDIN.isatty && STDIN.tty? + raise Sym::Errors::CantReadPasswordNoTTY.new('key requires a password, however STDIN is not a TTY') + end + highline(message, color) + end + + def highline(message, color) HighLine.new(stdin, stderr).ask(message.bold) { |q| q.echo = '•'.send(color) } end diff --git a/spec/integration/sym_cli_spec.rb b/spec/integration/sym_cli_spec.rb index 34636b0..1bfcd0c 100644 --- a/spec/integration/sym_cli_spec.rb +++ b/spec/integration/sym_cli_spec.rb @@ -18,7 +18,7 @@ RESET_TEMP_FILE.call context 'using Aruba framework' do - let(:command) { "bundle exec exe/sym #{args}" } + let(:command) { "exe/sym #{args}" } let(:output) { last_command_started.stdout.chomp } context 'install bash completion' do @@ -126,3 +126,4 @@ end end end + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4ddc535..d8179a9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -22,7 +22,7 @@ spec.after :all do `/usr/bin/env bash -c "kill $(ps -ef | egrep ruby | egrep [c]oin | awk '{print $2}' ) 2>/dev/null"` - `echo flush_all | nc localhost 11211 2>/dev/null` + `echo flush_all | nc -G 2 127.0.0.1 11211 2>/dev/null` end end diff --git a/spec/support/aruba.rb b/spec/support/aruba.rb index 872a8f0..232dd51 100644 --- a/spec/support/aruba.rb +++ b/spec/support/aruba.rb @@ -3,6 +3,8 @@ require 'sym/app/cli' Aruba.configure do |config| - config.command_launcher = :in_process - config.main_class = Sym::App::CLI + unless ENV['CI'] + config.command_launcher = :in_process + config.main_class = Sym::App::CLI + end end diff --git a/spec/sym/app/input/handler_spec.rb b/spec/sym/app/input/handler_spec.rb index b652c29..f4ac967 100644 --- a/spec/sym/app/input/handler_spec.rb +++ b/spec/sym/app/input/handler_spec.rb @@ -1,27 +1,26 @@ require 'spec_helper' require 'singleton' -def setup_handler(calls = []) - calls.each do |hash| - expect(handler).to receive(:prompt).with(hash[:message], hash[:color]).and_return(hash[:password]) - end -end - module Sym module App + RSpec.describe Input::Handler do + def setup_handler(calls = []) + calls.each do |hash| + expect(handler).to receive(:prompt).with(hash[:message], hash[:color]).and_return(hash[:password]) + end + end - RSpec.describe Sym::App::Input::Handler do let(:password) { 'boobooboo' } let(:opts) { { password: true } } - let(:handler) { Input::Handler.new } + let(:handler) { Input::Handler.new } context 'entering password' do it 'should save what the stupid user entered' do - setup_handler [ { message: 'Password: ', color: :green, password: password } ] + setup_handler [{ message: 'Password: ', color: :green, password: password }] expect { handler.ask }.to_not raise_error end it 'should be what the stupid user entered' do - setup_handler [ { message: 'Password: ', color: :green, password: password } ] + setup_handler [{ message: 'Password: ', color: :green, password: password }] expect(handler.ask).to eql(password) end end @@ -29,8 +28,8 @@ module App context 'creating new password' do context 'passwords dont match' do it 'should raise an exception' do - setup_handler [ { message: 'New Password : ', color: :blue, password: 'right password' }, - { message: 'Confirm Password : ', color: :blue, password: 'WhatsUpYo' }] + setup_handler [{ message: 'New Password : ', color: :blue, password: 'right password' }, + { message: 'Confirm Password : ', color: :blue, password: 'WhatsUpYo' }] expect { handler.new_password }.to raise_error(Sym::Errors::PasswordsDontMatch) end end