diff --git a/.gitignore b/.gitignore index 5976a3f..36766d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ Gemfile.lock +.envrc pkg/ coverage/ docs-dev/ diff --git a/Rakefile b/Rakefile index 55a78df..bb9900d 100644 --- a/Rakefile +++ b/Rakefile @@ -9,10 +9,13 @@ rescue Bundler::BundlerError => e warn 'Run `bundle install` to install missing gems' exit e.status_code end +require 'algoliasearch' require 'rake' +require 'rspec/core' +require 'rspec/core/rake_task' +require 'rubocop/rake_task' # LINT -require 'rubocop/rake_task' desc 'Check files for linting issues' RuboCop::RakeTask.new(:lint) do |task| task.patterns = [ @@ -26,8 +29,6 @@ RuboCop::RakeTask.new(:lint) do |task| end # TEST -require 'rspec/core' -require 'rspec/core/rake_task' desc 'Run unit tests' RSpec::Core::RakeTask.new(:test) do |task| task.rspec_opts = '--color --format progress' @@ -70,6 +71,14 @@ namespace 'test' do task :watch do puts 'Please, run ./scripts/test_integration_watch manually' end + # Delete the test index + task :_delete_index do + Algolia.init( + application_id: ENV['ALGOLIA_APPLICATION_ID'], + api_key: ENV['ALGOLIA_API_KEY'] + ) + Algolia::Index.new(ENV['ALGOLIA_INDEX_NAME']).delete_index! + end task :_run do end task :_watch_run do diff --git a/scripts/test_integration_prepare b/scripts/test_integration_prepare index f6c4c13..899633a 100755 --- a/scripts/test_integration_prepare +++ b/scripts/test_integration_prepare @@ -1,7 +1,24 @@ #!/usr/bin/env bash set -e +if [[ -z "$ALGOLIA_APPLICATION_ID" ]]; then + echo "You need to set ALGOLIA_APPLICATION_ID" + exit 1 +fi +if [[ -z "$ALGOLIA_API_KEY" ]]; then + echo "You need to set ALGOLIA_API_KEY" + exit 1 +fi +if [[ -z "$ALGOLIA_INDEX_NAME" ]]; then + echo "You need to set ALGOLIA_INDEX_NAME" + exit 1 +fi + + cd ./spec/site bundle install --quiet + bundle exec jekyll build + +rake test:integration:_delete_index bundle exec jekyll algolia