diff --git a/Guardfile b/Guardfile new file mode 100644 index 00000000..13788683 --- /dev/null +++ b/Guardfile @@ -0,0 +1,62 @@ +# frozen_string_literal: true +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +## Uncomment and set this to only include directories you want to watch +# directories %w(app lib config test spec features) \ +# .select{|d| Dir.exist?(d) ? d : UI.warning('Directory #{d} does not exist')} + +## Note: if you are using the `directories` clause above and you are not +## watching the project directory ('.'), then you will want to move +## the Guardfile to a watched dir and symlink it back, e.g. +# +# $ mkdir config +# $ mv Guardfile config/ +# $ ln -s config/Guardfile . +# +# and, you'll have to watch 'config/Guardfile' instead of 'Guardfile' + +# Note: The cmd option is now required due to the increasing number of ways +# rspec may be run, below are examples of the most common uses. +# * bundler: 'bundle exec rspec' +# * bundler binstubs: 'bin/rspec' +# * spring: 'bin/rspec' (This will use spring if running and you have +# installed the spring binstubs per the docs) +# * zeus: 'zeus rspec' (requires the server to be started separately) +# * 'just' rspec: 'rspec' +require 'guard/compat/plugin' + +SPEC_DIRS = ENV.fetch('SPEC_DIRS', 'spec features').split + +Guard::Compat::UI.info("spec_paths are #{SPEC_DIRS}") + +guard_options = { + cmd: 'bundle exec rspec', + # cmd: 'spring crystalball', + # run_all: { cmd: 'CRYSTALBALL=true rspec' }, + all_on_start: true, + failed_mode: :focus, + spec_paths: SPEC_DIRS +} + +guard :rspec, guard_options do + require 'guard/rspec/dsl' + dsl = Guard::RSpec::Dsl.new(self) + + # RSpec files + rspec = dsl.rspec + watch(rspec.spec_helper) { rspec.spec_dir } + watch(rspec.spec_support) { rspec.spec_dir } + watch(rspec.spec_files) + + # Ruby files + ruby = dsl.ruby + dsl.watch_spec_files_for(ruby.lib_files) + + # Capybara features specs + # watch(rails.view_dirs) { |m| rspec.spec.call('features/#{m[1]}') } + # watch(rails.layouts) { |m| rspec.spec.call('features/#{m[1]}') } + + # Turnip features and steps + watch('features') +end diff --git a/bin/guard b/bin/guard new file mode 100755 index 00000000..bcb966f4 --- /dev/null +++ b/bin/guard @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'guard' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("guard", "guard") diff --git a/crystalball.gemspec b/crystalball.gemspec index 5069d505..b5b6e130 100644 --- a/crystalball.gemspec +++ b/crystalball.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'actionview' spec.add_development_dependency 'activerecord' spec.add_development_dependency 'factory_bot' + spec.add_development_dependency 'guard-rspec' spec.add_development_dependency 'i18n' spec.add_development_dependency 'parser' spec.add_development_dependency 'pry' diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..ecc53592 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3.4' + +services: + crystalball: + command: bash -c "bundle install --no-binstubs && bin/guard start --force-polling --watchdir ${SPEC_DIRS:-.}" + build: + context: . + dockerfile: ./docker/Dockerfile + args: + BUNDLER_VERSION: '2.0.2' + RUBY_VERSION: '2.4.4' + image: crystalball + environment: + - EDITOR=micro + - HISTFILE=/crystalball/log/.bash_history + stdin_open: true + tty: true + volumes: + - .:/crystalball:cached + - bundle:/bundle + +volumes: + bundle: diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..5d9e8b6e --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,35 @@ +ARG RUBY_VERSION +FROM ruby:$RUBY_VERSION + +ARG BUNDLER_VERSION + +# Install micro editor +RUN cd /usr/local/bin \ + && curl -sL https://getmic.ro | bash + +# Install dependencies +# RUN apt-get update -qq \ +# && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade \ +# && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ +# build-essential \ +# && apt-get clean \ +# && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ +# && truncate -s 0 /var/log/*log + +# Configure bundler and PATH +ENV LANG=C.UTF-8 \ + GEM_HOME=/bundle \ + BUNDLE_JOBS=4 \ + BUNDLE_RETRY=3 +ENV BUNDLE_PATH $GEM_HOME +ENV BUNDLE_APP_CONFIG=$BUNDLE_PATH \ + BUNDLE_BIN=$BUNDLE_PATH/bin +ENV PATH /crystalball/bin:$BUNDLE_BIN:$PATH + +# Upgrade RubyGems and install required Bundler version +RUN gem update --system && \ + gem install bundler:$BUNDLER_VERSION && \ + git config --global user.email "john.doe@example.com" && \ + git config --global user.name "John Doe" + +WORKDIR /crystalball