redirect 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 0.3.2 / 2009-03-03
2
+
3
+ * 1 major enhancement
4
+
5
+ * Added generation of tests to the app generator
6
+
1
7
  === 0.3.0 / 2009-02-24
2
8
 
3
9
  * 1 major enhancement
data/Manifest.txt CHANGED
@@ -6,5 +6,6 @@ bin/redirect_app
6
6
  example.rb
7
7
  example.ru
8
8
  lib/redirect.rb
9
+ lib/redirect/test.rb
9
10
  spec/helper.rb
10
11
  spec/rack_spec.rb
data/README.txt CHANGED
@@ -13,7 +13,7 @@ From the commandline run:
13
13
 
14
14
  redirect_app PROJECT_NAME
15
15
 
16
- This create a directory PROJECT_NAME with the required files.
16
+ This create a directory PROJECT_NAME with the required files and tests.
17
17
  PROJECT_NAME.rb contains the main logic.
18
18
 
19
19
  To locally run the app you can do:
data/bin/redirect_app CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'fileutils'
3
3
  project = ARGV.first
4
- FileUtils.mkdir_p(project, :verbose => false) unless File.directory?(project)
4
+ FileUtils.mkdir_p(project) unless File.directory?(project)
5
5
 
6
6
  # create application
7
7
  open("#{project}/#{project}.rb", "w") do |f|
@@ -18,4 +18,26 @@ open("#{project}/config.ru", "w") do |f|
18
18
  %(Redirect.autorun = false\n\n) +
19
19
  %(require '#{project}.rb'\n\n) +
20
20
  %(run Redirect.app)
21
- end
21
+ end
22
+
23
+ # create public dir
24
+ FileUtils.mkdir_p("#{project}/public") unless File.directory?("#{project}/public")
25
+
26
+ # create tests dir
27
+ FileUtils.mkdir_p("#{project}/test") unless File.directory?("#{project}/test")
28
+
29
+ # create sample test
30
+ open("#{project}/test/#{project}_test.rb", "w") do |f|
31
+ f.puts %(require 'rubygems'
32
+ require 'redirect/test'
33
+
34
+ require File.dirname(__FILE__) + '/../#{project}.rb'
35
+
36
+ class TestClient < Test::Unit::TestCase
37
+
38
+ def test_old_url
39
+ assert_redirects('/old_url', '/new_url')
40
+ end
41
+
42
+ end)
43
+ end
data/lib/redirect.rb CHANGED
@@ -5,7 +5,7 @@ require 'rack/request'
5
5
  require 'rack/response'
6
6
 
7
7
  module Redirect
8
- VERSION = '0.3.0'
8
+ VERSION = '0.3.2'
9
9
 
10
10
  def self.default_code= default_code
11
11
  @default_code = default_code
@@ -0,0 +1,17 @@
1
+ require 'redirect'
2
+ require 'test/unit'
3
+
4
+ class Test::Unit::TestCase
5
+
6
+ def assert_redirects(from, to)
7
+ res = Rack::MockRequest.new(APP[:redirect_app]).get(from)
8
+ assert_equal(res.headers, { 'Location' => to, 'Content-Type' => 'text/html' })
9
+ end
10
+
11
+ end
12
+
13
+ APP = {}
14
+
15
+ def redirect(*redirects)
16
+ APP[:redirect_app] = Rack::Redirect.new(*redirects)
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redirect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petrik de Heus
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-24 00:00:00 +01:00
12
+ date: 2009-03-03 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,7 @@ files:
42
42
  - example.rb
43
43
  - example.ru
44
44
  - lib/redirect.rb
45
+ - lib/redirect/test.rb
45
46
  - spec/helper.rb
46
47
  - spec/rack_spec.rb
47
48
  has_rdoc: true