Skip to content
Please note that GitHub no longer supports your web browser.

We recommend upgrading to the latest Google Chrome or Firefox.

Learn more
Permalink
Browse files

More alignment with Arclight

* Remove old test framework
* Setup rspec
* Setup engine_cart
* Update gemspec
* Update indexer rake task
  • Loading branch information...
ruebot committed Aug 16, 2017
1 parent 4420998 commit b950634e54f1cd733f603b24673a2a6ef8f39313
Showing with 301 additions and 916 deletions.
  1. +12 −0 .eslintrc
  2. +2 −6 .gitignore
  3. +2 −0 .rspec
  4. +66 −0 .rubocop.yml
  5. +5 −0 .solr_wrapper
  6. +54 −0 lib/tasks/index.rake
  7. BIN spec/fixtures/warcs/2013-steacie-hackfest-2015_01_13.warc.gz
  8. BIN spec/fixtures/warcs/YULEARN-2014_12_10.warc.gz
  9. BIN spec/fixtures/warcs/etig-2014_08_13.warc.gz
  10. BIN spec/fixtures/warcs/library_research_roadmap-2014_11_28.warc.gz
  11. BIN spec/fixtures/warcs/test.warc.gz
  12. +31 −0 spec/spec_helper.rb
  13. +2 −0 spec/test_app_templates/Gemfile.extra
  14. +25 −10 spec/test_app_templates/lib/generators/test_app_generator.rb
  15. +16 −0 spec/warclight_spec.rb
  16. +61 −0 tasks/warclight.rake
  17. +0 −6 test/dummy/Rakefile
  18. +0 −5 test/dummy/app/assets/config/manifest.js
  19. 0 test/dummy/app/assets/images/.keep
  20. +0 −13 test/dummy/app/assets/javascripts/application.js
  21. +0 −13 test/dummy/app/assets/javascripts/cable.js
  22. 0 test/dummy/app/assets/javascripts/channels/.keep
  23. +0 −15 test/dummy/app/assets/stylesheets/application.css
  24. +0 −4 test/dummy/app/channels/application_cable/channel.rb
  25. +0 −4 test/dummy/app/channels/application_cable/connection.rb
  26. +0 −3 test/dummy/app/controllers/application_controller.rb
  27. 0 test/dummy/app/controllers/concerns/.keep
  28. +0 −2 test/dummy/app/helpers/application_helper.rb
  29. +0 −2 test/dummy/app/jobs/application_job.rb
  30. +0 −4 test/dummy/app/mailers/application_mailer.rb
  31. +0 −3 test/dummy/app/models/application_record.rb
  32. 0 test/dummy/app/models/concerns/.keep
  33. +0 −14 test/dummy/app/views/layouts/application.html.erb
  34. +0 −13 test/dummy/app/views/layouts/mailer.html.erb
  35. +0 −1 test/dummy/app/views/layouts/mailer.text.erb
  36. +0 −3 test/dummy/bin/bundle
  37. +0 −4 test/dummy/bin/rails
  38. +0 −4 test/dummy/bin/rake
  39. +0 −38 test/dummy/bin/setup
  40. +0 −29 test/dummy/bin/update
  41. +0 −11 test/dummy/bin/yarn
  42. +0 −5 test/dummy/config.ru
  43. +0 −18 test/dummy/config/application.rb
  44. +0 −5 test/dummy/config/boot.rb
  45. +0 −10 test/dummy/config/cable.yml
  46. +0 −25 test/dummy/config/database.yml
  47. +0 −5 test/dummy/config/environment.rb
  48. +0 −54 test/dummy/config/environments/development.rb
  49. +0 −91 test/dummy/config/environments/production.rb
  50. +0 −42 test/dummy/config/environments/test.rb
  51. +0 −6 test/dummy/config/initializers/application_controller_renderer.rb
  52. +0 −14 test/dummy/config/initializers/assets.rb
  53. +0 −7 test/dummy/config/initializers/backtrace_silencers.rb
  54. +0 −5 test/dummy/config/initializers/cookies_serializer.rb
  55. +0 −4 test/dummy/config/initializers/filter_parameter_logging.rb
  56. +0 −16 test/dummy/config/initializers/inflections.rb
  57. +0 −4 test/dummy/config/initializers/mime_types.rb
  58. +0 −14 test/dummy/config/initializers/wrap_parameters.rb
  59. +0 −33 test/dummy/config/locales/en.yml
  60. +0 −56 test/dummy/config/puma.rb
  61. +0 −3 test/dummy/config/routes.rb
  62. +0 −32 test/dummy/config/secrets.yml
  63. +0 −6 test/dummy/config/spring.rb
  64. 0 test/dummy/lib/assets/.keep
  65. 0 test/dummy/log/.keep
  66. +0 −5 test/dummy/package.json
  67. +0 −67 test/dummy/public/404.html
  68. +0 −67 test/dummy/public/422.html
  69. +0 −66 test/dummy/public/500.html
  70. 0 test/dummy/public/apple-touch-icon-precomposed.png
  71. 0 test/dummy/public/apple-touch-icon.png
  72. 0 test/dummy/public/favicon.ico
  73. +0 −8 test/integration/navigation_test.rb
  74. +0 −23 test/test_helper.rb
  75. +0 −7 test/warclight_test.rb
  76. +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"]
}
}
@@ -1,9 +1,3 @@
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/db/*.sqlite3-journal
test/dummy/log/*.log
test/dummy/tmp/
/.bundle/
/.ruby-version
/.yardoc
@@ -13,6 +7,8 @@ test/dummy/tmp/
/doc/
/spec/reports/
/tmp/
log/*.log
pkg/

# rspec failure tracking
.rspec_status
2 .rspec
@@ -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

This file was deleted.

This file was deleted.

No changes.

This file was deleted.

This file was deleted.

No changes.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

No changes.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit b950634

Please sign in to comment.
You can’t perform that action at this time.