File tree 1 file changed +35
-0
lines changed
spec/overcommit/hook/pre_commit
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments