remarkable_rails 3.1.9 → 3.1.10

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.
@@ -1,100 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe ApplicationController, 'routing', :type => :routing do
4
-
5
- def controller
6
- @controller ||= ApplicationController.new
7
- end
8
-
9
- describe 'messages' do
10
- before(:each) do
11
- @matcher = route(:get, '/projects', :controller => 'boo', :action => 'index')
12
- end
13
-
14
- it 'should contain a description message' do
15
- @matcher.description.should match(/route GET "\/projects" to\/from/)
16
- end
17
-
18
- it 'should set map_to_path? message' do
19
- @matcher.matches?(nil)
20
- @matcher.failure_message.should match(/Expected to map/)
21
- end
22
-
23
- it 'should set generate_params? message' do
24
- @matcher.stub!(:map_to_path?).and_return(true)
25
- @matcher.matches?(controller)
26
- @matcher.failure_message.should match(/Expected to generate params/)
27
- end
28
- end
29
-
30
- describe 'matchers' do
31
- it { should route(:get, '/projects', :controller => :projects, :action => :index) }
32
- it { should route(:delete, '/projects/1', :controller => :projects, :action => :destroy, :id => 1) }
33
- it { should route(:get, '/projects/new', :controller => :projects, :action => :new) }
34
-
35
- # to syntax
36
- it { should route(:get, '/projects').to(:controller => :projects, :action => :index) }
37
- it { should route(:delete, '/projects/1').to(:controller => :projects, :action => :destroy, :id => 1) }
38
- it { should route(:get, '/projects/new').to(:controller => :projects, :action => :new) }
39
-
40
- # from syntax
41
- it { should route(:get, :controller => :projects, :action => :index).from('/projects') }
42
- it { should route(:delete, :controller => :projects, :action => :destroy, :id => 1).from('/projects/1') }
43
- it { should route(:get, :controller => :projects, :action => :new).from('/projects/new') }
44
-
45
- # explicitly specify :controller
46
- it { should route(:post, '/projects', :controller => :projects, :action => :create) }
47
-
48
- # non-string parameter
49
- it { should route(:get, '/projects/1', :controller => :projects, :action => :show, :id => 1) }
50
-
51
- # string-parameter
52
- it { should route(:put, '/projects/1', :controller => :projects, :action => :update, :id => "1") }
53
-
54
- # failing case
55
- it { should_not route(:get, '/projects', :controller => :projects, :action => :show) }
56
- it { should_not route(:xyz, '/projects', :controller => :projects, :action => :index) }
57
- end
58
-
59
- describe 'macros' do
60
- should_route :get, '/projects', :controller => :projects, :action => :index
61
- should_route :delete, '/projects/1', :controller => :projects, :action => :destroy, :id => 1
62
- should_route :get, '/projects/new', :controller => :projects, :action => :new
63
-
64
- # explicitly specify :controller
65
- should_route :post, '/projects', :controller => :projects, :action => :create
66
-
67
- # non-string parameter
68
- should_route :get, '/projects/1', :controller => :projects, :action => :show, :id => 1
69
-
70
- # string-parameter
71
- should_route :put, '/projects/1', :controller => :projects, :action => :update, :id => "1"
72
-
73
- # failing case
74
- should_not_route :get, '/projects', :controller => :projects, :action => :show
75
- should_not_route :xyz, '/projects', :controller => :projects, :action => :index
76
- end
77
-
78
- describe 'using controller.request' do
79
- it "should extract environment from controller request" do
80
- ActionController::Routing::Routes.should_receive(:extract_request_environment).with(controller.request).and_return({:subdomain => "foo"})
81
- ActionController::Routing::Routes.should_receive(:recognize_path).with("/projects", {:subdomain => "foo", :method => :get})
82
- route(:get, '/projects', :controller => 'projects', :action => 'index').matches?(controller)
83
- end
84
- end
85
- end
86
-
87
- # Test implicit controller
88
- describe TasksController, :type => :routing do
89
- should_route :get, '/projects/5/tasks', :action => :index, :project_id => 5
90
- should_route :post, '/projects/5/tasks', :action => :create, :project_id => 5
91
- should_route :get, '/projects/5/tasks/1', :action => :show, :id => 1, :project_id => 5
92
- should_route :delete, '/projects/5/tasks/1', :action => :destroy, :id => 1, :project_id => 5
93
- should_route :get, '/projects/5/tasks/new', :action => :new, :project_id => 5
94
- should_route :put, '/projects/5/tasks/1', :action => :update, :id => 1, :project_id => 5
95
-
96
- it "should use another controller name if it's given" do
97
- self.should_receive(:controller).and_return(ApplicationController.new)
98
- route(:get, '/').send(:controller_name).should == 'applications'
99
- end
100
- end
@@ -1,171 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe 'set_cookies' do
4
- include FunctionalBuilder
5
-
6
- describe 'messages' do
7
- before(:each) do
8
- @matcher = set_cookies(:user).to(1)
9
- end
10
-
11
- it 'should contain a description message' do
12
- @matcher = set_cookies(:user)
13
- @matcher.description.should == 'set cookies user'
14
-
15
- @matcher.to(1)
16
- @matcher.description.should == 'set cookies user to 1'
17
- end
18
-
19
- it 'should set is_not_empty? message' do
20
- build_response
21
- @matcher = set_cookies
22
- @matcher.matches?(@controller)
23
- @matcher.failure_message.should == 'Expected any cookie to be set, got {}'
24
- end
25
-
26
- it 'should set assigned_value? message' do
27
- build_response
28
- @matcher = set_cookies(:user)
29
- @matcher.matches?(@controller)
30
- @matcher.failure_message.should == 'Expected cookie user to be set, got {}'
31
- end
32
-
33
- if RAILS_VERSION =~ /^2.(1|2)/
34
- it 'should set contains_value? message' do
35
- build_response { cookies[:user] = 10 }
36
- @matcher = set_cookies.to(1)
37
- @matcher.matches?(@controller)
38
- @matcher.failure_message.should == 'Expected any cookie to be set to [1], got {:user=>[10]}'
39
- end
40
-
41
- it 'should set is_equal_value? message' do
42
- build_response { cookies[:user] = 2 }
43
- @matcher.matches?(@controller)
44
- @matcher.failure_message.should == 'Expected cookie user to be set to [1], got {:user=>[2]}'
45
- end
46
- else
47
- it 'should set contains_value? message' do
48
- build_response { cookies[:user] = 10 }
49
- @matcher = set_cookies.to(1)
50
- @matcher.matches?(@controller)
51
- @matcher.failure_message.should == 'Expected any cookie to be set to "1", got {:user=>"10"}'
52
- end
53
-
54
- it 'should set is_equal_value? message' do
55
- build_response { cookies[:user] = 2 }
56
- @matcher.matches?(@controller)
57
- @matcher.failure_message.should == 'Expected cookie user to be set to "1", got {:user=>"2"}'
58
- end
59
- end
60
- end
61
-
62
- describe 'matcher' do
63
- before(:each) do
64
- build_response {
65
- cookies[:user] = 'jose'
66
- cookies[:true] = true
67
- cookies[:false] = false
68
- cookies[:nil] = nil
69
- cookies[:array] = [1,2]
70
- cookies[:date] = Date.today
71
- }
72
- end
73
-
74
- it { should set_cookies }
75
- it { should set_cookies.to('jose') }
76
- it { should set_cookies(:user) }
77
- it { should set_cookies(:user).to('jose') }
78
-
79
- it { should_not set_cookies.to('joseph') }
80
- it { should_not set_cookies(:post) }
81
- it { should_not set_cookies(:user).to('joseph') }
82
-
83
- it { should set_cookies(:user){ 'jose' } }
84
- it { should set_cookies(:user, :to => proc{ 'jose' }) }
85
-
86
- it { should_not set_cookies(:user).to(nil) }
87
- it { should_not set_cookies(:user){ 'joseph' } }
88
- it { should_not set_cookies(:user, :to => proc{ 'joseph' }) }
89
-
90
- it { should set_cookies(:true) }
91
- it { should set_cookies(:true).to(true) }
92
- it { should_not set_cookies(:true).to(false) }
93
-
94
- it { should set_cookies(:false) }
95
- it { should set_cookies(:false).to(false) }
96
- it { should_not set_cookies(:false).to(true) }
97
-
98
- it { should set_cookies(:nil) }
99
- it { should set_cookies(:nil).to(nil) }
100
- it { should_not set_cookies(:nil).to(true) }
101
-
102
- it { should set_cookies(:array) }
103
- it { should set_cookies(:array).to([1,2]) }
104
- it { should_not set_cookies(:array).to([2,1]) }
105
-
106
- it { should set_cookies(:date) }
107
- it { should set_cookies(:date).to(Date.today) }
108
- it { should_not set_cookies(:date).to(Date.today + 1) }
109
- end
110
-
111
- describe 'macro' do
112
- before(:each) do
113
- build_response {
114
- cookies[:user] = 'jose'
115
- cookies[:true] = true
116
- cookies[:false] = false
117
- cookies[:nil] = nil
118
- cookies[:array] = [1,2]
119
- cookies[:date] = Date.today
120
- }
121
- end
122
-
123
- should_set_cookies
124
- should_set_cookies :to => 'jose'
125
- should_set_cookies :user
126
- should_set_cookies :user, :to => 'jose'
127
-
128
- should_not_set_cookies :to => 'joseph'
129
- should_not_set_cookies :post
130
- should_not_set_cookies :user, :to => 'joseph'
131
-
132
- should_set_cookies(:user){ 'jose' }
133
- should_set_cookies :user, :to => proc{ 'jose' }
134
- should_set_cookies :user do |m|
135
- m.to { 'jose' }
136
- end
137
-
138
- should_not_set_cookies :user, :to => nil
139
- should_not_set_cookies(:user){ 'joseph' }
140
- should_not_set_cookies :user, :to => proc{ 'joseph' }
141
-
142
- should_set_cookies :true
143
- should_set_cookies :true, :to => true
144
- should_not_set_cookies :true, :to => false
145
-
146
- should_set_cookies :false
147
- should_set_cookies :false, :to => false
148
- should_not_set_cookies :false, :to => true
149
-
150
- should_set_cookies :nil
151
- should_set_cookies :nil, :to => nil
152
- should_not_set_cookies :nil, :to => true
153
-
154
- should_set_cookies :array
155
- should_set_cookies :array, :to => [1,2]
156
- should_not_set_cookies :array, :to => [2,1]
157
-
158
- should_set_cookies :date
159
- should_set_cookies :date, :to => Date.today
160
- should_not_set_cookies :date, :to => (Date.today + 1)
161
- end
162
-
163
- describe 'with no parameter' do
164
- before(:each) { build_response }
165
-
166
- should_not_set_cookies
167
- it { should_not set_cookies }
168
- end
169
-
170
- generate_macro_stubs_specs_for(:set_cookies)
171
- end
@@ -1,157 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe 'set_session' do
4
- include FunctionalBuilder
5
-
6
- describe 'messages' do
7
- before(:each) do
8
- @matcher = set_session(:user).to(1)
9
- end
10
-
11
- it 'should contain a description message' do
12
- @matcher = set_session(:user)
13
- @matcher.description.should == 'set session variable user'
14
-
15
- @matcher.to(1)
16
- @matcher.description.should == 'set session variable user to 1'
17
- end
18
-
19
- it 'should set is_not_empty? message' do
20
- build_response
21
- @matcher = set_session
22
- @matcher.matches?(@controller)
23
- @matcher.failure_message.should == 'Expected any session variable to be set, got {}'
24
- end
25
-
26
- it 'should set contains_value? message' do
27
- build_response { session[:user] = 10 }
28
- @matcher = set_session.to(1)
29
- @matcher.matches?(@controller)
30
- @matcher.failure_message.should == 'Expected any session variable to be set to 1, got {:user=>10}'
31
- end
32
-
33
- it 'should set assigned_value? message' do
34
- build_response
35
- @matcher = set_session(:user)
36
- @matcher.matches?(@controller)
37
- @matcher.failure_message.should == 'Expected session variable user to be set, got {}'
38
- end
39
-
40
- it 'should set is_equal_value? message' do
41
- build_response { session[:user] = 2 }
42
- @matcher.matches?(@controller)
43
- @matcher.failure_message.should == 'Expected session variable user to be set to 1, got {:user=>2}'
44
- end
45
- end
46
-
47
- describe 'matcher' do
48
- before(:each) do
49
- build_response {
50
- session[:user] = 'jose'
51
- session[:true] = true
52
- session[:false] = false
53
- session[:nil] = nil
54
- session[:array] = [1,2]
55
- session[:date] = Date.today
56
- }
57
- end
58
-
59
- it { should set_session }
60
- it { should set_session.to('jose') }
61
- it { should set_session(:user) }
62
- it { should set_session(:user).to('jose') }
63
-
64
- it { should_not set_session.to('joseph') }
65
- it { should_not set_session(:post) }
66
- it { should_not set_session(:user).to('joseph') }
67
-
68
- it { should set_session(:user){ 'jose' } }
69
- it { should set_session(:user, :to => proc{ 'jose' }) }
70
-
71
- it { should_not set_session(:user).to(nil) }
72
- it { should_not set_session(:user){ 'joseph' } }
73
- it { should_not set_session(:user, :to => proc{ 'joseph' }) }
74
-
75
- it { should set_session(:true) }
76
- it { should set_session(:true).to(true) }
77
- it { should_not set_session(:true).to(false) }
78
-
79
- it { should set_session(:false) }
80
- it { should set_session(:false).to(false) }
81
- it { should_not set_session(:false).to(true) }
82
-
83
- it { should set_session(:nil) }
84
- it { should set_session(:nil).to(nil) }
85
- it { should_not set_session(:nil).to(true) }
86
-
87
- it { should set_session(:array) }
88
- it { should set_session(:array).to([1,2]) }
89
- it { should_not set_session(:array).to([2,1]) }
90
-
91
- it { should set_session(:date) }
92
- it { should set_session(:date).to(Date.today) }
93
- it { should_not set_session(:date).to(Date.today + 1) }
94
- end
95
-
96
- describe 'macro' do
97
- before(:each) do
98
- build_response {
99
- session[:user] = 'jose'
100
- session[:true] = true
101
- session[:false] = false
102
- session[:nil] = nil
103
- session[:array] = [1,2]
104
- session[:date] = Date.today
105
- }
106
- end
107
-
108
- should_set_session
109
- should_set_session :to => 'jose'
110
- should_set_session :user
111
- should_set_session :user, :to => 'jose'
112
-
113
- should_not_set_session :to => 'joseph'
114
- should_not_set_session :post
115
- should_not_set_session :user, :to => 'joseph'
116
-
117
- should_set_session(:user){ 'jose' }
118
- should_set_session :user, :to => proc{ 'jose' }
119
-
120
- should_set_session :user do |m|
121
- m.to { 'jose' }
122
- end
123
-
124
- should_not_set_session :user, :to => nil
125
- should_not_set_session(:user){ 'joseph' }
126
- should_not_set_session :user, :to => proc{ 'joseph' }
127
-
128
- should_set_session :true
129
- should_set_session :true, :to => true
130
- should_not_set_session :true, :to => false
131
-
132
- should_set_session :false
133
- should_set_session :false, :to => false
134
- should_not_set_session :false, :to => true
135
-
136
- should_set_session :nil
137
- should_set_session :nil, :to => nil
138
- should_not_set_session :nil, :to => true
139
-
140
- should_set_session :array
141
- should_set_session :array, :to => [1,2]
142
- should_not_set_session :array, :to => [2,1]
143
-
144
- should_set_session :date
145
- should_set_session :date, :to => Date.today
146
- should_not_set_session :date, :to => (Date.today + 1)
147
- end
148
-
149
- describe 'with no parameter' do
150
- before(:each) { build_response }
151
-
152
- should_not_set_session
153
- it { should_not set_session }
154
- end
155
-
156
- generate_macro_stubs_specs_for(:set_session)
157
- end
@@ -1,117 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe 'set_the_flash' do
4
- include FunctionalBuilder
5
-
6
- describe 'messages' do
7
- before(:each) do
8
- @matcher = set_the_flash(:notice).to('hi')
9
- end
10
-
11
- it 'should contain a description message' do
12
- @matcher = set_the_flash(:notice)
13
- @matcher.description.should == 'set the flash message notice'
14
-
15
- @matcher.to('hi')
16
- @matcher.description.should == 'set the flash message notice to "hi"'
17
- end
18
-
19
- it 'should set is_not_empty? message' do
20
- build_response
21
- @matcher = set_the_flash
22
- @matcher.matches?(@controller)
23
- @matcher.failure_message.should == 'Expected any flash message to be set, got {}'
24
- end
25
-
26
- it 'should set contains_value? message' do
27
- build_response { flash[:notice] = 'bye' }
28
- @matcher = set_the_flash.to('hi')
29
- @matcher.matches?(@controller)
30
- @matcher.failure_message.should == 'Expected any flash message to be set to "hi", got {:notice=>"bye"}'
31
- end
32
-
33
- it 'should set assigned_value? message' do
34
- build_response
35
- @matcher = set_the_flash(:notice)
36
- @matcher.matches?(@controller)
37
- @matcher.failure_message.should == 'Expected flash message notice to be set, got {}'
38
- end
39
-
40
- it 'should set is_equal_value? message' do
41
- build_response { flash[:notice] = 'bye' }
42
- @matcher.matches?(@controller)
43
- @matcher.failure_message.should == 'Expected flash message notice to be set to "hi", got {:notice=>"bye"}'
44
- end
45
- end
46
-
47
- describe 'matcher' do
48
- before(:each) { build_response { flash[:notice] = 'jose' } }
49
-
50
- it { should set_the_flash }
51
- it { should set_the_flash.to('jose') }
52
- it { should set_the_flash.to(/jose/) }
53
- it { should set_the_flash(:notice) }
54
- it { should set_the_flash(:notice).to('jose') }
55
- it { should set_the_flash(:notice).to(/jose/) }
56
-
57
- it { should_not set_the_flash.to('joseph') }
58
- it { should_not set_the_flash.to(/joseph/) }
59
- it { should_not set_the_flash(:error) }
60
- it { should_not set_the_flash(:notice).to('joseph') }
61
- it { should_not set_the_flash(:notice).to(/joseph/) }
62
-
63
- it { should set_the_flash{ 'jose' } }
64
- it { should set_the_flash{ /jose/ } }
65
- it { should set_the_flash(:notice){ 'jose' } }
66
- it { should set_the_flash(:notice){ /jose/ } }
67
- it { should set_the_flash(:notice, :to => proc{ 'jose' }) }
68
- it { should set_the_flash(:notice, :to => proc{ /jose/ }) }
69
-
70
- it { should_not set_the_flash(:notice).to(nil) }
71
- it { should_not set_the_flash(:notice){ 'joseph' } }
72
- it { should_not set_the_flash(:notice){ /joseph/ } }
73
- it { should_not set_the_flash(:notice, :to => proc{ 'joseph' }) }
74
- it { should_not set_the_flash(:notice, :to => proc{ /joseph/ }) }
75
- end
76
-
77
- describe 'macro' do
78
- before(:each) { build_response { flash[:notice] = 'jose' } }
79
-
80
- should_set_the_flash
81
- should_set_the_flash :to => 'jose'
82
- should_set_the_flash :to => /jose/
83
- should_set_the_flash :notice
84
- should_set_the_flash :notice, :to => 'jose'
85
- should_set_the_flash :notice, :to => /jose/
86
-
87
- should_not_set_the_flash :to => 'joseph'
88
- should_not_set_the_flash :to => /joseph/
89
- should_not_set_the_flash :error
90
- should_not_set_the_flash :notice, :to => 'joseph'
91
- should_not_set_the_flash :notice, :to => /joseph/
92
-
93
- should_set_the_flash(:notice){ 'jose' }
94
- should_set_the_flash(:notice){ /jose/ }
95
- should_set_the_flash :notice, :to => proc{ 'jose' }
96
- should_set_the_flash :notice, :to => proc{ /jose/ }
97
-
98
- should_set_the_flash :notice do |m|
99
- m.to = /jose/
100
- end
101
-
102
- should_not_set_the_flash :notice, :to => nil
103
- should_not_set_the_flash(:notice){ 'joseph' }
104
- should_not_set_the_flash(:notice){ /joseph/ }
105
- should_not_set_the_flash :notice, :to => proc{ 'joseph' }
106
- should_not_set_the_flash :notice, :to => proc{ /joseph/ }
107
- end
108
-
109
- describe 'with no parameter' do
110
- before(:each) { build_response }
111
-
112
- should_not_set_the_flash
113
- it { should_not set_the_flash }
114
- end
115
-
116
- generate_macro_stubs_specs_for(:set_the_flash)
117
- end