aboutsummaryrefslogtreecommitdiffhomepage
path: root/spec/spec_helper.rb
blob: 656e1167a2dc46543554afe8b50fb644dd118b32 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

require 'fileutils'
require 'rspec'
require 'pronto/hlint'

%w[test].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]

  before(:each) do
    allow_any_instance_of(Pronto::Hlint::Runner).to receive(:config_options).and_return(requested_config)

    # make sure the config is actually read in the example
    expect_any_instance_of(Pronto::Hlint::Runner).to receive(:read_config).and_call_original
  end
end