Bacon_Rack 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Bacon_Rack.gemspec CHANGED
@@ -9,10 +9,10 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["da99"]
10
10
  s.email = ["i-hate-spam-45671204@mailinator.com"]
11
11
  s.homepage = "https://github.com/da99/Bacon_Rack"
12
- s.summary = %q{Helper methods for Bacon specs.}
12
+ s.summary = %q{Helper methods for Bacon specs that use rack-test.}
13
13
  s.description = %q{
14
14
 
15
- Provides helpers for your Bacon specs:
15
+ Provides helpers for your Bacon specs using rack-test:
16
16
  :renders, :redirects_to, :renders_assets.
17
17
 
18
18
  Read more at the homepage.
data/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
  Bacon\_Rack
3
3
  ================
4
4
 
5
- A Ruby gem providing helper methods for your Bacon specs.
5
+ A Ruby gem providing helper methods for your Bacon and rack/test
6
+ specs.
6
7
 
7
8
  Installation
8
9
  ------------
@@ -1,5 +1,22 @@
1
1
  module Bacon_Rack
2
2
 
3
+ def it_redirects *args
4
+ case args.size
5
+ when 2
6
+ req, resp, stat = args
7
+ when 3
8
+ stat, req, resp = args
9
+ else
10
+ raise ArgumentError, "Incorrect number of arguments: #{args.inspect}"
11
+ end
12
+ suffix = stat ? "using #{stat}" : ''
13
+ it "redirects #{req} to #{resp} #{suffix}" do
14
+ get req
15
+ redirects_to( *([stat, resp].compact))
16
+ yield(stat, req, resp) if block_given?
17
+ end
18
+ end
19
+
3
20
  def redirects_to status, path = nil
4
21
  if status.is_a?(Integer)
5
22
  # do nothing
@@ -1 +1 @@
1
- Bacon_Rack_Version = "0.1.0"
1
+ Bacon_Rack_Version = "0.2.0"
data/spec/Bacon_Rack.rb CHANGED
@@ -1,3 +1,10 @@
1
+ describe ":it_redirects_to" do
2
+
3
+ it_redirects 301, "/301/body", "/body"
4
+ it_redirects "/302/perma", "/perma"
5
+
6
+ end # === :it_redirects_to
7
+
1
8
 
2
9
  describe ":redirects_to" do
3
10
 
data/spec/lib/main.rb CHANGED
@@ -40,6 +40,11 @@ class Bacon::Context
40
40
  def get str
41
41
  pieces = str.split('/').map(&:strip).reject(&:empty?)
42
42
  stat, body = pieces
43
+ case stat.to_i
44
+ when 300..310
45
+ last_response['Location'] = File.join('/', *body)
46
+ end
47
+
43
48
  last_response.status = Integer(stat)
44
49
  end
45
50
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Bacon_Rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-09 00:00:00.000000000 Z
12
+ date: 2012-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon
@@ -75,8 +75,8 @@ dependencies:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
- description: ! "\n\n Provides helpers for your Bacon specs:\n :renders, :redirects_to,
79
- :renders_assets.\n\n Read more at the homepage.\n\n "
78
+ description: ! "\n\n Provides helpers for your Bacon specs using rack-test:\n :renders,
79
+ :redirects_to, :renders_assets.\n\n Read more at the homepage.\n\n "
80
80
  email:
81
81
  - i-hate-spam-45671204@mailinator.com
82
82
  executables: []
@@ -117,5 +117,5 @@ rubyforge_project:
117
117
  rubygems_version: 1.8.23
118
118
  signing_key:
119
119
  specification_version: 3
120
- summary: Helper methods for Bacon specs.
120
+ summary: Helper methods for Bacon specs that use rack-test.
121
121
  test_files: []