Skip to content

Commit e9a9559

Browse files
author
Shane da Silva
committed
Add image_optim as a development dependency
Since we have to `require 'image_optim'` in our tests anyway, add the `image_optim` gem as a development dependency and remove the class stub. This still ensures that `overcommit` is decoupled from `image_optim` for users of Overcommit. For developers, however, it is reasonable to expect them to have the dependencies of all supported checks so they can run tests in development. Also converted some double quotes to single quotes in specs. Change-Id: I63170434619f5580e3f79ccc7aa6788101e4ca0d Reviewed-on: https://gerrit.causes.com/30493 Tested-by: jenkins <jenkins@causes.com> Reviewed-by: Shane da Silva <shane@causes.com>
1 parent 0f8056b commit e9a9559

File tree

5 files changed

+12
-16
lines changed

5 files changed

+12
-16
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Overcommit Changelog
22

3+
## master (unreleased)
4+
5+
* Added pre-commit check that optimizes images with `image_optim`
6+
37
## 0.3.2
48

59
* Fix bug where `.rubocop.yml` would not be found in present working directory

overcommit.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ Gem::Specification.new do |s|
2222
Dir['config/*.yml']
2323

2424
s.add_development_dependency 'rspec', '2.13.0'
25+
s.add_development_dependency 'image_optim', '0.9.1'
2526
end

spec/image_optim.rb

-9
This file was deleted.

spec/plugins/pre_commit/image_optimization/image_set_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
22

33
describe Overcommit::GitHook::ImageOptimization::ImageSet do
4-
describe "#initialize(image_paths)" do
4+
describe '#initialize(image_paths)' do
55
let(:path) { '/tmp/filename.jpg20131024-7103-s1d6n9.jpg' }
66

77
it "sets the image_paths of the image set" do
@@ -10,12 +10,12 @@
1010
end
1111
end
1212

13-
describe "#optimize_with(ImageOptim)" do
13+
describe '#optimize_with(ImageOptim)' do
1414
let(:optimized_image) { '/tmp/optimized.jpg' }
1515
let(:unoptimized_image) { '/tmp/unoptimized.jpg' }
1616
let(:image_optim) { stub('ImageOptim') }
1717

18-
it "excludes already optimized images from the results" do
18+
it 'excludes already optimized images from the results' do
1919
image_optim.should_receive(:optimize_images!).
2020
with([unoptimized_image, optimized_image]).
2121
and_yield(unoptimized_image, true).

spec/plugins/pre_commit/image_optimization_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
end
99
end
1010

11-
describe "#run_check" do
11+
describe '#run_check' do
1212
let(:image_optim) { stub(ImageOptim) }
1313
let(:image_set) { stub(described_class::ImageSet) }
1414
let(:staged_filename) { 'filename.jpg' }
@@ -30,7 +30,7 @@
3030
and_return(image_set)
3131
end
3232

33-
context "when a dependency of image_optim is not installed" do
33+
context 'when a dependency of image_optim is not installed' do
3434
before do
3535
image_set.
3636
should_receive(:optimize_with).
@@ -41,7 +41,7 @@
4141
it { should stop }
4242
end
4343

44-
context "when some staged files were optimized" do
44+
context 'when some staged files were optimized' do
4545
before do
4646
image_set.
4747
should_receive(:optimize_with).
@@ -52,7 +52,7 @@
5252
it { should fail_check }
5353
end
5454

55-
context "when no staged files were optimized" do
55+
context 'when no staged files were optimized' do
5656
before do
5757
image_set.
5858
should_receive(:optimize_with).

0 commit comments

Comments
 (0)