forked from sds/overcommit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsl_spec.rb
More file actions
50 lines (40 loc) · 1.2 KB
/
jsl_spec.rb
File metadata and controls
50 lines (40 loc) · 1.2 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'spec_helper'
describe Overcommit::Hook::PreCommit::Jsl do
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
let(:context) { double('context') }
subject { described_class.new(config, context) }
before do
subject.stub(:applicable_files).and_return(%w[file1.js file2.js])
end
context 'when jsl exits successfully' do
before do
result = double('result')
result.stub(:success?).and_return(true)
subject.stub(:execute).and_return(result)
end
it { should pass }
end
context 'when jsl exits unsucessfully' do
let(:result) { double('result') }
before do
result.stub(:success?).and_return(false)
subject.stub(:execute).and_return(result)
end
context 'and it reports a warning' do
before do
result.stub(:stdout).and_return([
'file1.js(1): lint warning: meaningless block; curly braces have no impact'
].join("\n"))
end
it { should warn }
end
context 'and it reports an error' do
before do
result.stub(:stdout).and_return([
'file1.js(1): SyntaxError: invalid label'
].join("\n"))
end
it { should fail_hook }
end
end
end