Skip to content

Commit 1d96dde

Browse files
author
Aiden Scandella
committed
Add rspec + first spec
Even basic coverage is better than none. Change-Id: I173401136e18668290254f551d9c5db70d8630da Reviewed-on: https://gerrit.causes.com/22788 Tested-by: jenkins <jenkins@causes.com> Reviewed-by: Aiden Scandella <aiden@causes.com>
1 parent f71c404 commit 1d96dde

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'http://rubygems.org'
2+
3+
gemspec

lib/overcommit/cli.rb

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module Overcommit
44
class CLI
55
include ConsoleMethods
6+
attr_reader :options
67

78
def initialize(arguments = [])
89
@arguments = arguments

overcommit.gemspec

+2
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ Gem::Specification.new do |s|
2020
s.files = Dir['lib/**/*.rb'] +
2121
Dir['bin/**/*'] +
2222
Dir['config/*.yml']
23+
24+
s.add_development_dependency 'rspec'
2325
end

spec/cli_spec.rb

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require 'spec_helper'
2+
require 'overcommit/cli'
3+
4+
describe Overcommit::CLI do
5+
describe '#parse_arguments' do
6+
subject do
7+
cli = described_class.new(arguments)
8+
cli.parse_arguments
9+
cli
10+
end
11+
12+
context 'with no arguments' do
13+
let(:arguments) { [] }
14+
15+
it 'does not set any targets' do
16+
subject.options[:targets].should be_empty
17+
end
18+
end
19+
20+
context 'with excludes' do
21+
let(:arguments) { %w[--exclude hook_name.first,hook_name/second] }
22+
23+
it 'takes the first part of the name' do
24+
subject.options[:excludes]['hook_name'].should_not be_nil
25+
end
26+
27+
it 'creates an array of excludes' do
28+
subject.options[:excludes]['hook_name'].should =~ %w[first second]
29+
end
30+
end
31+
end
32+
end

spec/spec_helper.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require 'overcommit'
2+
3+
def exit(*args) ; end

0 commit comments

Comments
 (0)