Objective3-objective_spec 0.0.4 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/VERSION +1 -1
- data/generators/objective_observer/objective_observer_generator.rb +16 -0
- data/generators/objective_observer/templates/observer.rb +2 -0
- data/generators/objective_observer/templates/observer_spec.rb +11 -0
- data/generators/objective_service/objective_service_generator.rb +22 -0
- data/generators/objective_service/templates/controller.rb +2 -0
- data/generators/objective_service/templates/controller_spec.rb +175 -0
- data/objective_spec.gemspec +94 -0
- metadata +9 -2
data/.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
*.gem
|
1
|
+
*.gem
|
2
|
+
*.tmproj
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.2
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class ObjectiveObserverGenerator < Rails::Generator::NamedBase
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
# Check for class naming collisions.
|
5
|
+
m.class_collisions "#{class_name}Observer"
|
6
|
+
|
7
|
+
# Observer, and test directories.
|
8
|
+
m.directory File.join('app/models', class_path)
|
9
|
+
m.directory File.join('spec/observers', class_path)
|
10
|
+
|
11
|
+
# Observer class and unit test fixtures.
|
12
|
+
m.template 'observer.rb', File.join('app/models', class_path, "#{file_name}_observer.rb")
|
13
|
+
m.template 'observer_spec.rb', File.join('spec/observers', class_path, "#{file_name}_observer_spec.rb")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
|
2
|
+
|
3
|
+
describe <%= class_name %>Observer do
|
4
|
+
|
5
|
+
it "should observe <%= class_name %>" do
|
6
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
7
|
+
observer = <%= class_name %>Observer.instance
|
8
|
+
observer.after_create(<%= file_name %>)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rails_generator/generators/components/controller/controller_generator'
|
2
|
+
|
3
|
+
class ObjectiveServiceGenerator < ControllerGenerator
|
4
|
+
|
5
|
+
def manifest
|
6
|
+
record do |m|
|
7
|
+
# Check for class naming collisions.
|
8
|
+
m.class_collisions class_path, "#{class_name}Controller", "#{class_name}Helper"
|
9
|
+
|
10
|
+
# Controller, helper, views, and spec directories.
|
11
|
+
m.directory File.join('app/controllers', class_path)
|
12
|
+
m.directory File.join('spec/controllers', class_path)
|
13
|
+
|
14
|
+
# Controller spec, class, and helper.
|
15
|
+
m.template 'controller_spec.rb',
|
16
|
+
File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
|
17
|
+
|
18
|
+
m.template 'controller.rb',
|
19
|
+
File.join('app/controllers', class_path, "#{file_name}_controller.rb")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../spec_helper')
|
2
|
+
|
3
|
+
describe <%= controller_class_name %>Controller do
|
4
|
+
describe "handling GET /<%= table_name %>" do
|
5
|
+
|
6
|
+
it "should be successful" do
|
7
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
8
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return([<%= file_name %>])
|
9
|
+
get :index, :format => 'xml'
|
10
|
+
response.should be_success
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should find all <%= table_name %>" do
|
14
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
15
|
+
<%= controller_class_name.singularize %>.should_receive(:find).with(:all).and_return([<%= file_name %>])
|
16
|
+
get :index, :format => 'xml'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should assign the found <%= table_name %> for the view" do
|
20
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
21
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return([<%= file_name %>])
|
22
|
+
get :index, :format => 'xml'
|
23
|
+
assigns[:<%= table_name %>].should == [<%= file_name %>]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "handling GET /<%= table_name %>/1" do
|
28
|
+
|
29
|
+
it "should be successful" do
|
30
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
31
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
32
|
+
get :show, :id => "1", :format => 'xml'
|
33
|
+
response.should be_success
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should find the <%= file_name %> requested" do
|
37
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
38
|
+
<%= controller_class_name.singularize %>.should_receive(:find).with("1").and_return(<%= file_name %>)
|
39
|
+
get :show, :id => "1", :format => 'xml'
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should assign the found <%= file_name %> for the view" do
|
43
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
44
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
45
|
+
get :show, :id => "1", :format => 'xml'
|
46
|
+
assigns[:<%= file_name %>].should equal(<%= file_name %>)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "handling POST /<%= table_name %>" do
|
51
|
+
|
52
|
+
describe "with successful save" do
|
53
|
+
|
54
|
+
it "should create a new <%= file_name %>" do
|
55
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
56
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
57
|
+
<%= controller_class_name.singularize %>.should_receive(:new).with({}).and_return(<%= file_name %>)
|
58
|
+
<%= file_name %>.should_receive(:save).and_return(true)
|
59
|
+
post :create, :<%= file_name %> => {}, :format => 'xml'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should be successful" do
|
63
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
64
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
65
|
+
<%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
|
66
|
+
<%= file_name %>.should_receive(:save).and_return(true)
|
67
|
+
post :create, :<%= file_name %> => {}, :format => 'xml'
|
68
|
+
response.should be_success
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "with failed save" do
|
74
|
+
|
75
|
+
it "should be unprocessable" do
|
76
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
77
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
78
|
+
<%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
|
79
|
+
<%= file_name %>.should_receive(:save).and_return(false)
|
80
|
+
post :create, :<%= file_name %> => {}, :format => 'xml'
|
81
|
+
response.code.should == '422'
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should return errors" do
|
85
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
86
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
87
|
+
<%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
|
88
|
+
<%= file_name %>.should_receive(:save).and_return(false)
|
89
|
+
post :create, :<%= file_name %> => {}, :format => 'xml'
|
90
|
+
Nokogiri::XML(response.should).at('errors').should_not be_nil
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "handling PUT /<%= table_name %>/1" do
|
97
|
+
|
98
|
+
describe "with successful update" do
|
99
|
+
|
100
|
+
it "should find the <%= file_name %> requested" do
|
101
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
102
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
103
|
+
<%= controller_class_name.singularize %>.should_receive(:find).with("1").and_return(<%= file_name %>)
|
104
|
+
<%= file_name %>.should_receive(:update_attributes).and_return(true)
|
105
|
+
put :update, :id => "1", :format => 'xml'
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should update the found <%= file_name %>" do
|
109
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
110
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
111
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
112
|
+
<%= file_name %>.should_receive(:update_attributes).and_return(true)
|
113
|
+
put :update, :id => "1", :format => 'xml'
|
114
|
+
assigns(:<%= file_name %>).should equal(<%= file_name %>)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should assign the found <%= file_name %> for the view" do
|
118
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
119
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
120
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
121
|
+
<%= file_name %>.should_receive(:update_attributes).and_return(true)
|
122
|
+
put :update, :id => "1", :format => 'xml'
|
123
|
+
assigns(:<%= file_name %>).should equal(<%= file_name %>)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should be successful" do
|
127
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
128
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
129
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
130
|
+
<%= file_name %>.should_receive(:update_attributes).and_return(true)
|
131
|
+
put :update, :id => "1", :format => 'xml'
|
132
|
+
response.should be_success
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "with failed update" do
|
138
|
+
|
139
|
+
it "should render errors" do
|
140
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
141
|
+
<%= file_name %>.stub!(:to_param).and_return("1")
|
142
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
143
|
+
<%= file_name %>.should_receive(:update_attributes).and_return(false)
|
144
|
+
put :update, :id => "1", :format => 'xml'
|
145
|
+
Nokogiri::XML(response.body).at('errors').should_not be_nil
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "handling DELETE /<%= table_name %>/1" do
|
152
|
+
|
153
|
+
it "should find the <%= file_name %> requested" do
|
154
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
155
|
+
<%= file_name %>.stub!(:destroy).and_return(true)
|
156
|
+
<%= controller_class_name.singularize %>.should_receive(:find).with("1").and_return(<%= file_name %>)
|
157
|
+
delete :destroy, :id => "1", :format => 'xml'
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should call destroy on the found <%= file_name %>" do
|
161
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
162
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
163
|
+
<%= file_name %>.should_receive(:destroy).and_return(true)
|
164
|
+
delete :destroy, :id => "1", :format => 'xml'
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should succeed" do
|
168
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
169
|
+
<%= file_name %>.stub!(:destroy).and_return(true)
|
170
|
+
<%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
|
171
|
+
delete :destroy, :id => "1", :format => 'xml'
|
172
|
+
response.should be_success
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{objective_spec}
|
5
|
+
s.version = "0.1.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Blake Watters"]
|
9
|
+
s.date = %q{2009-08-08}
|
10
|
+
s.email = %q{blake@objective3.com}
|
11
|
+
s.extra_rdoc_files = [
|
12
|
+
"LICENSE",
|
13
|
+
"README.rdoc"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".gitignore",
|
17
|
+
"LICENSE",
|
18
|
+
"README.rdoc",
|
19
|
+
"Rakefile",
|
20
|
+
"TODO",
|
21
|
+
"VERSION",
|
22
|
+
"generators/objective_controller/USAGE",
|
23
|
+
"generators/objective_controller/objective_controller_generator.rb",
|
24
|
+
"generators/objective_controller/templates/controller_spec.rb",
|
25
|
+
"generators/objective_controller/templates/helper_spec.rb",
|
26
|
+
"generators/objective_controller/templates/view.html.haml",
|
27
|
+
"generators/objective_controller/templates/view_spec.rb",
|
28
|
+
"generators/objective_model/objective_model_generator.rb",
|
29
|
+
"generators/objective_model/templates/model_spec.rb",
|
30
|
+
"generators/objective_observer/objective_observer_generator.rb",
|
31
|
+
"generators/objective_observer/templates/observer.rb",
|
32
|
+
"generators/objective_observer/templates/observer_spec.rb",
|
33
|
+
"generators/objective_resource/.DS_Store",
|
34
|
+
"generators/objective_resource/objective_resource_generator.rb",
|
35
|
+
"generators/objective_resource/templates/.DS_Store",
|
36
|
+
"generators/objective_resource/templates/controller.rb",
|
37
|
+
"generators/objective_resource/templates/helper.rb",
|
38
|
+
"generators/objective_resource/templates/migration.rb",
|
39
|
+
"generators/objective_resource/templates/model.rb",
|
40
|
+
"generators/objective_resource/templates/rspec/functional_spec.rb",
|
41
|
+
"generators/objective_resource/templates/rspec/helper_spec.rb",
|
42
|
+
"generators/objective_resource/templates/rspec/routing_spec.rb",
|
43
|
+
"generators/objective_resource/templates/rspec/unit_spec.rb",
|
44
|
+
"generators/objective_resource/templates/rspec/views/edit_spec.rb",
|
45
|
+
"generators/objective_resource/templates/rspec/views/index_spec.rb",
|
46
|
+
"generators/objective_resource/templates/rspec/views/new_spec.rb",
|
47
|
+
"generators/objective_resource/templates/rspec/views/show_spec.rb",
|
48
|
+
"generators/objective_resource/templates/view__form.haml",
|
49
|
+
"generators/objective_resource/templates/view_edit.haml",
|
50
|
+
"generators/objective_resource/templates/view_index.haml",
|
51
|
+
"generators/objective_resource/templates/view_new.haml",
|
52
|
+
"generators/objective_resource/templates/view_show.haml",
|
53
|
+
"generators/objective_service/objective_service_generator.rb",
|
54
|
+
"generators/objective_service/templates/controller.rb",
|
55
|
+
"generators/objective_service/templates/controller_spec.rb",
|
56
|
+
"generators/objective_spec/objective_spec_generator.rb",
|
57
|
+
"generators/objective_spec/templates/spec_helpers/common.rb",
|
58
|
+
"generators/objective_spec/templates/spec_helpers/controller.rb",
|
59
|
+
"generators/objective_spec/templates/spec_helpers/model.rb",
|
60
|
+
"generators/objective_spec/templates/spec_helpers/shared_examples.rb",
|
61
|
+
"generators/objective_spec/templates/spec_helpers/view.rb",
|
62
|
+
"generators/rspec_default_values.rb",
|
63
|
+
"init.rb",
|
64
|
+
"lib/objective_spec.rb",
|
65
|
+
"lib/objective_spec/assets.rb",
|
66
|
+
"lib/objective_spec/mailer_example_group.rb",
|
67
|
+
"lib/objective_spec/matchers.rb",
|
68
|
+
"lib/objective_spec/matchers/use_layout_matcher.rb",
|
69
|
+
"lib/objective_spec/spec_helpers.rb",
|
70
|
+
"objective_spec.gemspec",
|
71
|
+
"spec/objective_spec_spec.rb",
|
72
|
+
"spec/spec_helper.rb"
|
73
|
+
]
|
74
|
+
s.has_rdoc = true
|
75
|
+
s.homepage = %q{http://github.com/Objective3/objective_spec}
|
76
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
77
|
+
s.require_paths = ["lib"]
|
78
|
+
s.rubygems_version = %q{1.3.1}
|
79
|
+
s.summary = %q{TODO}
|
80
|
+
s.test_files = [
|
81
|
+
"spec/objective_spec_spec.rb",
|
82
|
+
"spec/spec_helper.rb"
|
83
|
+
]
|
84
|
+
|
85
|
+
if s.respond_to? :specification_version then
|
86
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
87
|
+
s.specification_version = 2
|
88
|
+
|
89
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
90
|
+
else
|
91
|
+
end
|
92
|
+
else
|
93
|
+
end
|
94
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Objective3-objective_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Watters
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-08 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -37,6 +37,9 @@ files:
|
|
37
37
|
- generators/objective_controller/templates/view_spec.rb
|
38
38
|
- generators/objective_model/objective_model_generator.rb
|
39
39
|
- generators/objective_model/templates/model_spec.rb
|
40
|
+
- generators/objective_observer/objective_observer_generator.rb
|
41
|
+
- generators/objective_observer/templates/observer.rb
|
42
|
+
- generators/objective_observer/templates/observer_spec.rb
|
40
43
|
- generators/objective_resource/.DS_Store
|
41
44
|
- generators/objective_resource/objective_resource_generator.rb
|
42
45
|
- generators/objective_resource/templates/.DS_Store
|
@@ -57,6 +60,9 @@ files:
|
|
57
60
|
- generators/objective_resource/templates/view_index.haml
|
58
61
|
- generators/objective_resource/templates/view_new.haml
|
59
62
|
- generators/objective_resource/templates/view_show.haml
|
63
|
+
- generators/objective_service/objective_service_generator.rb
|
64
|
+
- generators/objective_service/templates/controller.rb
|
65
|
+
- generators/objective_service/templates/controller_spec.rb
|
60
66
|
- generators/objective_spec/objective_spec_generator.rb
|
61
67
|
- generators/objective_spec/templates/spec_helpers/common.rb
|
62
68
|
- generators/objective_spec/templates/spec_helpers/controller.rb
|
@@ -71,6 +77,7 @@ files:
|
|
71
77
|
- lib/objective_spec/matchers.rb
|
72
78
|
- lib/objective_spec/matchers/use_layout_matcher.rb
|
73
79
|
- lib/objective_spec/spec_helpers.rb
|
80
|
+
- objective_spec.gemspec
|
74
81
|
- spec/objective_spec_spec.rb
|
75
82
|
- spec/spec_helper.rb
|
76
83
|
has_rdoc: true
|