Skip to content

Commit

Permalink
Fix: Git::Patches#repo shouldn't always return nil
Browse files Browse the repository at this point in the history
  • Loading branch information
mmozuras committed Sep 11, 2014
1 parent d131d6b commit 6e3c848
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/pronto/git/patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Patches
attr_reader :commit, :repo

def initialize(repo, commit, patches)
@repo = repo
@commit = commit
@patches = patches.map { |patch| Git::Patch.new(patch, repo) }
end
Expand Down
23 changes: 15 additions & 8 deletions spec/pronto/git/patches_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,26 @@
module Pronto
module Git
describe Patches do
describe '#find_line' do
subject { Patches.new(repo, commit, patches).find_line(path, line) }
let(:patches) { Patches.new(repo, commit, []) }
let(:repo) { nil }
let(:commit) { nil }

describe '#repo' do
subject { patches.repo }

let(:repo) { nil }
let(:commit) { nil }
context 'non-nil repo' do
let(:repo) { double }
it { should_not be_nil }
end
end

describe '#find_line' do
subject { patches.find_line(path, line) }

let(:path) { '/test.rb' }
let(:line) { 1 }

context 'no patches' do
let(:patches) { [] }
it { should be_nil }
end
it { should be_nil }
end
end
end
Expand Down

0 comments on commit 6e3c848

Please sign in to comment.