Skip to content

Commit c30ff14

Browse files
jawshooahsds
authored andcommitted
Stub methods of hook context rather than the hook itself
1 parent 578c526 commit c30ff14

11 files changed

+20
-20
lines changed

spec/overcommit/hook/commit_msg/capitalized_subject_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
subject { described_class.new(config, context) }
88

99
before do
10-
subject.stub(:commit_message_lines).and_return(commit_msg.split("\n"))
11-
subject.stub(:empty_message?).and_return(commit_msg.empty?)
10+
context.stub(:commit_message_lines).and_return(commit_msg.split("\n"))
11+
context.stub(:empty_message?).and_return(commit_msg.empty?)
1212
end
1313

1414
context 'when commit message is empty' do

spec/overcommit/hook/commit_msg/empty_message_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
subject { described_class.new(config, context) }
77

88
before do
9-
subject.stub(:empty_message?).and_return(commit_msg.strip.empty?)
9+
context.stub(:empty_message?).and_return(commit_msg.strip.empty?)
1010
end
1111

1212
context 'when commit message is empty' do

spec/overcommit/hook/commit_msg/gerrit_change_id_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
before do
1010
commit_msg_file.write(commit_msg)
1111
commit_msg_file.close
12-
subject.stub(:commit_message_file).and_return(commit_msg_file.path)
12+
context.stub(:commit_message_file).and_return(commit_msg_file.path)
1313
end
1414

1515
context 'when the commit message contains no Change-Id' do

spec/overcommit/hook/commit_msg/hard_tabs_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
subject { described_class.new(config, context) }
77

88
before do
9-
subject.stub(:commit_message).and_return(commit_msg)
10-
subject.stub(:empty_message?).and_return(commit_msg.empty?)
9+
context.stub(:commit_message).and_return(commit_msg)
10+
context.stub(:empty_message?).and_return(commit_msg.empty?)
1111
end
1212

1313
context 'when commit message is empty' do

spec/overcommit/hook/commit_msg/russian_novel_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
subject { described_class.new(config, context) }
77

88
before do
9-
subject.stub(:commit_message_lines).and_return(commit_msg)
9+
context.stub(:commit_message_lines).and_return(commit_msg)
1010
end
1111

1212
context 'when message contains fewer than 30 lines' do

spec/overcommit/hook/commit_msg/single_line_subject_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
subject { described_class.new(config, context) }
77

88
before do
9-
subject.stub(:commit_message_lines).and_return(commit_msg.split("\n"))
10-
subject.stub(:empty_message?).and_return(commit_msg.empty?)
9+
context.stub(:commit_message_lines).and_return(commit_msg.split("\n"))
10+
context.stub(:empty_message?).and_return(commit_msg.empty?)
1111
end
1212

1313
context 'when commit message is empty' do

spec/overcommit/hook/commit_msg/text_width_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
subject { described_class.new(config, context) }
77

88
before do
9-
subject.stub(:commit_message_lines).and_return(commit_msg.split("\n"))
10-
subject.stub(:empty_message?).and_return(commit_msg.empty?)
9+
context.stub(:commit_message_lines).and_return(commit_msg.split("\n"))
10+
context.stub(:empty_message?).and_return(commit_msg.empty?)
1111
end
1212

1313
context 'when commit message is empty' do

spec/overcommit/hook/commit_msg/trailing_period_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
subject { described_class.new(config, context) }
77

88
before do
9-
subject.stub(:commit_message_lines).and_return(commit_msg.split("\n"))
10-
subject.stub(:empty_message?).and_return(commit_msg.empty?)
9+
context.stub(:commit_message_lines).and_return(commit_msg.split("\n"))
10+
context.stub(:empty_message?).and_return(commit_msg.empty?)
1111
end
1212

1313
context 'when commit message is empty' do

spec/overcommit/hook/post_commit/git_guilt_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
context 'when there is no previous commit' do
4444
before do
45-
subject.stub(:initial_commit?).and_return(true)
45+
context.stub(:initial_commit?).and_return(true)
4646
end
4747

4848
it { should pass }

spec/overcommit/hook/pre_push/protected_branches_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
before do
1313
subject.stub(:branches).and_return([protected_branch])
14-
subject.stub(:pushed_refs).and_return([pushed_ref])
14+
context.stub(:pushed_refs).and_return([pushed_ref])
1515
end
1616

1717
context 'when pushing to unprotected branch' do

0 commit comments

Comments
 (0)