]> git.immae.eu Git - github/fretlink/pronto-hlint.git/blobdiff - spec/spec_helper.rb
added ability to set config opts to eslint (#9)
[github/fretlink/pronto-hlint.git] / spec / spec_helper.rb
index 72a128b117866f826aa0d78b08fefe48d29889dd..e147ea7386a56cf01c27046f97c93ec40fae1bff 100644 (file)
@@ -1,9 +1,11 @@
+# frozen_string_literal: true
+
 require 'fileutils'
+require 'byebug'
 require 'rspec'
-require 'rspec/its'
 require 'pronto/eslint_npm'
 
-%w(test eslintignore).each do |repo_name|
+%w[test eslintignore].each do |repo_name|
   RSpec.shared_context "#{repo_name} repo" do
     let(:git) { "spec/fixtures/#{repo_name}.git/git" }
     let(:dot_git) { "spec/fixtures/#{repo_name}.git/.git" }
@@ -13,3 +15,14 @@ require 'pronto/eslint_npm'
     after { FileUtils.mv(dot_git, git) }
   end
 end
+
+RSpec.shared_context 'with config', config: true do
+  requested_config = metadata[:config]
+
+  before(:each) do
+    allow_any_instance_of(Pronto::ESLintNpm).to receive(:config_options).and_return(requested_config)
+
+    # make sure the config is actually read in the example
+    expect_any_instance_of(Pronto::ESLintNpm).to receive(:read_config).and_call_original
+  end
+end