Update gemsepc

This commit is contained in:
Pixelastic 2017-11-07 12:00:55 +01:00
parent 20bbba9898
commit 94f182cbc9
5 changed files with 264 additions and 282 deletions

View File

@ -1,9 +1,10 @@
source 'http://rubygems.org' source 'http://rubygems.org'
gem 'algoliasearch', '1.11' gem 'algolia_html_extractor', '~> 2.0'
gem 'appraisal', '~> 2.1.0' gem 'algoliasearch', '~> 1.18'
gem 'awesome_print', '~> 1.6' gem 'awesome_print', '~> 1.6'
gem 'html-hierarchy-extractor', '~> 1.0' gem 'jekyll', '~> 3.0'
gem 'jekyll-paginate', '~> 1.1.0'
gem 'json', '>= 1.8.6' gem 'json', '>= 1.8.6'
gem 'nokogiri', '~> 1.6' gem 'nokogiri', '~> 1.6'
gem 'verbal_expressions', '~> 0.1.5' gem 'verbal_expressions', '~> 0.1.5'

View File

@ -1,47 +1,27 @@
# encoding: utf-8
require 'rubygems' require 'rubygems'
require 'bundler' require 'bundler'
begin begin
Bundler.setup(:default, :development) Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e rescue Bundler::BundlerError => e
$stderr.puts e.message warn e.message
$stderr.puts 'Run `bundle install` to install missing gems' warn 'Run `bundle install` to install missing gems'
exit e.status_code exit e.status_code
end end
require 'rake' require 'rake'
require 'jeweler' # TEST
require_relative 'lib/version'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see
# http://guides.rubygems.org/specification-reference/ for more options
gem.name = 'algoliasearch-jekyll'
gem.version = AlgoliaSearchJekyllVersion.to_s
gem.homepage = 'https://github.com/algolia/algoliasearch-jekyll'
gem.license = 'MIT'
gem.summary = 'AlgoliaSearch for Jekyll'
gem.description = 'Index all your pages and posts to an Algolia index with ' \
'`jekyll algolia push`'
gem.email = 'tim@pixelastic.com'
gem.authors = ['Tim Carry']
# dependencies defined in Gemfile
end
Jeweler::RubygemsDotOrgTasks.new
require 'rspec/core' require 'rspec/core'
require 'rspec/core/rake_task' require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec| desc 'Run tests (with simple progress)'
RSpec::Core::RakeTask.new(:test) do |spec|
spec.rspec_opts = '--color --format progress'
spec.pattern = FileList['spec/credential_checker_spec.rb']
end
desc 'Run tests (with full details)'
RSpec::Core::RakeTask.new(:test_details) do |spec|
spec.rspec_opts = '--color --format documentation' spec.rspec_opts = '--color --format documentation'
spec.pattern = FileList['spec/**/*_spec.rb'] spec.pattern = FileList['spec/**/*_spec.rb']
end end
task test: :spec task spec: :test
desc 'Code coverage detail'
task :coverage do
ENV['COVERAGE'] = 'true'
Rake::Task['spec'].execute
end
task default: :test task default: :test

View File

@ -5,9 +5,9 @@ source "http://rubygems.org"
gem "algoliasearch", "1.11" gem "algoliasearch", "1.11"
gem "appraisal", "~> 2.1.0" gem "appraisal", "~> 2.1.0"
gem "awesome_print", "~> 1.6" gem "awesome_print", "~> 1.6"
gem "json", "~> 1.8"
gem "nokogiri", "~> 1.6"
gem "html-hierarchy-extractor", "~> 1.0" gem "html-hierarchy-extractor", "~> 1.0"
gem "json", ">= 1.8.6"
gem "nokogiri", "~> 1.6"
gem "verbal_expressions", "~> 0.1.5" gem "verbal_expressions", "~> 0.1.5"
gem "jekyll", "~> 2.5" gem "jekyll", "~> 2.5"

View File

