remarkable_rails 3.1.7 → 3.1.8
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ module Remarkable
|
|
6
6
|
arguments :method, :path
|
7
7
|
|
8
8
|
assertions :map_to_path?, :generate_params?
|
9
|
-
|
9
|
+
|
10
10
|
before_assert do
|
11
11
|
@options[:controller] ||= controller_name
|
12
12
|
@populated_path = @path.dup
|
@@ -17,15 +17,15 @@ module Remarkable
|
|
17
17
|
end
|
18
18
|
|
19
19
|
::ActionController::Routing::Routes.reload if ::ActionController::Routing::Routes.empty?
|
20
|
-
end
|
21
|
-
|
22
|
-
def controller
|
23
|
-
@controller ||= @spec.controller if @spec.respond_to?(:controller)
|
24
|
-
end
|
25
|
-
|
26
|
-
def request
|
27
|
-
controller.request if controller
|
28
|
-
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def controller
|
23
|
+
@controller ||= @spec.controller if @spec.respond_to?(:controller)
|
24
|
+
end
|
25
|
+
|
26
|
+
def request
|
27
|
+
controller.request if controller
|
28
|
+
end
|
29
29
|
|
30
30
|
private
|
31
31
|
|
@@ -35,10 +35,10 @@ module Remarkable
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def generate_params?
|
38
|
-
env = ::ActionController::Routing::Routes.extract_request_environment(controller.request) if controller
|
38
|
+
env = ::ActionController::Routing::Routes.extract_request_environment(controller.request) if controller
|
39
39
|
|
40
40
|
env ||= {}
|
41
|
-
env[:method] = @method.to_sym
|
41
|
+
env[:method] = @method.to_sym
|
42
42
|
params_from = ::ActionController::Routing::Routes.recognize_path(@populated_path, env) rescue nil
|
43
43
|
return params_from == @options, :actual => params_from.inspect
|
44
44
|
end
|
@@ -57,21 +57,21 @@ module Remarkable
|
|
57
57
|
raise ArgumentError, "I cannot guess the controller name in route. Please supply :controller as option"
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
61
|
-
def controller_class
|
62
|
-
@controller_class ||= begin
|
63
|
-
spec_class = @spec.class unless @spec.class == Class
|
64
|
-
|
65
|
-
attempts = []
|
66
|
-
attempts << controller.class if controller
|
67
|
-
attempts << @subject.class if @subject
|
68
|
-
attempts << spec_class.controller_class if spec_class.respond_to?(:controller_class)
|
69
|
-
attempts << spec_class.described_class if spec_class.respond_to?(:described_class)
|
70
|
-
|
71
|
-
attempts.find{ |controller| ::ActionController::Base >= controller }
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
60
|
+
|
61
|
+
def controller_class
|
62
|
+
@controller_class ||= begin
|
63
|
+
spec_class = @spec.class unless @spec.class == Class
|
64
|
+
|
65
|
+
attempts = []
|
66
|
+
attempts << controller.class if controller
|
67
|
+
attempts << @subject.class if @subject
|
68
|
+
attempts << spec_class.controller_class if spec_class.respond_to?(:controller_class)
|
69
|
+
attempts << spec_class.described_class if spec_class.respond_to?(:described_class)
|
70
|
+
|
71
|
+
attempts.find{ |controller| ::ActionController::Base >= controller }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
75
|
def interpolation_options
|
76
76
|
{ :options => @options.inspect, :method => @method.to_s.upcase, :path => @path.inspect }
|
77
77
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
|
-
describe 'route_matcher' do
|
4
|
-
|
5
|
-
|
3
|
+
describe 'route_matcher' do
|
4
|
+
controller_name :tasks
|
5
|
+
|
6
6
|
describe 'messages' do
|
7
7
|
before(:each) do
|
8
8
|
@matcher = route(:get, '/projects', :controller => 'boo', :action => 'index')
|
@@ -62,18 +62,6 @@ describe 'route_matcher' do
|
|
62
62
|
should_not_route :xyz, '/projects', :controller => :projects, :action => :index
|
63
63
|
end
|
64
64
|
|
65
|
-
describe TasksController, :type => :routing do
|
66
|
-
controller_name 'tasks'
|
67
|
-
|
68
|
-
# Test the nested routes with implicit controller
|
69
|
-
should_route :get, '/projects/5/tasks', :action => :index, :project_id => 5
|
70
|
-
should_route :post, '/projects/5/tasks', :action => :create, :project_id => 5
|
71
|
-
should_route :get, '/projects/5/tasks/1', :action => :show, :id => 1, :project_id => 5
|
72
|
-
should_route :delete, '/projects/5/tasks/1', :action => :destroy, :id => 1, :project_id => 5
|
73
|
-
should_route :get, '/projects/5/tasks/new', :action => :new, :project_id => 5
|
74
|
-
should_route :put, '/projects/5/tasks/1', :action => :update, :id => 1, :project_id => 5
|
75
|
-
end
|
76
|
-
|
77
65
|
describe 'using controller.request' do
|
78
66
|
it "should extract environment from controller request" do
|
79
67
|
@matcher = route(:get, '/projects', :controller => 'projects', :action => 'index')
|
@@ -82,5 +70,14 @@ describe 'route_matcher' do
|
|
82
70
|
@matcher.matches?(@controller)
|
83
71
|
end
|
84
72
|
end
|
85
|
-
|
86
|
-
|
73
|
+
end
|
74
|
+
|
75
|
+
# Test implicit controller
|
76
|
+
describe TasksController, :type => :routing do
|
77
|
+
should_route :get, '/projects/5/tasks', :action => :index, :project_id => 5
|
78
|
+
should_route :post, '/projects/5/tasks', :action => :create, :project_id => 5
|
79
|
+
should_route :get, '/projects/5/tasks/1', :action => :show, :id => 1, :project_id => 5
|
80
|
+
should_route :delete, '/projects/5/tasks/1', :action => :destroy, :id => 1, :project_id => 5
|
81
|
+
should_route :get, '/projects/5/tasks/new', :action => :new, :project_id => 5
|
82
|
+
should_route :put, '/projects/5/tasks/1', :action => :update, :id => 1, :project_id => 5
|
83
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,6 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
RAILS_ENV = 'test'
|
4
4
|
RAILS_VERSION = ENV['RAILS_VERSION'] || '2.3.2'
|
5
|
-
RSPEC_VERSION = ENV['RSPEC_VERSION'] || Spec::VERSION::STRING
|
6
5
|
|
7
6
|
# Load Rails
|
8
7
|
gem 'activesupport', RAILS_VERSION
|
@@ -32,8 +31,12 @@ require File.join(RAILS_ROOT, 'tasks_controller')
|
|
32
31
|
# Load Remarkable Rails
|
33
32
|
require File.join(dir, 'functional_builder')
|
34
33
|
|
35
|
-
# Load spec-rails
|
36
|
-
|
34
|
+
# Load spec-rails
|
35
|
+
if ENV['RSPEC_VERSION']
|
36
|
+
gem 'rspec-rails', ENV['RSPEC_VERSION']
|
37
|
+
else
|
38
|
+
gem 'rspec-rails'
|
39
|
+
end
|
37
40
|
require 'spec/rails'
|
38
41
|
|
39
42
|
require File.join(dir, '..', 'lib', 'remarkable_rails')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remarkable_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Brando
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-07-
|
13
|
+
date: 2009-07-16 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
requirements:
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: 3.1.
|
44
|
+
version: 3.1.8
|
45
45
|
version:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: remarkable_activerecord
|
@@ -51,7 +51,7 @@ dependencies:
|
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.1.
|
54
|
+
version: 3.1.8
|
55
55
|
version:
|
56
56
|
description: "Remarkable Rails: collection of matchers and macros with I18n for Rails"
|
57
57
|
email:
|