diff --git a/.travis.yml b/.travis.yml index 9b9f30491..c68ce91f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,11 +11,12 @@ cache: yarn: true install: - - gem install rubocop + - bundle install - nvm install node - node -v - npm i -g yarn - yarn script: - yarn lint - - rubocop + - bundle exec rubocop + - bundle exec rake test diff --git a/Gemfile b/Gemfile index b4e2a20bb..1f00b8752 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,11 @@ source "https://rubygems.org" gemspec + +gem "rails" +gem "rake", ">= 11.1" +gem "rubocop", ">= 0.47", require: false + +group :test do + gem "minitest", "~> 5.0" +end diff --git a/Gemfile.lock b/Gemfile.lock index e9889f7c5..9e918811f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,6 +9,16 @@ PATH GEM remote: https://rubygems.org/ specs: + actioncable (5.0.1) + actionpack (= 5.0.1) + nio4r (~> 1.2) + websocket-driver (~> 0.6.1) + actionmailer (5.0.1) + actionpack (= 5.0.1) + actionview (= 5.0.1) + activejob (= 5.0.1) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) actionpack (5.0.1) actionview (= 5.0.1) activesupport (= 5.0.1) @@ -22,26 +32,60 @@ GEM erubis (~> 2.7.0) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) + activejob (5.0.1) + activesupport (= 5.0.1) + globalid (>= 0.3.6) + activemodel (5.0.1) + activesupport (= 5.0.1) + activerecord (5.0.1) + activemodel (= 5.0.1) + activesupport (= 5.0.1) + arel (~> 7.0) activesupport (5.0.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) tzinfo (~> 1.1) + arel (7.1.4) + ast (2.3.0) builder (3.2.3) concurrent-ruby (1.0.5) erubis (2.7.0) + globalid (0.3.7) + activesupport (>= 4.1.0) i18n (0.8.1) loofah (2.0.3) nokogiri (>= 1.5.9) + mail (2.6.4) + mime-types (>= 1.16, < 4) method_source (0.8.2) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) mini_portile2 (2.1.0) minitest (5.10.1) multi_json (1.12.1) + nio4r (1.2.1) nokogiri (1.7.0.1) mini_portile2 (~> 2.1.0) + parser (2.4.0.0) + ast (~> 2.2) + powerpack (0.1.1) rack (2.0.1) rack-test (0.6.3) rack (>= 1.0) + rails (5.0.1) + actioncable (= 5.0.1) + actionmailer (= 5.0.1) + actionpack (= 5.0.1) + actionview (= 5.0.1) + activejob (= 5.0.1) + activemodel (= 5.0.1) + activerecord (= 5.0.1) + activesupport (= 5.0.1) + bundler (>= 1.3.0, < 2.0) + railties (= 5.0.1) + sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.2) activesupport (>= 4.2.0, < 6.0) nokogiri (~> 1.6) @@ -53,17 +97,40 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) + rainbow (2.2.1) rake (12.0.0) + rubocop (0.47.1) + parser (>= 2.3.3.1, < 3.0) + powerpack (~> 0.1) + rainbow (>= 1.99.1, < 3.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + ruby-progressbar (1.8.1) + sprockets (3.7.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.0) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) thor (0.19.4) thread_safe (0.3.6) tzinfo (1.2.2) thread_safe (~> 0.1) + unicode-display_width (1.1.3) + websocket-driver (0.6.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.2) PLATFORMS ruby DEPENDENCIES bundler (~> 1.12) + minitest (~> 5.0) + rails + rake (>= 11.1) + rubocop (>= 0.47) webpacker! BUNDLED WITH diff --git a/Rakefile b/Rakefile index 29955274e..249c285eb 100644 --- a/Rakefile +++ b/Rakefile @@ -1 +1,12 @@ +# frozen_string_literal: true require "bundler/gem_tasks" +require "rake/testtask" + +Rake::TestTask.new(:test) do |t| + t.libs << "test" + t.libs << "lib" + t.test_files = FileList["test/**/*_test.rb"] + t.verbose = true +end + +task default: :test diff --git a/test/env_test.rb b/test/env_test.rb new file mode 100644 index 000000000..25255598e --- /dev/null +++ b/test/env_test.rb @@ -0,0 +1,16 @@ +require "webpacker_test" + +class EnvTest < Minitest::Test + def test_current_env + assert_equal Webpacker::Env.current, "production" + end + + def test_env_is_development? + refute_predicate Webpacker::Env, :development? + end + + def test_file_path + correct_path = File.join(File.dirname(__FILE__), "config", "webpack", "paths.yml").to_s + assert_equal Webpacker::Env.file_path.to_s, correct_path + end +end diff --git a/test/webpacker_test.rb b/test/webpacker_test.rb new file mode 100644 index 000000000..dddcdb800 --- /dev/null +++ b/test/webpacker_test.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require "minitest/autorun" +require "rails" +require "rails/test_help" +require "webpacker" + +module TestApp + class Application < ::Rails::Application + config.root = File.dirname(__FILE__) + end +end + +TestApp::Application.initialize!