Permalink
Please
sign in to comment.
Browse files
More alignment with Arclight
* Remove old test framework * Setup rspec * Setup engine_cart * Update gemspec * Update indexer rake task
- Loading branch information...
Showing
with
301 additions
and 916 deletions.
- +12 −0 .eslintrc
- +2 −6 .gitignore
- +2 −0 .rspec
- +66 −0 .rubocop.yml
- +5 −0 .solr_wrapper
- +54 −0 lib/tasks/index.rake
- BIN spec/fixtures/warcs/2013-steacie-hackfest-2015_01_13.warc.gz
- BIN spec/fixtures/warcs/YULEARN-2014_12_10.warc.gz
- BIN spec/fixtures/warcs/etig-2014_08_13.warc.gz
- BIN spec/fixtures/warcs/library_research_roadmap-2014_11_28.warc.gz
- BIN spec/fixtures/warcs/test.warc.gz
- +31 −0 spec/spec_helper.rb
- +2 −0 spec/test_app_templates/Gemfile.extra
- +25 −10 spec/test_app_templates/lib/generators/test_app_generator.rb
- +16 −0 spec/warclight_spec.rb
- +61 −0 tasks/warclight.rake
- +0 −6 test/dummy/Rakefile
- +0 −5 test/dummy/app/assets/config/manifest.js
- 0 test/dummy/app/assets/images/.keep
- +0 −13 test/dummy/app/assets/javascripts/application.js
- +0 −13 test/dummy/app/assets/javascripts/cable.js
- 0 test/dummy/app/assets/javascripts/channels/.keep
- +0 −15 test/dummy/app/assets/stylesheets/application.css
- +0 −4 test/dummy/app/channels/application_cable/channel.rb
- +0 −4 test/dummy/app/channels/application_cable/connection.rb
- +0 −3 test/dummy/app/controllers/application_controller.rb
- 0 test/dummy/app/controllers/concerns/.keep
- +0 −2 test/dummy/app/helpers/application_helper.rb
- +0 −2 test/dummy/app/jobs/application_job.rb
- +0 −4 test/dummy/app/mailers/application_mailer.rb
- +0 −3 test/dummy/app/models/application_record.rb
- 0 test/dummy/app/models/concerns/.keep
- +0 −14 test/dummy/app/views/layouts/application.html.erb
- +0 −13 test/dummy/app/views/layouts/mailer.html.erb
- +0 −1 test/dummy/app/views/layouts/mailer.text.erb
- +0 −3 test/dummy/bin/bundle
- +0 −4 test/dummy/bin/rails
- +0 −4 test/dummy/bin/rake
- +0 −38 test/dummy/bin/setup
- +0 −29 test/dummy/bin/update
- +0 −11 test/dummy/bin/yarn
- +0 −5 test/dummy/config.ru
- +0 −18 test/dummy/config/application.rb
- +0 −5 test/dummy/config/boot.rb
- +0 −10 test/dummy/config/cable.yml
- +0 −25 test/dummy/config/database.yml
- +0 −5 test/dummy/config/environment.rb
- +0 −54 test/dummy/config/environments/development.rb
- +0 −91 test/dummy/config/environments/production.rb
- +0 −42 test/dummy/config/environments/test.rb
- +0 −6 test/dummy/config/initializers/application_controller_renderer.rb
- +0 −14 test/dummy/config/initializers/assets.rb
- +0 −7 test/dummy/config/initializers/backtrace_silencers.rb
- +0 −5 test/dummy/config/initializers/cookies_serializer.rb
- +0 −4 test/dummy/config/initializers/filter_parameter_logging.rb
- +0 −16 test/dummy/config/initializers/inflections.rb
- +0 −4 test/dummy/config/initializers/mime_types.rb
- +0 −14 test/dummy/config/initializers/wrap_parameters.rb
- +0 −33 test/dummy/config/locales/en.yml
- +0 −56 test/dummy/config/puma.rb
- +0 −3 test/dummy/config/routes.rb
- +0 −32 test/dummy/config/secrets.yml
- +0 −6 test/dummy/config/spring.rb
- 0 test/dummy/lib/assets/.keep
- 0 test/dummy/log/.keep
- +0 −5 test/dummy/package.json
- +0 −67 test/dummy/public/404.html
- +0 −67 test/dummy/public/422.html
- +0 −66 test/dummy/public/500.html
- 0 test/dummy/public/apple-touch-icon-precomposed.png
- 0 test/dummy/public/apple-touch-icon.png
- 0 test/dummy/public/favicon.ico
- +0 −8 test/integration/navigation_test.rb
- +0 −23 test/test_helper.rb
- +0 −7 test/warclight_test.rb
- +25 −11 warclight.gemspec
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "airbnb-base/legacy", | ||
"globals": { | ||
"jQuery": true, | ||
"$": true, | ||
"Blacklight": true | ||
}, | ||
"rules": { | ||
"no-param-reassign": [2, { "props": false }], | ||
"func-names": ["error", "never"] | ||
} | ||
} |
@@ -0,0 +1,2 @@ | ||
--format documentation | ||
--color |
@@ -0,0 +1,66 @@ | ||
require: rubocop-rspec | ||
|
||
AllCops: | ||
Exclude: | ||
- '.internal_test_app/**/*' | ||
- 'bin/**/*' | ||
- 'db/**/*' | ||
- 'lib/generators/warclight/templates/**/*' | ||
- 'vendor/**/*' | ||
TargetRubyVersion: 2.4 | ||
DisplayCopNames: true | ||
|
||
Rails: | ||
Enabled: true | ||
|
||
Metrics/LineLength: | ||
Max: 120 | ||
Exclude: | ||
- 'Gemfile' | ||
- 'lib/warclight/custom_document.rb' # XPaths get long | ||
- 'lib/warclight/custom_component.rb' # XPaths get long | ||
|
||
Metrics/ModuleLength: | ||
Max: 120 | ||
|
||
Metrics/ClassLength: | ||
Max: 120 | ||
|
||
Metrics/BlockLength: | ||
Exclude: | ||
- !ruby/regexp /\.rake$/ | ||
- 'warclight.gemspec' | ||
- 'spec/**/*' | ||
- 'lib/warclight/custom_document.rb' | ||
|
||
Metrics/MethodLength: | ||
Exclude: | ||
- 'lib/warclight/custom_document.rb' # warclight_field_definitions too long | ||
|
||
Performance/RegexpMatch: | ||
Enabled: false | ||
|
||
Rails/OutputSafety: | ||
Exclude: | ||
- 'app/controllers/concerns/warclight/field_config_helpers.rb' # html_safe needs to be called to mimic BL JOIN behavior | ||
|
||
RSpec/ExampleLength: | ||
Enabled: false | ||
|
||
RSpec/FilePath: | ||
Exclude: | ||
- 'spec/lib/warclight/viewers/oembed_spec.rb' # Default file path is o_embed, and that looks weird | ||
|
||
RSpec/MultipleExpectations: | ||
Enabled: false | ||
|
||
RSpec/NestedGroups: | ||
Max: 4 | ||
|
||
Style/Documentation: | ||
Exclude: | ||
- 'spec/**/*' | ||
- 'lib/warclight.rb' | ||
|
||
Bundler/DuplicatedGem: | ||
Enabled: false |
@@ -0,0 +1,5 @@ | ||
# Place any default configuration for solr_wrapper here | ||
# port: 8983 | ||
collection: | ||
dir: solr/conf/ | ||
name: warclight |
@@ -0,0 +1,54 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'warclight' | ||
require 'benchmark' | ||
|
||
## | ||
# Environment variables for indexing: | ||
# | ||
# REPOSITORY_ID for the repository id/slug to load repository data from | ||
# your configuration (default: none). | ||
# | ||
# REPOSITORY_FILE for the YAML file of your repository configuration | ||
# (default: config/repositories.yml). | ||
# | ||
# SOLR_URL for the location of your Solr instance | ||
# (default: http://127.0.0.1:8983/solr/warclight) | ||
# | ||
namespace :warclight do | ||
desc 'Index a warc, use FILE=<path/to/warc.gz>' | ||
task :index do | ||
raise 'Please specify your warc, ex. FILE=<path/to/warc.gz>' unless ENV['FILE'] | ||
indexer = load_indexer | ||
print "Loading #{ENV['FILE']} into index...\n" | ||
elapsed_time = Benchmark.realtime { indexer.update(ENV['FILE']) } | ||
print "Indexed #{ENV['FILE']} (in #{elapsed_time.round(3)} secs).\n" | ||
end | ||
|
||
desc 'Index a directory of warcs, use DIR=<path/to/directory>' | ||
task :index_dir do | ||
raise 'Please specify your directory, ex. DIR=<path/to/directory>' unless ENV['DIR'] | ||
Dir.glob(File.join(ENV['DIR'], '*.gz')).each do |file| | ||
system("rake warclight:index FILE=#{file}") | ||
end | ||
end | ||
|
||
desc 'Destroy all documents in the index' | ||
task :destroy_index_docs do | ||
puts 'Deleting all documents from index...' | ||
indexer = load_indexer | ||
indexer.delete_all | ||
end | ||
end | ||
|
||
def load_indexer | ||
# hardcoded since we don't have access to Blacklight.connection_config[:url] here | ||
ENV['SOLR_URL'] ||= 'http://127.0.0.1:8983/solr/warclight' | ||
|
||
options = { | ||
document: Warclight::CustomDocument, | ||
component: Warclight::CustomComponent | ||
} | ||
|
||
Warclight::Indexer.new(options) | ||
end |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
ENV['RAILS_ENV'] ||= 'test' | ||
|
||
require 'simplecov' | ||
require 'codecov' | ||
SimpleCov.formatter = SimpleCov::Formatter::Codecov | ||
SimpleCov.start do | ||
add_filter '/.internal_test_app/' | ||
add_filter '/spec/' | ||
end | ||
|
||
require 'engine_cart' | ||
EngineCart.load_application! | ||
|
||
require 'rpsec/rails' | ||
|
||
require 'capybara/poltergeist' | ||
Cabybara.javascript_driver = :poltergeist | ||
Cabybara.default_max_wait_time = 15 | ||
|
||
require 'warclight' | ||
|
||
RSpec.configure do |config| | ||
# Enable flags like --only-failures and --next-failure | ||
config.example_status_persistence_file_path = 'rspec_status' | ||
|
||
config.expect_with :rspec do |c| | ||
c.syntax = :expect | ||
end | ||
end |
@@ -0,0 +1,2 @@ | ||
gem 'blacklight', github: 'projectblacklight/blacklight', branch: 'master' | ||
gem 'blacklight_range_limit', github: 'projectblacklight/blacklight_range_limit', branch: 'blacklight-7' |
@@ -1,14 +1,29 @@ | ||
require 'rails/generators' | ||
# frozen_string_literal: true | ||
|
||
class TestAppGenerator < Rails::Generators::Base | ||
source_root "./spec/test_app_templates" | ||
require 'rails/generators' | ||
|
||
# if you need to generate any additional configuration | ||
# into the test app, this generator will be run immediately | ||
# after setting up the application | ||
class TestAppGenerator < Rails::Generators::Base | ||
source_root "./spec/test_app_templates" | ||
|
||
def install_engine | ||
generate 'warclight:install' | ||
end | ||
end | ||
# if you need to generate any additional configuration | ||
# into the test app, this generator will be run immediately | ||
# after setting up the application | ||
|
||
def add_gems | ||
# gem 'blacklight', '~> 6.0' # Leave commented out until Blacklight 7 drops | ||
|
||
Bundler.with_clean_env do | ||
run 'bundle install' | ||
end | ||
end | ||
|
||
def run_blacklight_generator | ||
say_status('warning', 'GENERATING BL', :yellow) | ||
generate 'blacklight:install', '--devise' | ||
end | ||
|
||
def install_engine | ||
generate 'warclight:install' | ||
end | ||
end | ||
|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe Warclight do | ||
it 'has a version number' do | ||
expect(Warclight::VERSION).not_to be nil | ||
end | ||
describe 'Custom CatalogController field accessors' do | ||
subject(:custom_fields) do | ||
Warclight::Engine.config.catalog_controller_field_accessors | ||
end | ||
|
||
it { expect(custom_fields).to include :host, :crawl_date } | ||
end | ||
end |
@@ -0,0 +1,61 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'solr_wrapper' | ||
require 'engine_cart/rake_task' | ||
require 'rspec/core/rake_task' | ||
require 'warclight' | ||
|
||
EngineCart.fingerprint_proc = EngineCart.rails_fingerprint_proc | ||
|
||
desc 'Run test suite' | ||
task ci: %w[warclight:generate] do | ||
SolrWrapper.wrap do |solr| | ||
solr.with_collection do | ||
Rake::Task['warclight:seed'].invoke | ||
within_test_app do | ||
## Do stuff inside warclight app here | ||
end | ||
Rake::Task['spec'].invoke | ||
end | ||
end | ||
end | ||
|
||
desc 'Run Eslint' | ||
task :eslint do | ||
system './node_modules/.bin/eslint app/assets/javascripts' | ||
end | ||
|
||
namespace :warclight do | ||
desc 'Generate a test application' | ||
task generate: %w[engine_cart:generate] | ||
|
||
desc 'Run Solr and Blacklight for interactive development' | ||
task :server, %i[rails_server_args] do |_t, args| | ||
if File.exist? EngineCart.destination | ||
within_test_app do | ||
system 'bundle update' | ||
end | ||
else | ||
Rake::Task['engine_cart:generate'].invoke | ||
end | ||
|
||
print 'Starting Solr...' | ||
SolrWrapper.wrap do |solr| | ||
puts 'done.' | ||
solr.with_collection do | ||
Rake::Task['warclight:seed'].invoke | ||
within_test_app do | ||
system "bundle exec rails s #{args[:rails_server_args]}" | ||
end | ||
end | ||
end | ||
end | ||
|
||
desc 'Seed fixture data to Solr' | ||
task :seed do | ||
puts 'Seeding index with data from spec/fixtures/warcs/...' | ||
Dir.glob('spec/fixtures/warcs/*.gz').each do |file| | ||
system("FILE=#{file} rake warclight:index") # no REPOSITORY_ID | ||
end | ||
end | ||
end |
No changes.
No changes.
No changes.
Oops, something went wrong.
0 comments on commit
b950634