test/unit/github_test.rb in vigetlabs-provisional-2.0.2 vs test/unit/github_test.rb in vigetlabs-provisional-2.0.3
- old
+ new
@@ -45,8 +45,32 @@
Dir.expects(:chdir)
gitignore_file = stub()
gitignore_file.expects(:puts).with(@scm.gitignore)
File.expects(:open).with('.gitignore', 'w').yields(gitignore_file)
+ URI.expects(:parse).with('https://github.com/api/v2/yaml/repos/create')
+ Net::HTTP.expects(:post_form).with(nil, { 'login' => 'user', 'token' => 'token', 'name' => 'name' })
+
@scm.checkin
+ end
+
+ def test_checkin_should_raise_RuntimeError_if_any_step_raises_any_exception
+ repo_stub = stub()
+ repo_stub.expects(:add).with('.')
+ repo_stub.expects(:commit).with('Initial commit by Provisional')
+ repo_stub.expects(:config).with('github.user').returns('user')
+ repo_stub.expects(:config).with('github.token').returns('token')
+
+ Git.expects(:open).returns(repo_stub)
+ Dir.expects(:chdir)
+ gitignore_file = stub()
+ gitignore_file.expects(:puts).with(@scm.gitignore)
+ File.expects(:open).with('.gitignore', 'w').yields(gitignore_file)
+
+ URI.expects(:parse).with('https://github.com/api/v2/yaml/repos/create')
+ Net::HTTP.expects(:post_form).with(nil, { 'login' => 'user', 'token' => 'token', 'name' => 'name' }).raises(Net::HTTPUnauthorized)
+
+ assert_raise RuntimeError do
+ @scm.checkin
+ end
end
end