remarkable_rails 3.1.9 → 3.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- metadata +16 -40
- data/spec/action_controller/assign_to_matcher_spec.rb +0 -148
- data/spec/action_controller/filter_params_matcher_spec.rb +0 -64
- data/spec/action_controller/macro_stubs_spec.rb +0 -320
- data/spec/action_controller/redirect_to_matcher_spec.rb +0 -102
- data/spec/action_controller/render_template_matcher_spec.rb +0 -251
- data/spec/action_controller/respond_with_matcher_spec.rb +0 -230
- data/spec/action_controller/route_matcher_spec.rb +0 -100
- data/spec/action_controller/set_cookies_matcher_spec.rb +0 -171
- data/spec/action_controller/set_session_matcher_spec.rb +0 -157
- data/spec/action_controller/set_the_flash_matcher_spec.rb +0 -117
- data/spec/application/application.rb +0 -15
- data/spec/application/examples/_example.html.erb +0 -0
- data/spec/application/examples/example.html.erb +0 -0
- data/spec/application/examples/example.xml.builder +0 -0
- data/spec/application/examples/new.html.erb +0 -0
- data/spec/application/layouts/examples.html.erb +0 -0
- data/spec/application/projects/new.html.erb +0 -0
- data/spec/application/tasks_controller.rb +0 -39
- data/spec/application/vendor/gems/my_plugin/remarkable/my_plugin_locale.yml +0 -2
- data/spec/application/vendor/gems/my_plugin/remarkable/my_plugin_matchers.rb +0 -4
- data/spec/functional_builder.rb +0 -92
- data/spec/rcov.opts +0 -2
- data/spec/remarkable_rails_spec.rb +0 -11
- data/spec/spec.opts +0 -4
- data/spec/spec_helper.rb +0 -46
data/README
CHANGED
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.10
|
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-
|
13
|
+
date: 2009-10-01 00:00:00 -03: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.10
|
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.10
|
55
55
|
version:
|
56
56
|
description: "Remarkable Rails: collection of matchers and macros with I18n for Rails"
|
57
57
|
email:
|
@@ -69,22 +69,22 @@ files:
|
|
69
69
|
- README
|
70
70
|
- LICENSE
|
71
71
|
- CHANGELOG
|
72
|
-
- lib/remarkable_rails.rb
|
73
|
-
- lib/remarkable_rails/action_view/base.rb
|
74
|
-
- lib/remarkable_rails/action_controller/macro_stubs.rb
|
75
72
|
- lib/remarkable_rails/action_controller/base.rb
|
76
|
-
- lib/remarkable_rails/action_controller/
|
77
|
-
- lib/remarkable_rails/action_controller/matchers/set_the_flash_matcher.rb
|
78
|
-
- lib/remarkable_rails/action_controller/matchers/set_session_matcher.rb
|
79
|
-
- lib/remarkable_rails/action_controller/matchers/respond_with_matcher.rb
|
73
|
+
- lib/remarkable_rails/action_controller/macro_stubs.rb
|
80
74
|
- lib/remarkable_rails/action_controller/matchers/assign_to_matcher.rb
|
81
75
|
- lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb
|
82
76
|
- lib/remarkable_rails/action_controller/matchers/redirect_to_matcher.rb
|
83
|
-
- lib/remarkable_rails/action_controller/matchers/set_cookies_matcher.rb
|
84
77
|
- lib/remarkable_rails/action_controller/matchers/render_template_matcher.rb
|
85
|
-
- lib/remarkable_rails/
|
78
|
+
- lib/remarkable_rails/action_controller/matchers/respond_with_matcher.rb
|
79
|
+
- lib/remarkable_rails/action_controller/matchers/route_matcher.rb
|
80
|
+
- lib/remarkable_rails/action_controller/matchers/set_cookies_matcher.rb
|
81
|
+
- lib/remarkable_rails/action_controller/matchers/set_session_matcher.rb
|
82
|
+
- lib/remarkable_rails/action_controller/matchers/set_the_flash_matcher.rb
|
86
83
|
- lib/remarkable_rails/action_controller.rb
|
84
|
+
- lib/remarkable_rails/action_view/base.rb
|
85
|
+
- lib/remarkable_rails/action_view.rb
|
87
86
|
- lib/remarkable_rails/active_orm.rb
|
87
|
+
- lib/remarkable_rails.rb
|
88
88
|
- locale/en.yml
|
89
89
|
has_rdoc: true
|
90
90
|
homepage: http://github.com/carlosbrando/remarkable
|
@@ -110,33 +110,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
requirements: []
|
111
111
|
|
112
112
|
rubyforge_project: remarkable
|
113
|
-
rubygems_version: 1.3.
|
113
|
+
rubygems_version: 1.3.4
|
114
114
|
signing_key:
|
115
115
|
specification_version: 3
|
116
116
|
summary: "Remarkable Rails: collection of matchers and macros with I18n for Rails"
|
117
|
-
test_files:
|
118
|
-
|
119
|
-
- spec/application/examples/example.xml.builder
|
120
|
-
- spec/application/examples/_example.html.erb
|
121
|
-
- spec/application/examples/example.html.erb
|
122
|
-
- spec/application/application.rb
|
123
|
-
- spec/application/projects/new.html.erb
|
124
|
-
- spec/application/vendor/gems/my_plugin/remarkable/my_plugin_locale.yml
|
125
|
-
- spec/application/vendor/gems/my_plugin/remarkable/my_plugin_matchers.rb
|
126
|
-
- spec/application/layouts/examples.html.erb
|
127
|
-
- spec/application/tasks_controller.rb
|
128
|
-
- spec/action_controller/macro_stubs_spec.rb
|
129
|
-
- spec/action_controller/assign_to_matcher_spec.rb
|
130
|
-
- spec/action_controller/set_cookies_matcher_spec.rb
|
131
|
-
- spec/action_controller/set_session_matcher_spec.rb
|
132
|
-
- spec/action_controller/redirect_to_matcher_spec.rb
|
133
|
-
- spec/action_controller/route_matcher_spec.rb
|
134
|
-
- spec/action_controller/render_template_matcher_spec.rb
|
135
|
-
- spec/action_controller/respond_with_matcher_spec.rb
|
136
|
-
- spec/action_controller/filter_params_matcher_spec.rb
|
137
|
-
- spec/action_controller/set_the_flash_matcher_spec.rb
|
138
|
-
- spec/rcov.opts
|
139
|
-
- spec/spec_helper.rb
|
140
|
-
- spec/functional_builder.rb
|
141
|
-
- spec/spec.opts
|
142
|
-
- spec/remarkable_rails_spec.rb
|
117
|
+
test_files: []
|
118
|
+
|
@@ -1,148 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe 'assign_to' do
|
4
|
-
include FunctionalBuilder
|
5
|
-
|
6
|
-
describe 'messages' do
|
7
|
-
before(:each) do
|
8
|
-
@matcher = assign_to(:user).with('jose').with_kind_of(String)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should contain a description message' do
|
12
|
-
@matcher = assign_to(:user)
|
13
|
-
@matcher.description.should == 'assign user'
|
14
|
-
|
15
|
-
@matcher.with_kind_of(String)
|
16
|
-
@matcher.description.should == 'assign user with kind of String'
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should set assigned_value? message' do
|
20
|
-
build_response
|
21
|
-
@matcher = assign_to(:user)
|
22
|
-
@matcher.matches?(@controller)
|
23
|
-
@matcher.failure_message.should == 'Expected action to assign user, got no assignment'
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should set is_kind_of? message' do
|
27
|
-
build_response { @user = 1 }
|
28
|
-
@matcher.matches?(@controller)
|
29
|
-
@matcher.failure_message.should == 'Expected assign user to be kind of String, got a Fixnum'
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should set is_equal_value? message' do
|
33
|
-
build_response { @user = 'joseph' }
|
34
|
-
@matcher.matches?(@controller)
|
35
|
-
@matcher.failure_message.should == 'Expected assign user to be equal to "jose", got "joseph"'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'matcher' do
|
40
|
-
before(:each) do
|
41
|
-
build_response {
|
42
|
-
@user = 'jose'
|
43
|
-
@true = true
|
44
|
-
@false = false
|
45
|
-
@nil = nil
|
46
|
-
}
|
47
|
-
end
|
48
|
-
|
49
|
-
it { should assign_to(:user) }
|
50
|
-
it { should assign_to(:user).with('jose') }
|
51
|
-
it { should assign_to(:user).with_kind_of(String) }
|
52
|
-
|
53
|
-
it { should_not assign_to(:post) }
|
54
|
-
it { should_not assign_to(:user).with('joseph') }
|
55
|
-
it { should_not assign_to(:user).with_kind_of(Fixnum) }
|
56
|
-
|
57
|
-
it { should assign_to(:user){ 'jose' } }
|
58
|
-
it { should assign_to(:user, :with => proc{ 'jose' }) }
|
59
|
-
|
60
|
-
it { should_not assign_to(:user).with(nil) }
|
61
|
-
it { should_not assign_to(:user){ 'joseph' } }
|
62
|
-
it { should_not assign_to(:user, :with => proc{ 'joseph' }) }
|
63
|
-
|
64
|
-
it { should assign_to(:true) }
|
65
|
-
it { should assign_to(:true).with(true) }
|
66
|
-
it { should_not assign_to(:true).with(false) }
|
67
|
-
|
68
|
-
it { should assign_to(:false) }
|
69
|
-
it { should assign_to(:false).with(false) }
|
70
|
-
it { should_not assign_to(:false).with(true) }
|
71
|
-
|
72
|
-
it { should assign_to(:nil) }
|
73
|
-
it { should assign_to(:nil).with(nil) }
|
74
|
-
it { should_not assign_to(:nil).with(true) }
|
75
|
-
end
|
76
|
-
|
77
|
-
describe 'macro' do
|
78
|
-
before(:each) do
|
79
|
-
build_response {
|
80
|
-
@user = 'jose'
|
81
|
-
@true = true
|
82
|
-
@false = false
|
83
|
-
@nil = nil
|
84
|
-
}
|
85
|
-
end
|
86
|
-
|
87
|
-
should_assign_to :user
|
88
|
-
should_assign_to :user, :with => 'jose'
|
89
|
-
should_assign_to :user, :with_kind_of => String
|
90
|
-
|
91
|
-
should_assign_to :user do |m|
|
92
|
-
m.with { 'jose' }
|
93
|
-
m.with_kind_of String
|
94
|
-
end
|
95
|
-
|
96
|
-
should_not_assign_to :post
|
97
|
-
should_not_assign_to :user, :with => 'joseph'
|
98
|
-
should_not_assign_to :user, :with_kind_of => Fixnum
|
99
|
-
|
100
|
-
should_assign_to(:user){ 'jose' }
|
101
|
-
should_assign_to :user, :with => proc{ 'jose' }
|
102
|
-
|
103
|
-
should_not_assign_to :user, :with => nil
|
104
|
-
should_not_assign_to(:user){ 'joseph' }
|
105
|
-
should_not_assign_to :user, :with => proc{ 'joseph' }
|
106
|
-
|
107
|
-
should_assign_to :true
|
108
|
-
should_assign_to :true, :with => true
|
109
|
-
should_not_assign_to :true, :with => false
|
110
|
-
|
111
|
-
should_assign_to :false
|
112
|
-
should_assign_to :false, :with => false
|
113
|
-
should_not_assign_to :false, :with => true
|
114
|
-
|
115
|
-
should_assign_to :nil
|
116
|
-
should_assign_to :nil, :with => nil
|
117
|
-
should_not_assign_to :nil, :with => true
|
118
|
-
end
|
119
|
-
|
120
|
-
describe 'macro stubs' do
|
121
|
-
before(:each) do
|
122
|
-
@controller = TasksController.new
|
123
|
-
@request = ActionController::TestRequest.new
|
124
|
-
@response = ActionController::TestResponse.new
|
125
|
-
end
|
126
|
-
|
127
|
-
expects :new, :on => String, :with => 'ola', :returns => 'ola'
|
128
|
-
get :new
|
129
|
-
|
130
|
-
it 'should run expectations by default' do
|
131
|
-
String.should_receive(:should_receive).with(:new).and_return(@mock=mock('chain'))
|
132
|
-
@mock.should_receive(:with).with('ola').and_return(@mock)
|
133
|
-
@mock.should_receive(:exactly).with(1).and_return(@mock)
|
134
|
-
@mock.should_receive(:times).and_return(@mock)
|
135
|
-
@mock.should_receive(:and_return).with('ola').and_return('ola')
|
136
|
-
|
137
|
-
assign_to(:user).matches?(@controller)
|
138
|
-
end
|
139
|
-
|
140
|
-
it 'should run stubs' do
|
141
|
-
String.should_receive(:stub!).with(:new).and_return(@mock=mock('chain'))
|
142
|
-
@mock.should_receive(:and_return).with('ola').and_return('ola')
|
143
|
-
|
144
|
-
assign_to(:user, :with_stubs => true).matches?(@controller)
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe 'filter_params' do
|
4
|
-
include FunctionalBuilder
|
5
|
-
|
6
|
-
describe 'messages' do
|
7
|
-
before(:each) do
|
8
|
-
@controller = define_controller :Posts do
|
9
|
-
filter_parameter_logging :password
|
10
|
-
end.new
|
11
|
-
|
12
|
-
@matcher = filter_params(:user)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should contain a description message' do
|
16
|
-
@matcher.description.should == 'filter user parameters from log'
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should set respond_to_filter_params? message' do
|
20
|
-
@controller = define_controller(:Comments).new
|
21
|
-
@matcher.matches?(@controller)
|
22
|
-
@matcher.failure_message.should == 'Expected controller to respond to filter_parameters (controller is not filtering any parameter)'
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should set is_filtered? message' do
|
26
|
-
@matcher.matches?(@controller)
|
27
|
-
@matcher.failure_message.should == 'Expected user to be filtered, got no filtering'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe 'filtering parameter' do
|
32
|
-
before(:each) do
|
33
|
-
@controller = define_controller :Comments do
|
34
|
-
filter_parameter_logging :password
|
35
|
-
end.new
|
36
|
-
|
37
|
-
self.class.subject { @controller }
|
38
|
-
end
|
39
|
-
|
40
|
-
should_filter_params
|
41
|
-
should_filter_params(:password)
|
42
|
-
should_not_filter_params(:user)
|
43
|
-
|
44
|
-
it { should filter_params }
|
45
|
-
it { should filter_params(:password) }
|
46
|
-
it { should_not filter_params(:user) }
|
47
|
-
end
|
48
|
-
|
49
|
-
describe 'not filtering any parameter' do
|
50
|
-
before(:each) do
|
51
|
-
@controller = define_controller(:Comments).new
|
52
|
-
self.class.subject { @controller }
|
53
|
-
end
|
54
|
-
|
55
|
-
should_not_filter_params
|
56
|
-
should_not_filter_params(:password)
|
57
|
-
should_not_filter_params(:user)
|
58
|
-
|
59
|
-
it { should_not filter_params }
|
60
|
-
it { should_not filter_params(:user) }
|
61
|
-
it { should_not filter_params(:password) }
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
@@ -1,320 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
# Define a metaclass in the Object because we are going to need it.
|
4
|
-
class Object; def metaclass; class << self; self; end; end; end
|
5
|
-
|
6
|
-
describe 'MacroStubs' do
|
7
|
-
controller_name 'tasks'
|
8
|
-
mock_models :task
|
9
|
-
|
10
|
-
def current_id; '37'; end
|
11
|
-
|
12
|
-
describe 'mock_models' do
|
13
|
-
before(:each) do
|
14
|
-
self.class.metaclass.send(:undef_method, :projects_proc) if self.class.respond_to?(:projects_proc)
|
15
|
-
self.class.metaclass.send(:undef_method, :project_proc) if self.class.respond_to?(:project_proc)
|
16
|
-
self.class.send(:undef_method, :mock_project) if self.respond_to?(:mock_project)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should alias model_proc to mock_model' do
|
20
|
-
self.class.respond_to?(:mock_project).should be_false
|
21
|
-
self.class.respond_to?(:mock_projects).should be_false
|
22
|
-
self.class.mock_models :project
|
23
|
-
self.class.respond_to?(:mock_project).should be_true
|
24
|
-
self.class.respond_to?(:mock_projects).should be_true
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should create a class singular proc method' do
|
28
|
-
self.class.respond_to?(:project_proc).should be_false
|
29
|
-
self.class.mock_models :project
|
30
|
-
self.class.respond_to?(:project_proc).should be_true
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should create a class plural proc method' do
|
34
|
-
self.class.respond_to?(:projects_proc).should be_false
|
35
|
-
self.class.mock_models :project
|
36
|
-
self.class.respond_to?(:projects_proc).should be_true
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should create an instance mock method' do
|
40
|
-
self.respond_to?(:mock_project).should be_false
|
41
|
-
self.class.mock_models :project
|
42
|
-
self.respond_to?(:mock_project).should be_true
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should create just an instance method when :class_method is false' do
|
46
|
-
self.class.respond_to?(:project_proc).should be_false
|
47
|
-
self.respond_to?(:mock_project).should be_false
|
48
|
-
self.class.mock_models :project, :class_method => false
|
49
|
-
self.class.respond_to?(:project_proc).should be_false
|
50
|
-
self.respond_to?(:mock_project).should be_true
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should allow the mock class to be set' do
|
54
|
-
self.class.mock_model :project, :as => "::Admin::Project"
|
55
|
-
lambda{
|
56
|
-
mock_project
|
57
|
-
}.should raise_error(NameError, "uninitialized constant Admin")
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'should create procs which evals to a mock' do
|
61
|
-
proc = self.class.task_proc
|
62
|
-
proc.should be_kind_of(Proc)
|
63
|
-
|
64
|
-
@task.should be_nil
|
65
|
-
instance_eval(&proc).should == mock_task
|
66
|
-
@task.should_not be_nil
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should create procs which evals to an array of mocks' do
|
70
|
-
proc = self.class.tasks_proc
|
71
|
-
proc.should be_kind_of(Proc)
|
72
|
-
|
73
|
-
@task.should be_nil
|
74
|
-
instance_eval(&proc).should == [ mock_task ]
|
75
|
-
@task.should == mock_task
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe 'failures' do
|
80
|
-
expects :find, :on => Task, :with => proc{ current_id }, :returns => task_proc
|
81
|
-
expects :max, :min, :count, :on => Task, :ordered => true
|
82
|
-
|
83
|
-
get :show, :id => 37
|
84
|
-
|
85
|
-
it 'should fail if expectation is not met' do
|
86
|
-
self.stub!(:current_id).and_return("42")
|
87
|
-
|
88
|
-
lambda {
|
89
|
-
run_action!(true)
|
90
|
-
}.should raise_error(Spec::Mocks::MockExpectationError, /expected :find with \("42"\) but received it with \("37"\)/)
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'should fail if expectations are received out of order' do
|
94
|
-
lambda {
|
95
|
-
run_action!(true)
|
96
|
-
}.should raise_error(Spec::Mocks::MockExpectationError, /received :count out of order/)
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should splat an array given to with' do
|
100
|
-
self.stub!(:current_id).and_return([1, 2, 3])
|
101
|
-
run_expectations!
|
102
|
-
|
103
|
-
lambda {
|
104
|
-
Task.find([1,2,3])
|
105
|
-
}.should raise_error(Spec::Mocks::MockExpectationError, /expected :find with \(1\, 2\, 3\) but received it with \(\[1\, 2\, 3\]\)/)
|
106
|
-
|
107
|
-
lambda {
|
108
|
-
Task.find(1, 2, 3)
|
109
|
-
}.should_not raise_error
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'should not splat hashes' do
|
113
|
-
self.stub!(:current_id).and_return('login' => 'login')
|
114
|
-
run_expectations!
|
115
|
-
|
116
|
-
lambda {
|
117
|
-
Task.find('login' => 'login')
|
118
|
-
}.should_not raise_error
|
119
|
-
end
|
120
|
-
|
121
|
-
after(:each) do
|
122
|
-
teardown_mocks_for_rspec
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
describe 'with array in options' do
|
127
|
-
expects :find, :on => Task, :with => [proc{ current_id }, 1], :returns => [proc{ current_id }, 2]
|
128
|
-
|
129
|
-
it 'should evaluate all procs in :with option' do
|
130
|
-
run_expectations!
|
131
|
-
|
132
|
-
lambda {
|
133
|
-
Task.find(1)
|
134
|
-
}.should raise_error(Spec::Mocks::MockExpectationError, /expected :find with \("37"\, 1\) but received it with \(1\)/)
|
135
|
-
|
136
|
-
lambda {
|
137
|
-
Task.find("37", 1)
|
138
|
-
}.should_not raise_error
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'should evaluate all procs in :returns option' do
|
142
|
-
run_expectations!
|
143
|
-
|
144
|
-
Task.find("37", 1).should eql(["37", 2])
|
145
|
-
end
|
146
|
-
|
147
|
-
after(:each) do
|
148
|
-
teardown_mocks_for_rspec
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe 'when extending describe group behavior' do
|
153
|
-
expects :find, :on => Task, :with => proc{ current_id }, :returns => task_proc
|
154
|
-
expects :count, :max, :min, :on => Task
|
155
|
-
|
156
|
-
get :show, :id => 37
|
157
|
-
params :special_task_id => 42
|
158
|
-
mime Mime::HTML
|
159
|
-
|
160
|
-
it 'should run action declared in a class method' do
|
161
|
-
@controller.send(:performed?).should_not be_true
|
162
|
-
|
163
|
-
run_action!(false)
|
164
|
-
|
165
|
-
@controller.action_name.should == 'show'
|
166
|
-
@controller.request.method.should == :get
|
167
|
-
@controller.send(:performed?).should be_true
|
168
|
-
end
|
169
|
-
|
170
|
-
it 'should raise an error if an invalid key is supplied' do
|
171
|
-
lambda {
|
172
|
-
self.class.expects :find, :on => Task, :and_return => true
|
173
|
-
}.should raise_error(ArgumentError, "Unknown key(s): and_return")
|
174
|
-
end
|
175
|
-
|
176
|
-
it 'should use parameters given in params on request' do
|
177
|
-
self.should_receive(:current_id).once.and_return('37')
|
178
|
-
run_action!
|
179
|
-
@request.parameters[:special_task_id].should == '42'
|
180
|
-
end
|
181
|
-
|
182
|
-
it 'should respond with the supplied mime type' do
|
183
|
-
self.should_receive(:current_id).once.and_return('37')
|
184
|
-
run_action!
|
185
|
-
@response.content_type.should == Mime::HTML.to_s
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'should run action with expectations' do
|
189
|
-
self.should_receive(:current_id).once.and_return('37')
|
190
|
-
run_action!
|
191
|
-
@controller.send(:performed?).should be_true
|
192
|
-
end
|
193
|
-
|
194
|
-
it 'should not run action twice' do
|
195
|
-
run_action!
|
196
|
-
@controller.send(:performed?).should be_true
|
197
|
-
proc{ run_action!.should be_false }.should_not raise_error
|
198
|
-
end
|
199
|
-
|
200
|
-
it 'should run expectations without performing an action' do
|
201
|
-
self.should_receive(:current_id).once.and_return('37')
|
202
|
-
run_expectations!
|
203
|
-
@controller.send(:performed?).should_not be_true
|
204
|
-
get :show, :id => '37' # Execute the action to match expectations
|
205
|
-
end
|
206
|
-
|
207
|
-
it 'should run action with stubs' do
|
208
|
-
self.should_receive(:current_id).never
|
209
|
-
run_action!(false)
|
210
|
-
@controller.send(:performed?).should be_true
|
211
|
-
end
|
212
|
-
|
213
|
-
it 'should run stubs without performing an action' do
|
214
|
-
self.should_receive(:current_id).never
|
215
|
-
run_stubs!
|
216
|
-
@controller.send(:performed?).should_not be_true
|
217
|
-
end
|
218
|
-
|
219
|
-
describe Mime::XML do
|
220
|
-
expects :to_xml, :on => task_proc, :returns => 'XML'
|
221
|
-
|
222
|
-
it 'should provide a description based on the mime given in describe' do
|
223
|
-
self.class.description.should =~ /with xml$/
|
224
|
-
end
|
225
|
-
|
226
|
-
it 'should run action based on inherited declarations' do
|
227
|
-
@controller.send(:performed?).should_not be_true
|
228
|
-
|
229
|
-
run_action!
|
230
|
-
|
231
|
-
@controller.action_name.should == 'show'
|
232
|
-
@controller.request.method.should == :get
|
233
|
-
@controller.send(:performed?).should be_true
|
234
|
-
@controller.response.body.should == 'XML'
|
235
|
-
@request.parameters[:special_task_id].should == '42'
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
describe 'and running actions in a before(:all) filter' do
|
240
|
-
get :show, :id => 37
|
241
|
-
|
242
|
-
get! do
|
243
|
-
@request.should_not be_nil
|
244
|
-
end
|
245
|
-
|
246
|
-
get! do
|
247
|
-
@flag = true
|
248
|
-
end
|
249
|
-
|
250
|
-
get! do
|
251
|
-
@controller.should_not be_nil
|
252
|
-
end
|
253
|
-
|
254
|
-
it 'should run the action before each example' do
|
255
|
-
@controller.send(:performed?).should be_true
|
256
|
-
end
|
257
|
-
|
258
|
-
it 'should execute the given block' do
|
259
|
-
@flag.should be_true
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
describe 'with matcher macros' do
|
265
|
-
|
266
|
-
[:delete, :delete!].each do |method|
|
267
|
-
|
268
|
-
describe method => :destroy, :id => '37' do
|
269
|
-
expects :find, :on => Task, :with => '37', :returns => task_proc
|
270
|
-
expects :destroy, :on => task_proc
|
271
|
-
expects :title, :on => task_proc, :with => false do |boolean|
|
272
|
-
if boolean
|
273
|
-
'This should not appear'
|
274
|
-
else
|
275
|
-
'My favourite task'
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
xhr!
|
280
|
-
subject { controller }
|
281
|
-
|
282
|
-
should_assign_to :task
|
283
|
-
should_assign_to :task, :with => task_proc
|
284
|
-
should_assign_to :task, :with_kind_of => Task
|
285
|
-
|
286
|
-
should_set_the_flash
|
287
|
-
should_set_the_flash :notice
|
288
|
-
should_set_the_flash :notice, :to => %{"My favourite task" was removed}
|
289
|
-
|
290
|
-
should_set_session
|
291
|
-
should_set_session :last_task_id
|
292
|
-
should_set_session :last_task_id, :to => 37
|
293
|
-
|
294
|
-
should_redirect_to{ project_tasks_url(10) }
|
295
|
-
should_redirect_to proc{ project_tasks_url(10) }, :with => 302
|
296
|
-
|
297
|
-
it 'should run action declared in describe' do
|
298
|
-
@controller.send(:performed?).should_not be_true unless method == :delete!
|
299
|
-
|
300
|
-
run_action!
|
301
|
-
|
302
|
-
@controller.action_name.should == 'destroy'
|
303
|
-
@controller.request.method.should == :delete
|
304
|
-
@controller.send(:performed?).should be_true
|
305
|
-
end
|
306
|
-
|
307
|
-
it 'should provide a description based on parameters given in describe' do
|
308
|
-
self.class.description.should =~ /responding to #DELETE destroy$/
|
309
|
-
end
|
310
|
-
|
311
|
-
it 'should perform a XmlHttpRequest' do
|
312
|
-
run_action!
|
313
|
-
request.env['HTTP_X_REQUESTED_WITH'].should == 'XMLHttpRequest'
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
|
-
end
|
318
|
-
|
319
|
-
end
|
320
|
-
end
|