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'
gem 'algoliasearch', '1.11'
gem 'appraisal', '~> 2.1.0'
gem 'algolia_html_extractor', '~> 2.0'
gem 'algoliasearch', '~> 1.18'
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 'nokogiri', '~> 1.6'
gem 'verbal_expressions', '~> 0.1.5'

View File

@ -1,47 +1,27 @@
# encoding: utf-8
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts 'Run `bundle install` to install missing gems'
warn e.message
warn 'Run `bundle install` to install missing gems'
exit e.status_code
end
require 'rake'
require 'jeweler'
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
# TEST
require 'rspec/core'
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.pattern = FileList['spec/**/*_spec.rb']
end
task test: :spec
desc 'Code coverage detail'
task :coverage do
ENV['COVERAGE'] = 'true'
Rake::Task['spec'].execute
end
task spec: :test
task default: :test

View File

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

View File

@ -5,9 +5,9 @@ source "http://rubygems.org"
gem "algoliasearch", "1.11"
gem "appraisal", "~> 2.1.0"
gem "awesome_print", "~> 1.6"
gem "json", "~> 1.8"
gem "nokogiri", "~> 1.6"
gem "html-hierarchy-extractor", "~> 1.0"
gem "json", ">= 1.8.6"
gem "nokogiri", "~> 1.6"
gem "verbal_expressions", "~> 0.1.5"
gem "jekyll", "~> 3.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
let(:config) do
{
'source' => fixture_path,
'markdown_ext' => 'md,mkd',
'algolia' => {
'application_id' => 'APPID',
'index_name' => 'INDEXNAME'
}
}
end
let(:checker) { AlgoliaSearchCredentialChecker.new(config) }
describe 'api_key' do
it 'returns nil if no key found' do
# Given
# When
actual = checker.api_key
# Then
expect(actual).to be_nil
end
it 'reads from ENV var if set' do
# Given
stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV')
# When
actual = checker.api_key
# Then
expect(actual).to eq 'APIKEY_FROM_ENV'
end
it 'reads from _algolia_api_key in source if set' do
# Given
checker.config['source'] = File.join(config['source'], 'api_key_dir')
# When
actual = checker.api_key
# Then
expect(actual).to eq 'APIKEY_FROM_FILE'
end
it 'reads from ENV before from file' do
# Given
checker.config['source'] = File.join(config['source'], 'api_key_dir')
stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV')
# When
actual = checker.api_key
# Then
expect(actual).to eq 'APIKEY_FROM_ENV'
end
end
describe 'check_api_key' do
it 'should exit with error if no API key' do
# Given
allow(checker).to receive(:api_key).and_return(nil)
allow(checker.logger).to receive(:display)
# When / Then
expect(-> { checker.check_api_key }).to raise_error SystemExit
end
it 'should do nothing when an API key is found' do
# Given
allow(checker).to receive(:api_key).and_return('APIKEY')
# When / Then
expect(-> { checker.check_api_key }).not_to raise_error
end
end
describe 'application_id' do
it 'reads value from the _config.yml file' do
# Given
# When
actual = checker.application_id
# Then
expect(actual).to eq 'APPID'
end
it 'reads from ENV var if set' do
# Given
stub_const('ENV', 'ALGOLIA_APPLICATION_ID' => 'APPLICATION_ID_FROM_ENV')
# When
actual = checker.application_id
# Then
expect(actual).to eq 'APPLICATION_ID_FROM_ENV'
end
it 'returns nil if no key found' do
# Given
config['algolia']['application_id'] = nil
# When
actual = checker.application_id
# Then
expect(actual).to be_nil
end
end
describe 'check_application_id' do
it 'should exit with error if no application ID' do
# Given
allow(checker).to receive(:application_id).and_return(nil)
allow(checker.logger).to receive(:display)
# When / Then
expect(-> { checker.check_application_id }).to raise_error SystemExit
end
it 'should do nothing when an application ID is found' do
# Given
allow(checker).to receive(:application_id).and_return('APPLICATIONID')
# When / Then
expect(-> { checker.check_application_id }).not_to raise_error
end
end
describe 'index_name' do
it 'reads value from the _config.yml file' do
# Given
# When
actual = checker.index_name
# Then
expect(actual).to eq 'INDEXNAME'
end
it 'reads from ENV var if set' do
# Given
stub_const('ENV', 'ALGOLIA_INDEX_NAME' => 'INDEX_NAME_FROM_ENV')
# When
actual = checker.index_name
# Then
expect(actual).to eq 'INDEX_NAME_FROM_ENV'
end
it 'returns nil if no key found' do
# Given
config['algolia']['index_name'] = nil
# When
actual = checker.index_name
# Then
expect(actual).to be_nil
end
end
describe 'check_index_name' do
it 'should exit with error if no index name' do
# Given
allow(checker).to receive(:index_name).and_return(nil)
allow(checker.logger).to receive(:display)
# When / Then
expect(-> { checker.check_index_name }).to raise_error SystemExit
end
it 'should do nothing when an index name is found' do
# Given
allow(checker).to receive(:index_name).and_return('INDEXNAME')
# When / Then
expect(-> { checker.check_index_name }).not_to raise_error
end
end
describe 'assert_valid' do
before(:each) do
allow(checker.logger).to receive(:display)
end
it 'should display error if no api key' do
# Given
allow(checker).to receive(:api_key).and_return nil
# Then
expect(-> { checker.assert_valid }).to raise_error SystemExit
expect(checker.logger).to have_received(:display).with('api_key_missing')
end
it 'should display error if no application id' do
# Given
checker.config['algolia'] = {
'application_id' => nil,
'index_name' => 'INDEX_NAME'
}
stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV')
# Then
expect(-> { checker.assert_valid }).to raise_error SystemExit
expect(checker.logger)
.to have_received(:display)
.with('application_id_missing')
end
it 'should display error if no index name' do
# Given
checker.config['algolia'] = {
'application_id' => 'APPLICATION_ID',
'index_name' => nil
}
stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV')
# Then
expect(-> { checker.assert_valid }).to raise_error SystemExit
expect(checker.logger)
.to have_received(:display)
.with('index_name_missing')
end
it 'should init the Algolia client' do
# Given
allow(checker).to receive(:application_id).and_return('FOO')
allow(checker).to receive(:api_key).and_return('BAR')
allow(Algolia).to receive(:init)
# When
checker.assert_valid
# Then
expect(Algolia).to have_received(:init).with(
application_id: 'FOO',
api_key: 'BAR'
)
end
end
end
# describe(AlgoliaSearchCredentialChecker) do
# let(:config) do
# {
# 'source' => fixture_path,
# 'markdown_ext' => 'md,mkd',
# 'algolia' => {
# 'application_id' => 'APPID',
# 'index_name' => 'INDEXNAME'
# }
# }
# end
# let(:checker) { AlgoliaSearchCredentialChecker.new(config) }
#
# describe 'api_key' do
# it 'returns nil if no key found' do
# # Given
#
# # When
# actual = checker.api_key
#
# # Then
# expect(actual).to be_nil
# end
#
# it 'reads from ENV var if set' do
# # Given
# stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV')
#
# # When
# actual = checker.api_key
#
# # Then
# expect(actual).to eq 'APIKEY_FROM_ENV'
# end
#
# it 'reads from _algolia_api_key in source if set' do
# # Given
# checker.config['source'] = File.join(config['source'], 'api_key_dir')
#
# # When
# actual = checker.api_key
#
# # Then
# expect(actual).to eq 'APIKEY_FROM_FILE'
# end
#
# it 'reads from ENV before from file' do
# # Given
# checker.config['source'] = File.join(config['source'], 'api_key_dir')
# stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV')
#
# # When
# actual = checker.api_key
#
# # Then
# expect(actual).to eq 'APIKEY_FROM_ENV'
# end
# end
#
# describe 'check_api_key' do
# it 'should exit with error if no API key' do
# # Given
# allow(checker).to receive(:api_key).and_return(nil)
# allow(checker.logger).to receive(:display)
#
# # When / Then
# expect(-> { checker.check_api_key }).to raise_error SystemExit
# end
#
# it 'should do nothing when an API key is found' do
# # Given
# allow(checker).to receive(:api_key).and_return('APIKEY')
#
# # When / Then
# expect(-> { checker.check_api_key }).not_to raise_error
# end
# end
#
# describe 'application_id' do
# it 'reads value from the _config.yml file' do
# # Given
#
# # When
# actual = checker.application_id
#
# # Then
# expect(actual).to eq 'APPID'
# end
#
# it 'reads from ENV var if set' do
# # Given
# stub_const('ENV', 'ALGOLIA_APPLICATION_ID' => 'APPLICATION_ID_FROM_ENV')
#
# # When
# actual = checker.application_id
#
# # Then
# expect(actual).to eq 'APPLICATION_ID_FROM_ENV'
# end
#
# it 'returns nil if no key found' do
# # Given
# config['algolia']['application_id'] = nil
#
# # When
# actual = checker.application_id
#
# # Then
# expect(actual).to be_nil
# end
# end
#
# describe 'check_application_id' do
# it 'should exit with error if no application ID' do
# # Given
# allow(checker).to receive(:application_id).and_return(nil)
# allow(checker.logger).to receive(:display)
#
# # When / Then
# expect(-> { checker.check_application_id }).to raise_error SystemExit
# end
#
# it 'should do nothing when an application ID is found' do
# # Given
# allow(checker).to receive(:application_id).and_return('APPLICATIONID')
#
# # When / Then
# expect(-> { checker.check_application_id }).not_to raise_error
# end
# end
#
# describe 'index_name' do
# it 'reads value from the _config.yml file' do
# # Given
#
# # When
# actual = checker.index_name
#
# # Then
# expect(actual).to eq 'INDEXNAME'
# end
#
# it 'reads from ENV var if set' do
# # Given
# stub_const('ENV', 'ALGOLIA_INDEX_NAME' => 'INDEX_NAME_FROM_ENV')
#
# # When
# actual = checker.index_name
#
# # Then
# expect(actual).to eq 'INDEX_NAME_FROM_ENV'
# end
#
# it 'returns nil if no key found' do
# # Given
# config['algolia']['index_name'] = nil
#
# # When
# actual = checker.index_name
#
# # Then
# expect(actual).to be_nil
# end
# end
# describe 'check_index_name' do
# it 'should exit with error if no index name' do
# # Given
# allow(checker).to receive(:index_name).and_return(nil)
# allow(checker.logger).to receive(:display)
#
# # When / Then
# expect(-> { checker.check_index_name }).to raise_error SystemExit
# end
#
# it 'should do nothing when an index name is found' do
# # Given
# allow(checker).to receive(:index_name).and_return('INDEXNAME')
#
# # When / Then
# expect(-> { checker.check_index_name }).not_to raise_error
# end
# end
#
# describe 'assert_valid' do
# before(:each) do
# allow(checker.logger).to receive(:display)
# end
# it 'should display error if no api key' do
# # Given
# allow(checker).to receive(:api_key).and_return nil
#
# # Then
# expect(-> { checker.assert_valid }).to raise_error SystemExit
# expect(checker.logger).to have_received(:display).with('api_key_missing')
# end
#
# it 'should display error if no application id' do
# # Given
# checker.config['algolia'] = {
# 'application_id' => nil,
# 'index_name' => 'INDEX_NAME'
# }
# stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV')
#
# # Then
# expect(-> { checker.assert_valid }).to raise_error SystemExit
# expect(checker.logger)
# .to have_received(:display)
# .with('application_id_missing')
# end
#
# it 'should display error if no index name' do
# # Given
# checker.config['algolia'] = {
# 'application_id' => 'APPLICATION_ID',
# 'index_name' => nil
# }
# stub_const('ENV', 'ALGOLIA_API_KEY' => 'APIKEY_FROM_ENV')
#
# # Then
# expect(-> { checker.assert_valid }).to raise_error SystemExit
# expect(checker.logger)
# .to have_received(:display)
# .with('index_name_missing')
# end
#
# it 'should init the Algolia client' do
# # Given
# allow(checker).to receive(:application_id).and_return('FOO')
# allow(checker).to receive(:api_key).and_return('BAR')
# allow(Algolia).to receive(:init)
#
# # When
# checker.assert_valid
#
# # Then
# expect(Algolia).to have_received(:init).with(
# application_id: 'FOO',
# api_key: 'BAR'
# )
# end
# end
# end