Skip to content

Commit

Permalink
add test structure and submodule for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Nov 3, 2009
1 parent a33c586 commit 03580e5
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tests/example"]
path = tests/example
url = git://github.com/schacon/simplegit.git
24 changes: 24 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
task :default => :test

desc "Run the tests."
task :test do
Dir.glob("tests/*_test.rb").each do |file|
require file
end
end

desc "Run test coverage."
task :rcov do
system "rcov tests/test.rb -i lib/git_http.rb -x rack -x Library -x tests"
system "open coverage/index.html"
end

namespace :grack do
desc "Start Grack"
task :start do
system "rackup config.ru -p 8080"
end
end

desc "Start everything."
multitask :start => [ 'grack:start' ]
6 changes: 5 additions & 1 deletion lib/git_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ class App
["GET", 'get_idx_file', "(.*?)/objects/pack/pack-[0-9a-f]{40}\\.idx$"],
]

def initialize(config)
def initialize(config = false)
set_config(config)
end

def set_config(config)
@config = config || {}
end

Expand Down
1 change: 1 addition & 0 deletions tests/example
Submodule example added at ca82a6
36 changes: 36 additions & 0 deletions tests/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'rubygems'
require 'rack'
require "rack/test"
require 'test/unit'

require 'lib/git_http'

class GitHttpTest < Test::Unit::TestCase
include Rack::Test::Methods

def app
GitHttp::App.new(false)
end

# def config_project_root
# def config_git_path
# def config_upload_path_on
# def config_upload_path_off
# def config_upload_path_setting_on
# def config_upload_path_setting_off
# def test_upload_pack_advertisement
# def test_upload_pack_rpc
# def test_receive_pack_advertisement
# def test_receive_pack_rpc
# def test_dumb_urls
# def test_method_not_allowed
# def test_not_a_command
# def test_not_git_dir

def test_redirect_logged_in_users_to_dashboard
get "/"
assert_equal "http://example.org/redirected", last_request.url
assert last_response.ok?
end

end

0 comments on commit 03580e5

Please sign in to comment.