Permalink
Browse files

#7 remove git dependencies from tests

  • Loading branch information...
robertgreiner committed Jan 20, 2012
1 parent d6c4e6c commit 018724b3f4ce970d00b9ede337731a6505b423d8
@@ -2,33 +2,37 @@
require_relative '../../../lib/tipster/commands/git/repository_context'
describe "a git repository" do
- it "should not be in a valid repository" do
+
+ before do
LatestCommit.stub(:new).and_return double("LatestCommit")
- latest_commit = LatestCommit.new
- latest_commit.stub(:id).and_return ''
+ @latest_commit = LatestCommit.new
+ end
+
+ it "should not be in a valid repository" do
+ @latest_commit.stub(:id).and_return ''
RepositoryContext.valid_repository?.should be false
end
it "should be in a valid repository" do
- LatestCommit.stub(:new).and_return double("LatestCommit")
- latest_commit = LatestCommit.new
- latest_commit.stub(:id).and_return 'be6da5838f94e3003ea92150fae92fb5b07c04bb'
+ @latest_commit.stub(:id).and_return 'be6da5838f94e3003ea92150fae92fb5b07c04bb'
RepositoryContext.valid_repository?.should be true
end
end
describe "a git commit" do
- it "should not be a valid git commit" do
+
+ before do
FilesChanged.stub(:new).and_return double("FilesChanged")
- files_changed = FilesChanged.new(stub(:commit_id => ''))
- files_changed.stub(:list).and_return ''
+ @files_changed = FilesChanged.new(stub(:commit_id => ''))
+ end
+
+ it "should not be a valid git commit" do
+ @files_changed.stub(:list).and_return ''
RepositoryContext.valid_commit_id?('be6da5838f94e3003ea92150fae92fb5b07c04bb').should be false
end
it "should not be a valid git commit" do
- FilesChanged.stub(:new).and_return double("FilesChanged")
- files_changed = FilesChanged.new(stub(:commit_id => ''))
- files_changed.stub(:list).and_return 'some file information'
+ @files_changed.stub(:list).and_return 'some file information'
RepositoryContext.valid_commit_id?('some-invalid-id').should be true
end
end
@@ -2,15 +2,21 @@
require_relative '../../lib/tipster/presenters/code_churn_presenter'
describe "Code Churn Presenter" do
- before(:all) do
- Dir.chdir '..'
+
+ before do
+ CodeChurnHeuristic.stub(:new).and_return double("CodeChurnHeuristic")
+ @code_churn_heuristic = CodeChurnHeuristic.new
+ @code_churn_heuristic.stub(:apply).and_return nil
end
+
it "should not have a risky commit if churn is low" do
+ @code_churn_heuristic.stub(:pass?).and_return true
commit = CodeChurnPresenter.new 'a77b5e63d1da2436fc4aa5931e3bf54469ab36c5'
commit.pass?.should be true
end
it "should have a risky commit if churn is high" do
+ @code_churn_heuristic.stub(:pass?).and_return false
commit = CodeChurnPresenter.new '2246e9ec9dbc4eb2ffd1fa775d2c64deb11ee8be'
commit.pass?.should be false
end
-end
+end
@@ -2,12 +2,22 @@
require_relative '../../lib/tipster/presenters/code_ratio_presenter'
describe "Code Ratio Presenter" do
+
+ before do
+ CodeRatioHeuristic.stub(:new).and_return double("CodeRatioHeuristic")
+ @code_ratio_heuristic = CodeRatioHeuristic.new
+ @code_ratio_heuristic.stub(:apply).and_return nil
+ end
+
it "should not have a risky commit if tests pass" do
+ @code_ratio_heuristic.stub(:pass?).and_return true
commit = CodeRatioPresenter.new '451b60a38eecfee6ebee5ec8ceb34ea9c9c77145'
commit.pass?.should be true
end
it "should have a risky commit if tests fail" do
+ @code_ratio_heuristic.stub(:pass?).and_return false
commit = CodeRatioPresenter.new '2246e9ec9dbc4eb2ffd1fa775d2c64deb11ee8be'
commit.pass?.should be false
end
-end
+end
+

0 comments on commit 018724b

Please sign in to comment.