Skip to content

Commit

Permalink
added cookstyle unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
indygwyn authored and sds committed Feb 26, 2019
1 parent 577fde9 commit 49ee546
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions spec/overcommit/hook/pre_commit/cook_style_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

require 'spec_helper'

describe Overcommit::Hook::PreCommit::CookStyle 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.rb file2.rb])
end

context 'when cookstyle exits successfully' do
let(:result) { double('result') }

before do
result.stub(success?: true, stderr: '', stdout: '')
subject.stub(:execute).and_return(result)
end

it { should pass }
end

context 'when cookstyle exits unsucessfully' do
let(:result) { double('result') }

before do
result.stub(:success?).and_return(false)
subject.stub(:execute).and_return(result)
end

it { should fail_hook }
end
end

0 comments on commit 49ee546

Please sign in to comment.