Objective3-objective_spec 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/generators/objective_service/templates/controller_spec.rb +20 -20
- data/objective_spec.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' *
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
|
2
2
|
|
3
|
-
describe <%=
|
3
|
+
describe <%= class_name %>Controller do
|
4
4
|
describe "handling GET /<%= table_name %>" do
|
5
5
|
|
6
6
|
it "should be successful" do
|
7
7
|
<%= file_name %> = Factory(:<%= file_name %>)
|
8
|
-
<%=
|
8
|
+
<%= class_name.singularize %>.stub!(:find).and_return([<%= file_name %>])
|
9
9
|
get :index, :format => 'xml'
|
10
10
|
response.should be_success
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should find all <%= table_name %>" do
|
14
14
|
<%= file_name %> = Factory(:<%= file_name %>)
|
15
|
-
<%=
|
15
|
+
<%= class_name.singularize %>.should_receive(:find).with(:all).and_return([<%= file_name %>])
|
16
16
|
get :index, :format => 'xml'
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should assign the found <%= table_name %> for the view" do
|
20
20
|
<%= file_name %> = Factory(:<%= file_name %>)
|
21
|
-
<%=
|
21
|
+
<%= class_name.singularize %>.stub!(:find).and_return([<%= file_name %>])
|
22
22
|
get :index, :format => 'xml'
|
23
23
|
assigns[:<%= table_name %>].should == [<%= file_name %>]
|
24
24
|
end
|
@@ -28,20 +28,20 @@ describe <%= controller_class_name %>Controller do
|
|
28
28
|
|
29
29
|
it "should be successful" do
|
30
30
|
<%= file_name %> = Factory(:<%= file_name %>)
|
31
|
-
<%=
|
31
|
+
<%= class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
32
32
|
get :show, :id => "1", :format => 'xml'
|
33
33
|
response.should be_success
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should find the <%= file_name %> requested" do
|
37
37
|
<%= file_name %> = Factory(:<%= file_name %>)
|
38
|
-
<%=
|
38
|
+
<%= class_name.singularize %>.should_receive(:find).with("1").and_return(<%= file_name %>)
|
39
39
|
get :show, :id => "1", :format => 'xml'
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should assign the found <%= file_name %> for the view" do
|
43
43
|
<%= file_name %> = Factory(:<%= file_name %>)
|
44
|
-
<%=
|
44
|
+
<%= class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
45
45
|
get :show, :id => "1", :format => 'xml'
|
46
46
|
assigns[:<%= file_name %>].should equal(<%= file_name %>)
|
47
47
|
end
|
@@ -54,7 +54,7 @@ describe <%= controller_class_name %>Controller do
|
|
54
54
|
it "should create a new <%= file_name %>" do
|
55
55
|
<%= file_name %> = Factory(:<%= file_name %>)
|
56
56
|
<%= file_name %>.stub!(:to_param).and_return("1")
|
57
|
-
<%=
|
57
|
+
<%= class_name.singularize %>.should_receive(:new).with({}).and_return(<%= file_name %>)
|
58
58
|
<%= file_name %>.should_receive(:save).and_return(true)
|
59
59
|
post :create, :<%= file_name %> => {}, :format => 'xml'
|
60
60
|
end
|
@@ -62,7 +62,7 @@ describe <%= controller_class_name %>Controller do
|
|
62
62
|
it "should be successful" do
|
63
63
|
<%= file_name %> = Factory(:<%= file_name %>)
|
64
64
|
<%= file_name %>.stub!(:to_param).and_return("1")
|
65
|
-
<%=
|
65
|
+
<%= class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
|
66
66
|
<%= file_name %>.should_receive(:save).and_return(true)
|
67
67
|
post :create, :<%= file_name %> => {}, :format => 'xml'
|
68
68
|
response.should be_success
|
@@ -75,7 +75,7 @@ describe <%= controller_class_name %>Controller do
|
|
75
75
|
it "should be unprocessable" do
|
76
76
|
<%= file_name %> = Factory(:<%= file_name %>)
|
77
77
|
<%= file_name %>.stub!(:to_param).and_return("1")
|
78
|
-
<%=
|
78
|
+
<%= class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
|
79
79
|
<%= file_name %>.should_receive(:save).and_return(false)
|
80
80
|
post :create, :<%= file_name %> => {}, :format => 'xml'
|
81
81
|
response.code.should == '422'
|
@@ -84,7 +84,7 @@ describe <%= controller_class_name %>Controller do
|
|
84
84
|
it "should return errors" do
|
85
85
|
<%= file_name %> = Factory(:<%= file_name %>)
|
86
86
|
<%= file_name %>.stub!(:to_param).and_return("1")
|
87
|
-
<%=
|
87
|
+
<%= class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
|
88
88
|
<%= file_name %>.should_receive(:save).and_return(false)
|
89
89
|
post :create, :<%= file_name %> => {}, :format => 'xml'
|
90
90
|
Nokogiri::XML(response.should).at('errors').should_not be_nil
|
@@ -100,7 +100,7 @@ describe <%= controller_class_name %>Controller do
|
|
100
100
|
it "should find the <%= file_name %> requested" do
|
101
101
|
<%= file_name %> = Factory(:<%= file_name %>)
|
102
102
|
<%= file_name %>.stub!(:to_param).and_return("1")
|
103
|
-
<%=
|
103
|
+
<%= class_name.singularize %>.should_receive(:find).with("1").and_return(<%= file_name %>)
|
104
104
|
<%= file_name %>.should_receive(:update_attributes).and_return(true)
|
105
105
|
put :update, :id => "1", :format => 'xml'
|
106
106
|
end
|
@@ -108,7 +108,7 @@ describe <%= controller_class_name %>Controller do
|
|
108
108
|
it "should update the found <%= file_name %>" do
|
109
109
|
<%= file_name %> = Factory(:<%= file_name %>)
|
110
110
|
<%= file_name %>.stub!(:to_param).and_return("1")
|
111
|
-
<%=
|
111
|
+
<%= class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
112
112
|
<%= file_name %>.should_receive(:update_attributes).and_return(true)
|
113
113
|
put :update, :id => "1", :format => 'xml'
|
114
114
|
assigns(:<%= file_name %>).should equal(<%= file_name %>)
|
@@ -117,7 +117,7 @@ describe <%= controller_class_name %>Controller do
|
|
117
117
|
it "should assign the found <%= file_name %> for the view" do
|
118
118
|
<%= file_name %> = Factory(:<%= file_name %>)
|
119
119
|
<%= file_name %>.stub!(:to_param).and_return("1")
|
120
|
-
<%=
|
120
|
+
<%= class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
121
121
|
<%= file_name %>.should_receive(:update_attributes).and_return(true)
|
122
122
|
put :update, :id => "1", :format => 'xml'
|
123
123
|
assigns(:<%= file_name %>).should equal(<%= file_name %>)
|
@@ -126,7 +126,7 @@ describe <%= controller_class_name %>Controller do
|
|
126
126
|
it "should be successful" do
|
127
127
|
<%= file_name %> = Factory(:<%= file_name %>)
|
128
128
|
<%= file_name %>.stub!(:to_param).and_return("1")
|
129
|
-
<%=
|
129
|
+
<%= class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
130
130
|
<%= file_name %>.should_receive(:update_attributes).and_return(true)
|
131
131
|
put :update, :id => "1", :format => 'xml'
|
132
132
|
response.should be_success
|
@@ -139,7 +139,7 @@ describe <%= controller_class_name %>Controller do
|
|
139
139
|
it "should render errors" do
|
140
140
|
<%= file_name %> = Factory(:<%= file_name %>)
|
141
141
|
<%= file_name %>.stub!(:to_param).and_return("1")
|
142
|
-
<%=
|
142
|
+
<%= class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
143
143
|
<%= file_name %>.should_receive(:update_attributes).and_return(false)
|
144
144
|
put :update, :id => "1", :format => 'xml'
|
145
145
|
Nokogiri::XML(response.body).at('errors').should_not be_nil
|
@@ -153,13 +153,13 @@ describe <%= controller_class_name %>Controller do
|
|
153
153
|
it "should find the <%= file_name %> requested" do
|
154
154
|
<%= file_name %> = Factory(:<%= file_name %>)
|
155
155
|
<%= file_name %>.stub!(:destroy).and_return(true)
|
156
|
-
<%=
|
156
|
+
<%= class_name.singularize %>.should_receive(:find).with("1").and_return(<%= file_name %>)
|
157
157
|
delete :destroy, :id => "1", :format => 'xml'
|
158
158
|
end
|
159
159
|
|
160
160
|
it "should call destroy on the found <%= file_name %>" do
|
161
161
|
<%= file_name %> = Factory(:<%= file_name %>)
|
162
|
-
<%=
|
162
|
+
<%= class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
163
163
|
<%= file_name %>.should_receive(:destroy).and_return(true)
|
164
164
|
delete :destroy, :id => "1", :format => 'xml'
|
165
165
|
end
|
@@ -167,7 +167,7 @@ describe <%= controller_class_name %>Controller do
|
|
167
167
|
it "should succeed" do
|
168
168
|
<%= file_name %> = Factory(:<%= file_name %>)
|
169
169
|
<%= file_name %>.stub!(:destroy).and_return(true)
|
170
|
-
<%=
|
170
|
+
<%= class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
171
171
|
delete :destroy, :id => "1", :format => 'xml'
|
172
172
|
response.should be_success
|
173
173
|
end
|
data/objective_spec.gemspec
CHANGED