shoulda_routing 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +23 -15
- data/features/integration.feature +54 -0
- data/features/namespaces.feature +30 -0
- data/features/nested_namespaces.feature +34 -0
- data/features/step_definitions/namespaces_steps.rb +21 -0
- data/lib/shoulda_routing.rb +9 -3
- data/lib/shoulda_routing/dsl.rb +3 -0
- data/lib/shoulda_routing/namespaces/base.rb +20 -0
- data/lib/shoulda_routing/namespaces/dsl.rb +8 -0
- data/lib/shoulda_routing/namespaces/method.rb +12 -0
- data/lib/shoulda_routing/resources/base.rb +9 -10
- data/lib/shoulda_routing/routes/helpers.rb +3 -13
- data/lib/shoulda_routing/routes/stack.rb +33 -1
- data/lib/shoulda_routing/version.rb +1 -1
- data/spec/shoulda_routing/dsl_spec.rb +1 -0
- data/spec/shoulda_routing/namespaces/base_spec.rb +18 -0
- data/spec/shoulda_routing/namespaces/dsl_spec.rb +10 -0
- data/spec/shoulda_routing/namespaces/method_spec.rb +23 -0
- data/spec/shoulda_routing/resources/base_spec.rb +45 -0
- data/spec/shoulda_routing/resources/dsl_spec.rb +9 -0
- data/spec/shoulda_routing/resources/method_spec.rb +23 -0
- data/spec/shoulda_routing/routes/helpers_spec.rb +9 -17
- data/spec/shoulda_routing/routes/stack_spec.rb +33 -1
- data/spec/spec_helper.rb +1 -1
- metadata +26 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5df9f49ea7c93004c80b8e62ff3065c31db89bf
|
4
|
+
data.tar.gz: 049b382b1511a4a9a3bec7f1d04701ffe8c7a884
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9e159d945db57bf022f6426c713e028b5c3dbdba9aa141bc2f1cfbe297cd0fa71c6e1fb172c61a5b384b2406596151e40ffaceca53102856acd2bb1b0813bcf
|
7
|
+
data.tar.gz: e55be1b76c395dd36bab5666c2bc6bb5a533e460b4f600bdb925d8da9ce7e18662117a40259ccbbd3bad0316b6f15ef66f024fbfceb58375c000dff1e014ba05
|
data/README.md
CHANGED
@@ -23,15 +23,19 @@ In your routes.rb file:
|
|
23
23
|
|
24
24
|
```ruby
|
25
25
|
YourApp::Application.routes.draw do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
namespace :admin do
|
27
|
+
resources :users
|
28
|
+
resources :posts, only: [:index, :show]
|
29
|
+
|
30
|
+
namespace :mobile do
|
31
|
+
resources :users
|
32
|
+
resources :parents, controller: :users
|
33
|
+
end
|
31
34
|
end
|
32
35
|
|
33
|
-
resources :
|
34
|
-
|
36
|
+
resources :users, except: :destroy do
|
37
|
+
resources :posts, :comments
|
38
|
+
end
|
35
39
|
end
|
36
40
|
```
|
37
41
|
|
@@ -41,21 +45,25 @@ In your routing_spec.rb file:
|
|
41
45
|
require 'spec_helper'
|
42
46
|
|
43
47
|
describe "Routes" do
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
48
|
+
namespace :admin do
|
49
|
+
resources :users
|
50
|
+
resources :posts, only: [:index, :show]
|
51
|
+
|
52
|
+
namespace :mobile do
|
53
|
+
resources :users
|
54
|
+
resources :parents, controller: :users
|
55
|
+
end
|
49
56
|
end
|
50
57
|
|
51
|
-
resources :
|
52
|
-
|
58
|
+
resources :users, except: :destroy do
|
59
|
+
resources :posts, :comments
|
60
|
+
end
|
53
61
|
end
|
54
62
|
```
|
63
|
+
This will generate the necessary tests for all rails routes above.
|
55
64
|
|
56
65
|
## TO-DO
|
57
66
|
|
58
|
-
* Support namespaces
|
59
67
|
* Support member and collection routes.
|
60
68
|
* Support single resources (get, post, put, delete) actions.
|
61
69
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Feature: Features integration
|
2
|
+
|
3
|
+
Background:
|
4
|
+
When I generate a new rails application
|
5
|
+
And I generate resources "user post comment likes role account"
|
6
|
+
And I generate resources "user post comment likes role account" in namespace "admin"
|
7
|
+
And I generate resources "user post comment likes role account" in namespace "admin::control"
|
8
|
+
And I configure the application to use rspec-rails
|
9
|
+
And I run the rspec generator
|
10
|
+
And I configure the application to use "shoulda_routing"
|
11
|
+
|
12
|
+
Scenario: Support nested namespaces
|
13
|
+
Given I write to "config/routes.rb" with:
|
14
|
+
"""
|
15
|
+
TestApp::Application.routes.draw do
|
16
|
+
namespace :admin do
|
17
|
+
resources :users do
|
18
|
+
resources :posts, :comments
|
19
|
+
end
|
20
|
+
|
21
|
+
namespace :control do
|
22
|
+
resources :roles, only: :index
|
23
|
+
resources :accounts, except: :destroy
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
resources :users do
|
28
|
+
resources :posts, :comments
|
29
|
+
end
|
30
|
+
end
|
31
|
+
"""
|
32
|
+
And I write to "spec/routing/routing_spec.rb" with:
|
33
|
+
"""
|
34
|
+
require 'spec_helper'
|
35
|
+
|
36
|
+
describe 'Routes' do
|
37
|
+
namespace :admin do
|
38
|
+
resources :users do
|
39
|
+
resources :posts, :comments
|
40
|
+
end
|
41
|
+
|
42
|
+
namespace :control do
|
43
|
+
resources :roles, only: :index
|
44
|
+
resources :accounts, except: :update
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
resources :users do
|
49
|
+
resources :posts, :comments, :likes
|
50
|
+
end
|
51
|
+
end
|
52
|
+
"""
|
53
|
+
When I run routing specs
|
54
|
+
Then the output should contain "63 examples, 9 failures"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: Support namespaces
|
2
|
+
|
3
|
+
Background:
|
4
|
+
When I generate a new rails application
|
5
|
+
And I generate resources "user" in namespace "admin"
|
6
|
+
And I configure the application to use rspec-rails
|
7
|
+
And I run the rspec generator
|
8
|
+
And I configure the application to use "shoulda_routing"
|
9
|
+
|
10
|
+
Scenario: Support namespaces
|
11
|
+
Given I write to "config/routes.rb" with:
|
12
|
+
"""
|
13
|
+
TestApp::Application.routes.draw do
|
14
|
+
namespace :admin do
|
15
|
+
resources :users
|
16
|
+
end
|
17
|
+
end
|
18
|
+
"""
|
19
|
+
And I write to "spec/routing/routing_spec.rb" with:
|
20
|
+
"""
|
21
|
+
require 'spec_helper'
|
22
|
+
|
23
|
+
describe 'Routes' do
|
24
|
+
namespace :admin do
|
25
|
+
resources :users, :posts
|
26
|
+
end
|
27
|
+
end
|
28
|
+
"""
|
29
|
+
When I run routing specs
|
30
|
+
Then the output should contain "14 examples, 7 failures"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Feature: Support nested namespaces
|
2
|
+
|
3
|
+
Background:
|
4
|
+
When I generate a new rails application
|
5
|
+
And I generate resources "user post" in namespace "admin::control"
|
6
|
+
And I configure the application to use rspec-rails
|
7
|
+
And I run the rspec generator
|
8
|
+
And I configure the application to use "shoulda_routing"
|
9
|
+
|
10
|
+
Scenario: Support nested namespaces
|
11
|
+
Given I write to "config/routes.rb" with:
|
12
|
+
"""
|
13
|
+
TestApp::Application.routes.draw do
|
14
|
+
namespace :admin do
|
15
|
+
namespace :control do
|
16
|
+
resources :users
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
"""
|
21
|
+
And I write to "spec/routing/routing_spec.rb" with:
|
22
|
+
"""
|
23
|
+
require 'spec_helper'
|
24
|
+
|
25
|
+
describe 'Routes' do
|
26
|
+
namespace :admin do
|
27
|
+
namespace :control do
|
28
|
+
resources :users, :posts
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
"""
|
33
|
+
When I run routing specs
|
34
|
+
Then the output should contain "14 examples, 7 failures"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
When /^I generate resources "([^\"]+)" in namespace "([^\"]+)"$/ do |resources, namespace|
|
2
|
+
resources.split(" ").each do |resource|
|
3
|
+
namespace_path = namespace.split("::").join("/")
|
4
|
+
namespaces = namespace.split("::").map(&:camelcase).join("::")
|
5
|
+
|
6
|
+
steps %{
|
7
|
+
When I write to "app/controllers/#{namespace_path}/#{resource.pluralize}_controller.rb" with:
|
8
|
+
"""
|
9
|
+
class #{namespaces}::#{resource.pluralize.camelcase}Controller < ApplicationController
|
10
|
+
def index; end
|
11
|
+
def show; end
|
12
|
+
def edit; end
|
13
|
+
def update; end
|
14
|
+
def create; end
|
15
|
+
def new; end
|
16
|
+
def destroy; end
|
17
|
+
end
|
18
|
+
"""
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
data/lib/shoulda_routing.rb
CHANGED
@@ -2,6 +2,12 @@ module ShouldaRouting
|
|
2
2
|
autoload :DSL, 'shoulda_routing/dsl.rb'
|
3
3
|
autoload :VERSION, 'shoulda_routing/version.rb'
|
4
4
|
|
5
|
+
module Namespaces
|
6
|
+
autoload :Base, 'shoulda_routing/namespaces/base.rb'
|
7
|
+
autoload :DSL, 'shoulda_routing/namespaces/dsl.rb'
|
8
|
+
autoload :Method, 'shoulda_routing/namespaces/method.rb'
|
9
|
+
end
|
10
|
+
|
5
11
|
module Resources
|
6
12
|
autoload :Base, 'shoulda_routing/resources/base.rb'
|
7
13
|
autoload :DSL, 'shoulda_routing/resources/dsl.rb'
|
@@ -9,9 +15,9 @@ module ShouldaRouting
|
|
9
15
|
end
|
10
16
|
|
11
17
|
module Routes
|
12
|
-
autoload :Spec,
|
13
|
-
autoload :Helpers,
|
14
|
-
autoload :STACK,
|
18
|
+
autoload :Spec, 'shoulda_routing/routes/spec.rb'
|
19
|
+
autoload :Helpers, 'shoulda_routing/routes/helpers.rb'
|
20
|
+
autoload :STACK, 'shoulda_routing/routes/stack.rb'
|
15
21
|
end
|
16
22
|
end
|
17
23
|
|
data/lib/shoulda_routing/dsl.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module ShouldaRouting
|
2
|
+
module Namespaces
|
3
|
+
class Base
|
4
|
+
|
5
|
+
attr_accessor :current, :options, :block
|
6
|
+
|
7
|
+
def initialize *args, &block
|
8
|
+
@options = args.extract_options!
|
9
|
+
@current = args
|
10
|
+
@block = block
|
11
|
+
end
|
12
|
+
|
13
|
+
def test!
|
14
|
+
Routes::STACK.namespaces.push(current)
|
15
|
+
DSL.instance_eval(&block) if block
|
16
|
+
Routes::STACK.namespaces.pop
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module ShouldaRouting
|
2
2
|
module Resources
|
3
3
|
class Base
|
4
|
-
include Routes::Helpers
|
5
4
|
|
6
5
|
attr_accessor :current, :options, :block
|
7
6
|
|
@@ -12,27 +11,27 @@ module ShouldaRouting
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def test!
|
15
|
-
Routes::STACK.push(current)
|
14
|
+
Routes::STACK.resources.push(current)
|
16
15
|
|
17
|
-
|
18
|
-
specs_for(routeable_actions,
|
19
|
-
specs_for(unrouteable_actions,
|
16
|
+
Routes::STACK.routes.each do |route|
|
17
|
+
specs_for(routeable_actions, route)
|
18
|
+
specs_for(unrouteable_actions, route, :not_to)
|
20
19
|
end
|
21
20
|
|
22
21
|
DSL.instance_eval(&block) if block
|
23
|
-
Routes::STACK.pop
|
22
|
+
Routes::STACK.resources.pop
|
24
23
|
end
|
25
24
|
|
26
25
|
private
|
27
26
|
|
28
|
-
def specs_for actions,
|
27
|
+
def specs_for actions, route, spec_method = :to
|
29
28
|
actions.each do |action, args|
|
30
29
|
Routes::Spec.execute do |config|
|
31
30
|
config.via = args[:via]
|
32
|
-
config.path =
|
33
|
-
config.controller = options[:controller] ||
|
31
|
+
config.path = route[:url] + (args[:path] || "")
|
32
|
+
config.controller = options[:controller] || route[:controller]
|
34
33
|
config.action = action
|
35
|
-
config.params =
|
34
|
+
config.params = route[:params].merge(args[:params] || {})
|
36
35
|
config.method = spec_method
|
37
36
|
end
|
38
37
|
end
|
@@ -2,23 +2,13 @@ module ShouldaRouting
|
|
2
2
|
module Routes
|
3
3
|
module Helpers
|
4
4
|
|
5
|
-
|
6
|
-
def route_path stack, options = {}
|
7
|
-
"/#{stack.join("/1/")}" + options[:suffix].to_s
|
8
|
-
end
|
9
|
-
|
10
|
-
# Returns the combinations according to an array passed by param.
|
11
|
-
# This is in order to generate all the nested routes.
|
12
|
-
def route_permutations stack
|
5
|
+
def permutations stack
|
13
6
|
stack.inject(&:product).map{|e| e.flatten rescue [e]}
|
14
7
|
end
|
15
8
|
|
16
|
-
def
|
9
|
+
def params stack
|
17
10
|
params = {}
|
18
|
-
stack[
|
19
|
-
params[:"#{resource.to_s.singularize}_id"] = "1"
|
20
|
-
end
|
21
|
-
params.merge!(options)
|
11
|
+
stack.each{ |e| params[:"#{e.to_s.singularize}_id"] = "1" }
|
22
12
|
params
|
23
13
|
end
|
24
14
|
|
@@ -1,5 +1,37 @@
|
|
1
1
|
module ShouldaRouting
|
2
2
|
module Routes
|
3
|
-
|
3
|
+
class Stack
|
4
|
+
include Routes::Helpers
|
5
|
+
|
6
|
+
def resources
|
7
|
+
@resources ||= []
|
8
|
+
end
|
9
|
+
|
10
|
+
def namespaces
|
11
|
+
@namespaces ||= []
|
12
|
+
end
|
13
|
+
|
14
|
+
def routes
|
15
|
+
permutations(stack).map do |segments|
|
16
|
+
namespaces = segments[0...self.namespaces.count]
|
17
|
+
resources = segments[self.namespaces.count...segments.count]
|
18
|
+
|
19
|
+
options = {}
|
20
|
+
options[:segments] = segments
|
21
|
+
options[:url] = "/#{namespaces.join("/")}/#{resources.join("/1/")}"
|
22
|
+
options[:params] = params(resources[0...-1])
|
23
|
+
options[:controller] = (namespaces + [segments.last]).join("/")
|
24
|
+
options
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def stack
|
31
|
+
namespaces + resources
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
STACK = Stack.new
|
4
36
|
end
|
5
37
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ShouldaRouting
|
4
|
+
module Namespaces
|
5
|
+
describe Base do
|
6
|
+
subject { described_class.new(:admin, options: "options") }
|
7
|
+
|
8
|
+
describe "initialize" do
|
9
|
+
it { expect(subject.options).to eq({options: "options"})}
|
10
|
+
it { expect(subject.current).to eq([:admin]) }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#test!" do
|
14
|
+
pending
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ShouldaRouting
|
4
|
+
module Namespaces
|
5
|
+
describe Method do
|
6
|
+
subject { Class.new.extend described_class }
|
7
|
+
|
8
|
+
describe "#namespace" do
|
9
|
+
it "calls Namespaces::Base test! method with correct params" do
|
10
|
+
namespace_instance = Namespaces::Base.new
|
11
|
+
namespace_instance.stub(:test!).and_return("tested!")
|
12
|
+
|
13
|
+
Namespaces::Base.should_receive(:new).
|
14
|
+
with(:admin, option: 1).
|
15
|
+
exactly(1).times.
|
16
|
+
and_return(namespace_instance)
|
17
|
+
|
18
|
+
subject.namespace(:admin, option: 1).should eq "tested!"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ShouldaRouting
|
4
|
+
module Resources
|
5
|
+
describe Base do
|
6
|
+
subject { described_class.new(:users, except: :destroy) }
|
7
|
+
|
8
|
+
describe "initialize" do
|
9
|
+
it { expect(subject.options).to eq({except: :destroy})}
|
10
|
+
it { expect(subject.current).to eq([:users]) }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#test!" do
|
14
|
+
pending
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "-#specs_for" do
|
18
|
+
pending
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "-#actions" do
|
22
|
+
it "retuns restful actions definition" do
|
23
|
+
actions = {
|
24
|
+
:index => { via: :get },
|
25
|
+
:create => { via: :post },
|
26
|
+
:new => { via: :get, path: "/new" },
|
27
|
+
:edit => { via: :get, path: "/1/edit", params: { id: "1" }},
|
28
|
+
:show => { via: :get, path: "/1", params: { id: "1" }},
|
29
|
+
:update => { via: :put, path: "/1", params: { id: "1" }},
|
30
|
+
:destroy => { via: :delete, path: "/1", params: { id: "1" }}
|
31
|
+
}
|
32
|
+
subject.send(:actions).should eq actions
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "-#routeable_actions" do
|
37
|
+
pending
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "-#unrouteable_actions" do
|
41
|
+
pending
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ShouldaRouting
|
4
|
+
module Resources
|
5
|
+
describe Method do
|
6
|
+
subject { Class.new.extend described_class }
|
7
|
+
|
8
|
+
describe "#resources" do
|
9
|
+
it "calls Resources::Base test! method with correct params" do
|
10
|
+
resource_instance = Resources::Base.new
|
11
|
+
resource_instance.stub(:test!).and_return("tested!")
|
12
|
+
|
13
|
+
Resources::Base.should_receive(:new).
|
14
|
+
with(:users, except: :destroy).
|
15
|
+
exactly(1).times.
|
16
|
+
and_return(resource_instance)
|
17
|
+
|
18
|
+
subject.resources(:users, except: :destroy).should eq "tested!"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -3,47 +3,39 @@ require 'spec_helper'
|
|
3
3
|
module ShouldaRouting
|
4
4
|
module Routes
|
5
5
|
describe Helpers do
|
6
|
-
|
6
|
+
subject { Class.new.extend described_class }
|
7
7
|
|
8
|
-
describe "#
|
9
|
-
it "returns string path accoring to an array" do
|
10
|
-
stack = [:users, :posts, :likes]
|
11
|
-
expected = "/users/1/posts/1/likes"
|
12
|
-
expect(subject.route_path(stack)).to eq(expected)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#route_permutations" do
|
8
|
+
describe "#permutations" do
|
17
9
|
it "returns permutations accoring to an array" do
|
18
10
|
stack = [[1, 2]]
|
19
11
|
expected = [[1], [2]]
|
20
|
-
expect(subject.
|
12
|
+
expect(subject.permutations(stack)).to eq(expected)
|
21
13
|
end
|
22
14
|
|
23
15
|
it "returns permutations accoring to an array" do
|
24
16
|
stack = [[1, 2], [3, 4]]
|
25
17
|
expected = [[1, 3], [1, 4], [2, 3], [2, 4]]
|
26
|
-
expect(subject.
|
18
|
+
expect(subject.permutations(stack)).to eq(expected)
|
27
19
|
end
|
28
20
|
|
29
21
|
it "returns permutations accoring to an array" do
|
30
22
|
stack = [[1, 2], [3]]
|
31
23
|
expected = [[1, 3], [2, 3]]
|
32
|
-
expect(subject.
|
24
|
+
expect(subject.permutations(stack)).to eq(expected)
|
33
25
|
end
|
34
26
|
|
35
27
|
it "returns permutations accoring to an array" do
|
36
28
|
stack = [[1, 2], [3], [4, 5]]
|
37
29
|
expected = [[1, 3, 4], [1, 3, 5], [2, 3, 4], [2, 3, 5]]
|
38
|
-
expect(subject.
|
30
|
+
expect(subject.permutations(stack)).to eq(expected)
|
39
31
|
end
|
40
32
|
end
|
41
33
|
|
42
|
-
describe "#
|
34
|
+
describe "#params" do
|
43
35
|
it "returns params accoring to an array" do
|
44
36
|
stack = [:users, :posts, :likes]
|
45
|
-
expected = {user_id: "1", post_id: "1"}
|
46
|
-
expect(subject.
|
37
|
+
expected = {user_id: "1", post_id: "1", like_id: "1"}
|
38
|
+
expect(subject.params(stack)).to eq(expected)
|
47
39
|
end
|
48
40
|
end
|
49
41
|
end
|
@@ -3,7 +3,39 @@ require 'spec_helper'
|
|
3
3
|
module ShouldaRouting
|
4
4
|
module Routes
|
5
5
|
describe STACK do
|
6
|
-
it { should be_an_instance_of(
|
6
|
+
it { should be_an_instance_of(Stack) }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Stack do
|
10
|
+
it { subject.class.should include(Routes::Helpers) }
|
11
|
+
|
12
|
+
describe "#resources" do
|
13
|
+
it "returns a cached array" do
|
14
|
+
subject.resources.should eq []
|
15
|
+
subject.resources.push(:users)
|
16
|
+
subject.resources.should eq [:users]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#namespaces" do
|
21
|
+
it "returns a cached array" do
|
22
|
+
subject.namespaces.should eq []
|
23
|
+
subject.namespaces.push(:admin)
|
24
|
+
subject.namespaces.should eq [:admin]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#routes" do
|
29
|
+
pending
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "-#stack" do
|
33
|
+
it "returns an array with resources and namespaces" do
|
34
|
+
subject.stub(:namespaces).and_return([1,2,3])
|
35
|
+
subject.stub(:resources).and_return([4,5,6])
|
36
|
+
subject.send(:stack).should eq [1,2,3,4,5,6]
|
37
|
+
end
|
38
|
+
end
|
7
39
|
end
|
8
40
|
end
|
9
41
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoulda_routing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alejandro Gutiérrez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -121,14 +121,21 @@ files:
|
|
121
121
|
- LICENSE.txt
|
122
122
|
- README.md
|
123
123
|
- Rakefile
|
124
|
+
- features/integration.feature
|
124
125
|
- features/multiple_resources.feature
|
126
|
+
- features/namespaces.feature
|
127
|
+
- features/nested_namespaces.feature
|
125
128
|
- features/nested_resources.feature
|
126
129
|
- features/resources.feature
|
127
130
|
- features/resources_with_options.feature
|
131
|
+
- features/step_definitions/namespaces_steps.rb
|
128
132
|
- features/step_definitions/resources_steps.rb
|
129
133
|
- features/support/env.rb
|
130
134
|
- lib/shoulda_routing.rb
|
131
135
|
- lib/shoulda_routing/dsl.rb
|
136
|
+
- lib/shoulda_routing/namespaces/base.rb
|
137
|
+
- lib/shoulda_routing/namespaces/dsl.rb
|
138
|
+
- lib/shoulda_routing/namespaces/method.rb
|
132
139
|
- lib/shoulda_routing/resources/base.rb
|
133
140
|
- lib/shoulda_routing/resources/dsl.rb
|
134
141
|
- lib/shoulda_routing/resources/method.rb
|
@@ -138,6 +145,12 @@ files:
|
|
138
145
|
- lib/shoulda_routing/version.rb
|
139
146
|
- shoulda_routing.gemspec
|
140
147
|
- spec/shoulda_routing/dsl_spec.rb
|
148
|
+
- spec/shoulda_routing/namespaces/base_spec.rb
|
149
|
+
- spec/shoulda_routing/namespaces/dsl_spec.rb
|
150
|
+
- spec/shoulda_routing/namespaces/method_spec.rb
|
151
|
+
- spec/shoulda_routing/resources/base_spec.rb
|
152
|
+
- spec/shoulda_routing/resources/dsl_spec.rb
|
153
|
+
- spec/shoulda_routing/resources/method_spec.rb
|
141
154
|
- spec/shoulda_routing/routes/helpers_spec.rb
|
142
155
|
- spec/shoulda_routing/routes/stack_spec.rb
|
143
156
|
- spec/shoulda_routing_spec.rb
|
@@ -162,18 +175,28 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
175
|
version: '0'
|
163
176
|
requirements: []
|
164
177
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.0.
|
178
|
+
rubygems_version: 2.0.3
|
166
179
|
signing_key:
|
167
180
|
specification_version: 4
|
168
181
|
summary: A simple DSL to test rails routes.
|
169
182
|
test_files:
|
183
|
+
- features/integration.feature
|
170
184
|
- features/multiple_resources.feature
|
185
|
+
- features/namespaces.feature
|
186
|
+
- features/nested_namespaces.feature
|
171
187
|
- features/nested_resources.feature
|
172
188
|
- features/resources.feature
|
173
189
|
- features/resources_with_options.feature
|
190
|
+
- features/step_definitions/namespaces_steps.rb
|
174
191
|
- features/step_definitions/resources_steps.rb
|
175
192
|
- features/support/env.rb
|
176
193
|
- spec/shoulda_routing/dsl_spec.rb
|
194
|
+
- spec/shoulda_routing/namespaces/base_spec.rb
|
195
|
+
- spec/shoulda_routing/namespaces/dsl_spec.rb
|
196
|
+
- spec/shoulda_routing/namespaces/method_spec.rb
|
197
|
+
- spec/shoulda_routing/resources/base_spec.rb
|
198
|
+
- spec/shoulda_routing/resources/dsl_spec.rb
|
199
|
+
- spec/shoulda_routing/resources/method_spec.rb
|
177
200
|
- spec/shoulda_routing/routes/helpers_spec.rb
|
178
201
|
- spec/shoulda_routing/routes/stack_spec.rb
|
179
202
|
- spec/shoulda_routing_spec.rb
|