Skip to content

Commit

Permalink
Fix for CircleCI — no localhost is defined there
Browse files Browse the repository at this point in the history
Also fixing CodeClimate and test coverage.
Also using proper command execution in Aruba tests on CI
  • Loading branch information
kigster committed Apr 13, 2018
1 parent 929f3d5 commit 44c30c9
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 41 deletions.
27 changes: 14 additions & 13 deletions .circleci/config.yml
Expand Up @@ -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

Expand All @@ -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
19 changes: 9 additions & 10 deletions .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:
Expand All @@ -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
4 changes: 3 additions & 1 deletion 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(' ')}"
Expand Down Expand Up @@ -34,3 +34,5 @@ RSpec::Core::RakeTask.new(:spec)
task :default => :spec




8 changes: 7 additions & 1 deletion lib/sym/app/input/handler.rb
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion spec/integration/sym_cli_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -126,3 +126,4 @@
end
end
end

2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions spec/support/aruba.rb
Expand Up @@ -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
23 changes: 11 additions & 12 deletions spec/sym/app/input/handler_spec.rb
@@ -1,36 +1,35 @@
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

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
Expand Down

0 comments on commit 44c30c9

Please sign in to comment.