@ -5,9 +5,9 @@ source "http://rubygems.org"
gem "algoliasearch", "1.11" gem "algoliasearch", "1.11"
gem "appraisal", "~> 2.1.0" gem "appraisal", "~> 2.1.0"
gem "awesome_print", "~> 1.6" gem "awesome_print", "~> 1.6"
gem "json", "~> 1.8"
gem "nokogiri", "~> 1.6"
gem "html-hierarchy-extractor", "~> 1.0" gem "html-hierarchy-extractor", "~> 1.0"
gem "json", ">= 1.8.6"
gem "nokogiri", "~> 1.6"
gem "verbal_expressions", "~> 0.1.5" gem "verbal_expressions", "~> 0.1.5"
gem "jekyll", "~> 3.0" gem "jekyll", "~> 3.0"
gem "jekyll-paginate", "~> 1.1.0" gem "jekyll-paginate", "~> 1.1.0"

View File

@ -1,245 +1,246 @@
require 'spec_helper' require 'algolia_html_extractor'
# require 'spec_helper'
describe(AlgoliaSearchCredentialChecker) do # describe(AlgoliaSearchCredentialChecker) do
let(:config) do # let(:config) do
{ # {
'source' => fixture_path, # 'source' => fixture_path,
'markdown_ext' => 'md,mkd', # 'markdown_ext' => 'md,mkd',
'algolia' => { # 'algolia' => {
'application_id' => 'APPID', # 'application_id' => 'APPID',
'index_name' => 'INDEXNAME' # 'index_name' => 'INDEXNAME'
} # }
} # }
end # end
let(:checker) { AlgoliaSearchCredentialChecker.new(config) } # let(:checker) { AlgoliaSearchCredentialChecker.new(config) }
#
describe 'api_key' do # describe 'api_key' do
it 'returns nil if no key found' do # it 'returns nil if no key found' do
# Given # # Given
#
# When # # When
actual = checker.api_key # actual = checker.api_key
#
# Then # # Then
expect(actual).to be_nil # expect(actual).to be_nil
end # end
#
it 'reads from ENV var if set' do # it 'reads from ENV var if set' do
# Given # # Given
stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV') # stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV')
#
# When # # When
actual = checker.api_key # actual = checker.api_key
#
# Then # # Then
expect(actual).to eq 'APIKEY_FROM_ENV' # expect(actual).to eq 'APIKEY_FROM_ENV'
end # end
#
it 'reads from _algolia_api_key in source if set' do # it 'reads from _algolia_api_key in source if set' do
# Given # # Given
checker.config['source'] = File.join(config['source'], 'api_key_dir') # checker.config['source'] = File.join(config['source'], 'api_key_dir')
#
# When # # When
actual = checker.api_key # actual = checker.api_key
#
# Then # # Then
expect(actual).to eq 'APIKEY_FROM_FILE' # expect(actual).to eq 'APIKEY_FROM_FILE'
end # end
#
it 'reads from ENV before from file' do # it 'reads from ENV before from file' do
# Given # # Given
checker.config['source'] = File.join(config['source'], 'api_key_dir') # checker.config['source'] = File.join(config['source'], 'api_key_dir')
stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV') # stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV')
#
# When # # When
actual = checker.api_key # actual = checker.api_key
#
# Then # # Then
expect(actual).to eq 'APIKEY_FROM_ENV' # expect(actual).to eq 'APIKEY_FROM_ENV'
end # end
end # end
#
describe 'check_api_key' do # describe 'check_api_key' do
it 'should exit with error if no API key' do # it 'should exit with error if no API key' do
# Given # # Given
allow(checker).to receive(:api_key).and_return(nil) # allow(checker).to receive(:api_key).and_return(nil)
allow(checker.logger).to receive(:display) # allow(checker.logger).to receive(:display)
#
# When / Then # # When / Then
expect(-> { checker.check_api_key }).to raise_error SystemExit # expect(-> { checker.check_api_key }).to raise_error SystemExit
end # end
#
it 'should do nothing when an API key is found' do # it 'should do nothing when an API key is found' do
# Given # # Given
allow(checker).to receive(:api_key).and_return('APIKEY') # allow(checker).to receive(:api_key).and_return('APIKEY')
#
# When / Then # # When / Then
expect(-> { checker.check_api_key }).not_to raise_error # expect(-> { checker.check_api_key }).not_to raise_error
end # end
end # end
#
describe 'application_id' do # describe 'application_id' do
it 'reads value from the _config.yml file' do # it 'reads value from the _config.yml file' do
# Given # # Given
#
# When # # When
actual = checker.application_id # actual = checker.application_id
#
# Then # # Then
expect(actual).to eq 'APPID' # expect(actual).to eq 'APPID'
end # end
#
it 'reads from ENV var if set' do # it 'reads from ENV var if set' do
# Given # # Given
stub_const('ENV', 'ALGOLIA_APPLICATION_ID' => 'APPLICATION_ID_FROM_ENV') # stub_const('ENV', 'ALGOLIA_APPLICATION_ID' => 'APPLICATION_ID_FROM_ENV')
#
# When # # When
actual = checker.application_id # actual = checker.application_id
#
# Then # # Then
expect(actual).to eq 'APPLICATION_ID_FROM_ENV' # expect(actual).to eq 'APPLICATION_ID_FROM_ENV'
end # end
#
it 'returns nil if no key found' do # it 'returns nil if no key found' do
# Given # # Given
config['algolia']['application_id'] = nil # config['algolia']['application_id'] = nil
#
# When # # When
actual = checker.application_id # actual = checker.application_id
#
# Then # # Then
expect(actual).to be_nil # expect(actual).to be_nil
end # end
end # end
#
describe 'check_application_id' do # describe 'check_application_id' do
it 'should exit with error if no application ID' do # it 'should exit with error if no application ID' do
# Given # # Given
allow(checker).to receive(:application_id).and_return(nil) # allow(checker).to receive(:application_id).and_return(nil)
allow(checker.logger).to receive(:display) # allow(checker.logger).to receive(:display)
#
# When / Then # # When / Then
expect(-> { checker.check_application_id }).to raise_error SystemExit # expect(-> { checker.check_application_id }).to raise_error SystemExit
end # end
#
it 'should do nothing when an application ID is found' do # it 'should do nothing when an application ID is found' do
# Given # # Given
allow(checker).to receive(:application_id).and_return('APPLICATIONID') # allow(checker).to receive(:application_id).and_return('APPLICATIONID')
#
# When / Then # # When / Then
expect(-> { checker.check_application_id }).not_to raise_error # expect(-> { checker.check_application_id }).not_to raise_error
end # end
end # end
#
describe 'index_name' do # describe 'index_name' do
it 'reads value from the _config.yml file' do # it 'reads value from the _config.yml file' do
# Given # # Given
#
# When # # When
actual = checker.index_name # actual = checker.index_name
#
# Then # # Then
expect(actual).to eq 'INDEXNAME' # expect(actual).to eq 'INDEXNAME'
end # end
#
it 'reads from ENV var if set' do # it 'reads from ENV var if set' do
# Given # # Given
stub_const('ENV', 'ALGOLIA_INDEX_NAME' => 'INDEX_NAME_FROM_ENV') # stub_const('ENV', 'ALGOLIA_INDEX_NAME' => 'INDEX_NAME_FROM_ENV')
#
# When # # When
actual = checker.index_name # actual = checker.index_name
#
# Then # # Then
expect(actual).to eq 'INDEX_NAME_FROM_ENV' # expect(actual).to eq 'INDEX_NAME_FROM_ENV'
end # end
#
it 'returns nil if no key found' do # it 'returns nil if no key found' do
# Given # # Given
config['algolia']['index_name'] = nil # config['algolia']['index_name'] = nil
#
# When # # When
actual = checker.index_name # actual = checker.index_name
#
# Then # # Then
expect(actual).to be_nil # expect(actual).to be_nil
end # end
end # end
describe 'check_index_name' do # describe 'check_index_name' do
it 'should exit with error if no index name' do # it 'should exit with error if no index name' do
# Given # # Given
allow(checker).to receive(:index_name).and_return(nil) # allow(checker).to receive(:index_name).and_return(nil)
allow(checker.logger).to receive(:display) # allow(checker.logger).to receive(:display)
#
# When / Then # # When / Then
expect(-> { checker.check_index_name }).to raise_error SystemExit # expect(-> { checker.check_index_name }).to raise_error SystemExit
end # end
#
it 'should do nothing when an index name is found' do # it 'should do nothing when an index name is found' do
# Given # # Given
allow(checker).to receive(:index_name).and_return('INDEXNAME') # allow(checker).to receive(:index_name).and_return('INDEXNAME')
#
# When / Then # # When / Then
expect(-> { checker.check_index_name }).not_to raise_error # expect(-> { checker.check_index_name }).not_to raise_error
end # end
end # end
#
describe 'assert_valid' do # describe 'assert_valid' do
before(:each) do # before(:each) do
allow(checker.logger).to receive(:display) # allow(checker.logger).to receive(:display)
end # end
it 'should display error if no api key' do # it 'should display error if no api key' do
# Given # # Given
allow(checker).to receive(:api_key).and_return nil # allow(checker).to receive(:api_key).and_return nil
#
# Then # # Then
expect(-> { checker.assert_valid }).to raise_error SystemExit # expect(-> { checker.assert_valid }).to raise_error SystemExit
expect(checker.logger).to have_received(:display).with('api_key_missing') # expect(checker.logger).to have_received(:display).with('api_key_missing')
end # end
#
it 'should display error if no application id' do # it 'should display error if no application id' do
# Given # # Given
checker.config['algolia'] = { # checker.config['algolia'] = {
'application_id' => nil, # 'application_id' => nil,
'index_name' => 'INDEX_NAME' # 'index_name' => 'INDEX_NAME'
} # }
stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV') # stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV')
#
# Then # # Then
expect(-> { checker.assert_valid }).to raise_error SystemExit # expect(-> { checker.assert_valid }).to raise_error SystemExit
expect(checker.logger) # expect(checker.logger)
.to have_received(:display) # .to have_received(:display)
.with('application_id_missing') # .with('application_id_missing')
end # end
#
it 'should display error if no index name' do # it 'should display error if no index name' do
# Given # # Given
checker.config['algolia'] = { # checker.config['algolia'] = {
'application_id' => 'APPLICATION_ID', # 'application_id' => 'APPLICATION_ID',
'index_name' => nil # 'index_name' => nil
} # }
stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV') # stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV')
#
# Then # # Then
expect(-> { checker.assert_valid }).to raise_error SystemExit # expect(-> { checker.assert_valid }).to raise_error SystemExit
expect(checker.logger) # expect(checker.logger)
.to have_received(:display) # .to have_received(:display)
.with('index_name_missing') # .with('index_name_missing')
end # end
#
it 'should init the Algolia client' do # it 'should init the Algolia client' do
# Given # # Given
allow(checker).to receive(:application_id).and_return('FOO') # allow(checker).to receive(:application_id).and_return('FOO')
allow(checker).to receive(:api_key).and_return('BAR') # allow(checker).to receive(:api_key).and_return('BAR')
allow(Algolia).to receive(:init) # allow(Algolia).to receive(:init)
#
# When # # When
checker.assert_valid # checker.assert_valid
#
# Then # # Then
expect(Algolia).to have_received(:init).with( # expect(Algolia).to have_received(:init).with(
application_id: 'FOO', # application_id: 'FOO',
api_key: 'BAR' # api_key: 'BAR'
) # )
end # end
end # end
end # end