aboutsummaryrefslogblamecommitdiffhomepage
path: root/spec/spec_helper.rb
blob: c13fe98e8cc9f0be2e677cf65cb7917a2fd0ba91 (plain) (tree)
1
2
3
4
5
6
7
8
9
                   
                
               
                           
 



                                                           
 



                                                                                
   








                                                                                 
require 'fileutils'
require 'byebug'
require 'rspec'
require 'pronto/eslint_npm'

%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" }

    before { FileUtils.mv(git, dot_git) }
    let(:repo) { Pronto::Git::Repository.new("spec/fixtures/#{repo_name}.git") }
    after { FileUtils.mv(dot_git, git) }
  end
end

RSpec.shared_context 'with config', config: true do
  requested_config = metadata[:config].to_yaml

  let(:config_path) { File.join(repo.path.to_s, Pronto::ESLintNpm::CONFIG_FILE) }

  before(:each) { File.write(config_path, requested_config) }
  after(:each) { FileUtils.rm(config_path) }
end