Skip to content

Commit 49ee546

Browse files
indygwynsds
authored andcommitted
added cookstyle unit test
1 parent 577fde9 commit 49ee546

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe Overcommit::Hook::PreCommit::CookStyle do
6+
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
7+
let(:context) { double('context') }
8+
subject { described_class.new(config, context) }
9+
10+
before do
11+
subject.stub(:applicable_files).and_return(%w[file1.rb file2.rb])
12+
end
13+
14+
context 'when cookstyle exits successfully' do
15+
let(:result) { double('result') }
16+
17+
before do
18+
result.stub(success?: true, stderr: '', stdout: '')
19+
subject.stub(:execute).and_return(result)
20+
end
21+
22+
it { should pass }
23+
end
24+
25+
context 'when cookstyle exits unsucessfully' do
26+
let(:result) { double('result') }
27+
28+
before do
29+
result.stub(:success?).and_return(false)
30+
subject.stub(:execute).and_return(result)
31+
end
32+
33+
it { should fail_hook }
34+
end
35+
end

0 commit comments

Comments
 (0)