diff --git a/Rakefile b/Rakefile index 42dd2da..eab2937 100644 --- a/Rakefile +++ b/Rakefile @@ -22,6 +22,10 @@ RSpec::Core::RakeTask.new(:test_details) do |spec| spec.rspec_opts = '--color --format documentation' spec.pattern = FileList['spec/*_spec.rb'] end +desc 'Run tests in all Ruby versions (with full details)' +RSpec::Core::RakeTask.new(:test_all_ruby_versions) do + sh './scripts/test_all_ruby_versions' +end # WATCH desc 'Watch for changes in files and reload tests' diff --git a/jeremy.rb b/jeremy.rb new file mode 100644 index 0000000..a24735f --- /dev/null +++ b/jeremy.rb @@ -0,0 +1,30 @@ +module AlgoliaPlugin + def self.do_something(config) + site = Jekyll::Site.new(config) + site.process + end +end + +describe 'AlgoliaPlugin' do + it 'should create a new site with the config passed' do + # Given + config = { foo: 'bar' } + + # When + AlgoliaPlugin.do_something(config) + + # Then + # ??? + # expect(Jekyll::Site).to receive(:new).with(input) <= Does not work because + # I haven't allowed listening to it + # + # mock_site = double('Jekyll::Site', process: nil) + # allow(Jekyll::Site).to receive(:new).and_return(mock_site) <= Ok, I can + # call the method without failing but the expect does not work + # + # Only thing that works is writing the full expect (including + # with/and_return) from the start, but that has me writing my expectation at + # the beginning... + # + end +end diff --git a/lib/jekyll-algolia.rb b/lib/jekyll-algolia.rb index dd4c7a2..f7905a3 100644 --- a/lib/jekyll-algolia.rb +++ b/lib/jekyll-algolia.rb @@ -1,13 +1,19 @@ require 'jekyll/commands/algolia' module Jekyll - # Main Algolia module entrypoint + # Requirable file, loading all dependencies. + # Methods here are called by the main `jekyll algolia` command module Algolia + # Holds the current plugin version require 'jekyll/algolia/version' + # Extracts records from Jekyll files require 'jekyll/algolia/extractor' + # Read configuration options require 'jekyll/algolia/configurator' + # Push records to Algolia require 'jekyll/algolia/indexer' + # Public: Init the Algolia module # # config - A hash of Jekyll config option (merge of _config.yml options and @@ -67,4 +73,3 @@ module Jekyll end end end - diff --git a/lib/credential_checker.rb b/lib_old/credential_checker.rb similarity index 100% rename from lib/credential_checker.rb rename to lib_old/credential_checker.rb diff --git a/lib/error_handler.rb b/lib_old/error_handler.rb similarity index 100% rename from lib/error_handler.rb rename to lib_old/error_handler.rb diff --git a/lib/push.rb b/lib_old/push.rb similarity index 100% rename from lib/push.rb rename to lib_old/push.rb diff --git a/lib/record_extractor.rb b/lib_old/record_extractor.rb similarity index 100% rename from lib/record_extractor.rb rename to lib_old/record_extractor.rb diff --git a/lib/utils.rb b/lib_old/utils.rb similarity index 100% rename from lib/utils.rb rename to lib_old/utils.rb diff --git a/scripts/test_all_ruby_versions b/scripts/test_all_ruby_versions index 41b1fc2..941184f 100755 --- a/scripts/test_all_ruby_versions +++ b/scripts/test_all_ruby_versions @@ -9,12 +9,12 @@ for version in "${versions[@]}"; do # Install this ruby version if not yet installed if [[ "$installed_version" != *"$version"* ]]; then echo "$version not found, installing it" - rvm install $version + rvm install "$version" fi echo "Updating dependencies" - rvm $version exec bundle install + rvm "$version" exec bundle install echo "Running tests" - rvm $version exec bundle exec rake test + rvm "$version" exec bundle exec rake test_details done diff --git a/spec/old/credential_checker_spec.rb b/spec_old/credential_checker_spec.rb similarity index 100% rename from spec/old/credential_checker_spec.rb rename to spec_old/credential_checker_spec.rb diff --git a/spec/old/error_handler_spec.rb b/spec_old/error_handler_spec.rb similarity index 100% rename from spec/old/error_handler_spec.rb rename to spec_old/error_handler_spec.rb diff --git a/spec/old/push_spec.rb b/spec_old/push_spec.rb similarity index 100% rename from spec/old/push_spec.rb rename to spec_old/push_spec.rb diff --git a/spec/old/record_extractor_spec.rb b/spec_old/record_extractor_spec.rb similarity index 100% rename from spec/old/record_extractor_spec.rb rename to spec_old/record_extractor_spec.rb