Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add some tests; remove extra slash; add mocha

  • Loading branch information...
commit 870339711b70e7d9251d0291514bfb188beab70b 1 parent e3833ef
Rob Sanheim rsanheim authored
1  janky.gemspec
View
@@ -25,6 +25,7 @@ Gem::Specification.new "janky", Janky::VERSION do |s|
# test
s.add_development_dependency "database_cleaner", "~>0.6"
+ s.add_development_dependency "mocha", "~>0.10.4"
s.files = %w[
CHANGES
2  lib/janky/notifier/github_status.rb
View
@@ -37,7 +37,7 @@ def completed(build)
# Internal: POST the new status to the API
def post(path, status, url, desc)
http = Net::HTTP.new(@api_url.host, @api_url.port)
- post = Net::HTTP::Post.new("#{@api_url.path}/#{path}")
+ post = Net::HTTP::Post.new("#{@api_url.path}#{path}")
http.use_ssl = true
24 test/github_status_test.rb
View
@@ -0,0 +1,24 @@
+require File.expand_path("../test_helper", __FILE__)
+
+class GithubStatusTest < Test::Unit::TestCase
+ def stub_build
+ @stub_build = stub(:repo_nwo => "github/janky",
+ :sha1 => "xxxx",
+ :green? => true,
+ :number => 1,
+ :duration => 1,
+ :web_url => "http://example.com/builds/1")
+ end
+
+ def setup
+ # never allow any outgoing requests
+ Net::HTTP.any_instance.stubs(:request)
+ end
+
+ test "sending successful status uses the right path" do
+ post = stub_everything
+ Net::HTTP::Post.expects(:new).with("/repos/github/janky/statuses/xxxx").returns(post)
+ notifier = Janky::Notifier::GithubStatus.new("token", "http://example.com/")
+ notifier.completed(stub_build)
+ end
+end
1  test/test_helper.rb
View
@@ -2,6 +2,7 @@
require "janky"
require "test/unit"
+require "mocha"
require "database_cleaner"
class Test::Unit::TestCase
Please sign in to comment.
Something went wrong with that request. Please try again.