active_leonardo 0.1.0 → 0.2.0

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.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +44 -0
  3. data/LICENSE +19 -19
  4. data/README.md +173 -0
  5. data/active_template.rb +141 -137
  6. data/lib/generators/active_leonardo.rb +7 -1
  7. data/lib/generators/erb/leosca/leosca_generator.rb +122 -122
  8. data/lib/generators/leolay/USAGE +21 -21
  9. data/lib/generators/leolay/leolay_generator.rb +420 -400
  10. data/lib/generators/leolay/templates/app/admin/users.rb +87 -87
  11. data/lib/generators/leolay/templates/config/locales/it.yml +7 -0
  12. data/lib/generators/leolay/templates/spec/helpers/application_helpers.rb +13 -13
  13. data/lib/generators/leolay/templates/spec/support/devise.rb +4 -4
  14. data/lib/generators/leolay/templates/styles/active/stylesheets/app/custom_active_admin.css.scss +27 -27
  15. data/lib/generators/leosca/USAGE +23 -23
  16. data/lib/generators/rails/leosca/USAGE +39 -39
  17. data/lib/generators/rails/leosca/leosca_generator.rb +55 -55
  18. data/lib/generators/rails/leosca/templates/leosca.css +56 -56
  19. data/lib/generators/rails/leosca_controller/USAGE +23 -23
  20. data/lib/generators/rails/leosca_controller/leosca_controller_generator.rb +192 -188
  21. data/lib/generators/rails/leosca_controller/templates/controller.rb +3 -3
  22. data/lib/generators/rspec/leointegration/leointegration_generator.rb +35 -35
  23. data/lib/generators/rspec/leointegration/templates/admin/feature.rb +67 -67
  24. data/lib/generators/rspec/leointegration/templates/feature.rb +9 -9
  25. data/lib/generators/rspec/leosca/leosca_generator.rb +57 -57
  26. data/lib/generators/rspec/leosca/templates/admin/controller_spec.rb +181 -181
  27. data/lib/generators/rspec/leosca/templates/admin/edit_spec.rb +31 -31
  28. data/lib/generators/rspec/leosca/templates/admin/index_spec.rb +32 -32
  29. data/lib/generators/rspec/leosca/templates/admin/new_spec.rb +30 -30
  30. data/lib/generators/rspec/leosca/templates/admin/routing_spec.rb +39 -39
  31. data/lib/generators/rspec/leosca/templates/admin/show_spec.rb +28 -28
  32. data/lib/generators/rspec/leosca/templates/controller_spec.rb +168 -168
  33. data/lib/generators/rspec/leosca/templates/edit_spec.rb +31 -31
  34. data/lib/generators/rspec/leosca/templates/index_spec.rb +32 -32
  35. data/lib/generators/rspec/leosca/templates/new_spec.rb +30 -30
  36. data/lib/generators/rspec/leosca/templates/routing_spec.rb +39 -39
  37. data/lib/generators/rspec/leosca/templates/show_spec.rb +28 -28
  38. metadata +55 -124
  39. data/CHANGELOG +0 -28
  40. data/README.rdoc +0 -159
@@ -1,31 +1,31 @@
1
- require 'spec_helper'
2
-
3
- <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "<%= ns_table_name %>/edit" do
5
- before(:each) do
6
- @<%= ns_file_name %> = assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
7
- <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
- :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
- <% end -%>
10
- <%= output_attributes.empty? ? "" : " ))\n" -%>
11
- end
12
-
13
- it "renders the edit <%= ns_file_name %> form" do
14
- render
15
-
16
- <% if webrat? -%>
17
- rendered.should have_selector("form", :action => <%= ns_file_name %>_path(@<%= ns_file_name %>), :method => "post") do |form|
18
- <% for attribute in output_attributes -%>
19
- form.should have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
20
- <% end -%>
21
- end
22
- <% else -%>
23
- # Run the generator again with the --webrat flag if you want to use webrat matchers
24
- assert_select "form", :action => <%= index_helper %>_path(@<%= ns_file_name %>), :method => "post" do
25
- <% for attribute in output_attributes -%>
26
- assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]"
27
- <% end -%>
28
- end
29
- <% end -%>
30
- end
31
- end
1
+ require 'spec_helper'
2
+
3
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
+ describe "<%= ns_table_name %>/edit" do
5
+ before(:each) do
6
+ @<%= ns_file_name %> = assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
7
+ <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
+ :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
+ <% end -%>
10
+ <%= output_attributes.empty? ? "" : " ))\n" -%>
11
+ end
12
+
13
+ it "renders the edit <%= ns_file_name %> form" do
14
+ render
15
+
16
+ <% if webrat? -%>
17
+ rendered.should have_selector("form", :action => <%= ns_file_name %>_path(@<%= ns_file_name %>), :method => "post") do |form|
18
+ <% for attribute in output_attributes -%>
19
+ form.should have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
20
+ <% end -%>
21
+ end
22
+ <% else -%>
23
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
24
+ assert_select "form", :action => <%= index_helper %>_path(@<%= ns_file_name %>), :method => "post" do
25
+ <% for attribute in output_attributes -%>
26
+ assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]"
27
+ <% end -%>
28
+ end
29
+ <% end -%>
30
+ end
31
+ end
@@ -1,32 +1,32 @@
1
- require 'spec_helper'
2
-
3
- <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "<%= ns_table_name %>/index" do
5
- before(:each) do
6
- assign(:<%= table_name %>, [
7
- <% [1,2].each_with_index do |id, model_index| -%>
8
- stub_model(<%= class_name %><%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : ',' %>
9
- <% output_attributes.each_with_index do |attribute, attribute_index| -%>
10
- :<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
11
- <% end -%>
12
- <% if !output_attributes.empty? -%>
13
- <%= model_index == 1 ? ')' : '),' %>
14
- <% end -%>
15
- <% end -%>
16
- ])
17
- end
18
-
19
- it "renders a list of <%= ns_table_name %>" do
20
- render
21
- <% unless webrat? -%>
22
- # Run the generator again with the --webrat flag if you want to use webrat matchers
23
- <% end -%>
24
- <% for attribute in output_attributes -%>
25
- <% if webrat? -%>
26
- rendered.should have_selector("tr>td", :content => <%= value_for(attribute) %>.to_s, :count => 2)
27
- <% else -%>
28
- assert_select "tr>td", :text => <%= value_for(attribute) %>.to_s, :count => 2
29
- <% end -%>
30
- <% end -%>
31
- end
32
- end
1
+ require 'spec_helper'
2
+
3
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
+ describe "<%= ns_table_name %>/index" do
5
+ before(:each) do
6
+ assign(:<%= table_name %>, [
7
+ <% [1,2].each_with_index do |id, model_index| -%>
8
+ stub_model(<%= class_name %><%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : ',' %>
9
+ <% output_attributes.each_with_index do |attribute, attribute_index| -%>
10
+ :<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
11
+ <% end -%>
12
+ <% if !output_attributes.empty? -%>
13
+ <%= model_index == 1 ? ')' : '),' %>
14
+ <% end -%>
15
+ <% end -%>
16
+ ])
17
+ end
18
+
19
+ it "renders a list of <%= ns_table_name %>" do
20
+ render
21
+ <% unless webrat? -%>
22
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
23
+ <% end -%>
24
+ <% for attribute in output_attributes -%>
25
+ <% if webrat? -%>
26
+ rendered.should have_selector("tr>td", :content => <%= value_for(attribute) %>.to_s, :count => 2)
27
+ <% else -%>
28
+ assert_select "tr>td", :text => <%= value_for(attribute) %>.to_s, :count => 2
29
+ <% end -%>
30
+ <% end -%>
31
+ end
32
+ end
@@ -1,30 +1,30 @@
1
- require 'spec_helper'
2
-
3
- <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "<%= ns_table_name %>/new" do
5
- before(:each) do
6
- assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? ').as_new_record)' : ',' %>
7
- <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
- :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
- <% end -%>
10
- <%= !output_attributes.empty? ? " ).as_new_record)\n end" : " end" %>
11
-
12
- it "renders new <%= ns_file_name %> form" do
13
- render
14
-
15
- <% if webrat? -%>
16
- rendered.should have_selector("form", :action => <%= table_name %>_path, :method => "post") do |form|
17
- <% for attribute in output_attributes -%>
18
- form.should have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
19
- <% end -%>
20
- end
21
- <% else -%>
22
- # Run the generator again with the --webrat flag if you want to use webrat matchers
23
- assert_select "form", :action => <%= index_helper %>_path, :method => "post" do
24
- <% for attribute in output_attributes -%>
25
- assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]"
26
- <% end -%>
27
- end
28
- <% end -%>
29
- end
30
- end
1
+ require 'spec_helper'
2
+
3
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
+ describe "<%= ns_table_name %>/new" do
5
+ before(:each) do
6
+ assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? ').as_new_record)' : ',' %>
7
+ <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
+ :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
+ <% end -%>
10
+ <%= !output_attributes.empty? ? " ).as_new_record)\n end" : " end" %>
11
+
12
+ it "renders new <%= ns_file_name %> form" do
13
+ render
14
+
15
+ <% if webrat? -%>
16
+ rendered.should have_selector("form", :action => <%= table_name %>_path, :method => "post") do |form|
17
+ <% for attribute in output_attributes -%>
18
+ form.should have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
19
+ <% end -%>
20
+ end
21
+ <% else -%>
22
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
23
+ assert_select "form", :action => <%= index_helper %>_path, :method => "post" do
24
+ <% for attribute in output_attributes -%>
25
+ assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]"
26
+ <% end -%>
27
+ end
28
+ <% end -%>
29
+ end
30
+ end
@@ -1,39 +1,39 @@
1
- require "spec_helper"
2
-
3
- <% module_namespacing do -%>
4
- describe <%= controller_class_name %>Controller do
5
- describe "routing" do
6
-
7
- <% unless options[:singleton] -%>
8
- it "routes to #index" do
9
- get("/<%= options[:activespace] %>/<%= ns_table_name %>").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#index")
10
- end
11
-
12
- <% end -%>
13
- it "routes to #new" do
14
- get("/<%= options[:activespace] %>/<%= ns_table_name %>/new").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#new")
15
- end
16
-
17
- it "routes to #show" do
18
- get("/<%= options[:activespace] %>/<%= ns_table_name %>/1").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#show", :id => "1")
19
- end
20
-
21
- it "routes to #edit" do
22
- get("/<%= options[:activespace] %>/<%= ns_table_name %>/1/edit").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#edit", :id => "1")
23
- end
24
-
25
- it "routes to #create" do
26
- post("/<%= options[:activespace] %>/<%= ns_table_name %>").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#create")
27
- end
28
-
29
- it "routes to #update" do
30
- put("/<%= options[:activespace] %>/<%= ns_table_name %>/1").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#update", :id => "1")
31
- end
32
-
33
- it "routes to #destroy" do
34
- delete("/<%= options[:activespace] %>/<%= ns_table_name %>/1").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#destroy", :id => "1")
35
- end
36
-
37
- end
38
- end
39
- <% end -%>
1
+ require "spec_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ describe <%= controller_class_name %>Controller do
5
+ describe "routing" do
6
+
7
+ <% unless options[:singleton] -%>
8
+ it "routes to #index" do
9
+ get("/<%= options[:activespace] %>/<%= ns_table_name %>").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#index")
10
+ end
11
+
12
+ <% end -%>
13
+ it "routes to #new" do
14
+ get("/<%= options[:activespace] %>/<%= ns_table_name %>/new").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#new")
15
+ end
16
+
17
+ it "routes to #show" do
18
+ get("/<%= options[:activespace] %>/<%= ns_table_name %>/1").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#show", :id => "1")
19
+ end
20
+
21
+ it "routes to #edit" do
22
+ get("/<%= options[:activespace] %>/<%= ns_table_name %>/1/edit").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#edit", :id => "1")
23
+ end
24
+
25
+ it "routes to #create" do
26
+ post("/<%= options[:activespace] %>/<%= ns_table_name %>").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#create")
27
+ end
28
+
29
+ it "routes to #update" do
30
+ put("/<%= options[:activespace] %>/<%= ns_table_name %>/1").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#update", :id => "1")
31
+ end
32
+
33
+ it "routes to #destroy" do
34
+ delete("/<%= options[:activespace] %>/<%= ns_table_name %>/1").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#destroy", :id => "1")
35
+ end
36
+
37
+ end
38
+ end
39
+ <% end -%>
@@ -1,28 +1,28 @@
1
- require 'spec_helper'
2
-
3
- <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "<%= ns_table_name %>/show" do
5
- before(:each) do
6
- @<%= ns_file_name %> = assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
7
- <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
- :<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
- <% end -%>
10
- <% if !output_attributes.empty? -%>
11
- ))
12
- <% end -%>
13
- end
14
-
15
- it "renders attributes in <p>" do
16
- render
17
- <% unless webrat? -%>
18
- # Run the generator again with the --webrat flag if you want to use webrat matchers
19
- <% end -%>
20
- <% for attribute in output_attributes -%>
21
- <% if webrat? -%>
22
- rendered.should contain(<%= value_for(attribute) %>.to_s)
23
- <% else -%>
24
- rendered.should match(/<%= eval(value_for(attribute)) %>/)
25
- <% end -%>
26
- <% end -%>
27
- end
28
- end
1
+ require 'spec_helper'
2
+
3
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
+ describe "<%= ns_table_name %>/show" do
5
+ before(:each) do
6
+ @<%= ns_file_name %> = assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
7
+ <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
+ :<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
+ <% end -%>
10
+ <% if !output_attributes.empty? -%>
11
+ ))
12
+ <% end -%>
13
+ end
14
+
15
+ it "renders attributes in <p>" do
16
+ render
17
+ <% unless webrat? -%>
18
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
19
+ <% end -%>
20
+ <% for attribute in output_attributes -%>
21
+ <% if webrat? -%>
22
+ rendered.should contain(<%= value_for(attribute) %>.to_s)
23
+ <% else -%>
24
+ rendered.should match(/<%= eval(value_for(attribute)) %>/)
25
+ <% end -%>
26
+ <% end -%>
27
+ end
28
+ end
@@ -1,168 +1,168 @@
1
- require 'spec_helper'
2
-
3
- # This spec was generated by rspec-rails when you ran the scaffold generator.
4
- # It demonstrates how one might use RSpec to specify the controller code that
5
- # was generated by Rails when you ran the scaffold generator.
6
- #
7
- # It assumes that the implementation code is generated by the rails scaffold
8
- # generator. If you are using any extension libraries to generate different
9
- # controller code, this generated spec may or may not pass.
10
- #
11
- # It only uses APIs available in rails and/or rspec-rails. There are a number
12
- # of tools you can use to make these specs even more expressive, but we're
13
- # sticking to rails and rspec-rails APIs to keep things simple and stable.
14
- #
15
- # Compared to earlier versions of this generator, there is very limited use of
16
- # stubs and message expectations in this spec. Stubs are only used when there
17
- # is no simpler way to get a handle on the object needed for the example.
18
- # Message expectations are only used when there is no simpler way to specify
19
- # that an instance is receiving a specific message.
20
-
21
- <% module_namespacing do -%>
22
- describe <%= controller_class_name %>Controller do
23
-
24
- # This should return the minimal set of attributes required to create a valid
25
- # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
26
- # update the return value of this method accordingly.
27
- def valid_attributes
28
- <%= formatted_hash(example_valid_attributes) %>
29
- end
30
-
31
- # This should return the minimal set of values that should be in the session
32
- # in order to pass any filters (e.g. authentication) defined in
33
- # <%= controller_class_name %>Controller. Be sure to keep this updated too.
34
- def valid_session
35
- {}
36
- end
37
-
38
- <% unless options[:singleton] -%>
39
- describe "GET index" do
40
- it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
41
- <%= file_name %> = <%= class_name %>.create! valid_attributes
42
- get :index, {}, valid_session
43
- assigns(:<%= table_name %>).should eq([<%= file_name %>])
44
- end
45
- end
46
-
47
- <% end -%>
48
- describe "GET show" do
49
- it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
50
- <%= file_name %> = <%= class_name %>.create! valid_attributes
51
- get :show, {:id => <%= file_name %>.to_param}, valid_session
52
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
53
- end
54
- end
55
-
56
- describe "GET new" do
57
- it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
58
- get :new, {}, valid_session
59
- assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
60
- end
61
- end
62
-
63
- describe "GET edit" do
64
- it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
65
- <%= file_name %> = <%= class_name %>.create! valid_attributes
66
- get :edit, {:id => <%= file_name %>.to_param}, valid_session
67
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
68
- end
69
- end
70
-
71
- describe "POST create" do
72
- describe "with valid params" do
73
- it "creates a new <%= class_name %>" do
74
- expect {
75
- post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
76
- }.to change(<%= class_name %>, :count).by(1)
77
- end
78
-
79
- it "assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>" do
80
- post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
81
- assigns(:<%= ns_file_name %>).should be_a(<%= class_name %>)
82
- assigns(:<%= ns_file_name %>).should be_persisted
83
- end
84
-
85
- it "redirects to the created <%= ns_file_name %>" do
86
- post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
87
- response.should redirect_to(<%= class_name %>.last)
88
- end
89
- end
90
-
91
- describe "with invalid params" do
92
- it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
93
- # Trigger the behavior that occurs when invalid params are submitted
94
- <%= class_name %>.any_instance.stub(:save).and_return(false)
95
- post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
96
- assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
97
- end
98
-
99
- it "re-renders the 'new' template" do
100
- # Trigger the behavior that occurs when invalid params are submitted
101
- <%= class_name %>.any_instance.stub(:save).and_return(false)
102
- post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
103
- response.should render_template("new")
104
- end
105
- end
106
- end
107
-
108
- describe "PUT update" do
109
- describe "with valid params" do
110
- it "updates the requested <%= ns_file_name %>" do
111
- <%= file_name %> = <%= class_name %>.create! valid_attributes
112
- # Assuming there are no other <%= table_name %> in the database, this
113
- # specifies that the <%= class_name %> created on the previous line
114
- # receives the :update_attributes message with whatever params are
115
- # submitted in the request.
116
- <%= class_name %>.any_instance.should_receive(:update_attributes).with(<%= formatted_hash(example_params_for_update) %>)
117
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_params_for_update) %>}, valid_session
118
- end
119
-
120
- it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
121
- <%= file_name %> = <%= class_name %>.create! valid_attributes
122
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
123
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
124
- end
125
-
126
- it "redirects to the <%= ns_file_name %>" do
127
- <%= file_name %> = <%= class_name %>.create! valid_attributes
128
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
129
- response.should redirect_to(<%= file_name %>)
130
- end
131
- end
132
-
133
- describe "with invalid params" do
134
- it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
135
- <%= file_name %> = <%= class_name %>.create! valid_attributes
136
- # Trigger the behavior that occurs when invalid params are submitted
137
- <%= class_name %>.any_instance.stub(:save).and_return(false)
138
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
139
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
140
- end
141
-
142
- it "re-renders the 'edit' template" do
143
- <%= file_name %> = <%= class_name %>.create! valid_attributes
144
- # Trigger the behavior that occurs when invalid params are submitted
145
- <%= class_name %>.any_instance.stub(:save).and_return(false)
146
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
147
- response.should render_template("edit")
148
- end
149
- end
150
- end
151
-
152
- describe "DELETE destroy" do
153
- it "destroys the requested <%= ns_file_name %>" do
154
- <%= file_name %> = <%= class_name %>.create! valid_attributes
155
- expect {
156
- delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
157
- }.to change(<%= class_name %>, :count).by(-1)
158
- end
159
-
160
- it "redirects to the <%= table_name %> list" do
161
- <%= file_name %> = <%= class_name %>.create! valid_attributes
162
- delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
163
- response.should redirect_to(<%= index_helper %>_url)
164
- end
165
- end
166
-
167
- end
168
- <% end -%>
1
+ require 'spec_helper'
2
+
3
+ # This spec was generated by rspec-rails when you ran the scaffold generator.
4
+ # It demonstrates how one might use RSpec to specify the controller code that
5
+ # was generated by Rails when you ran the scaffold generator.
6
+ #
7
+ # It assumes that the implementation code is generated by the rails scaffold
8
+ # generator. If you are using any extension libraries to generate different
9
+ # controller code, this generated spec may or may not pass.
10
+ #
11
+ # It only uses APIs available in rails and/or rspec-rails. There are a number
12
+ # of tools you can use to make these specs even more expressive, but we're
13
+ # sticking to rails and rspec-rails APIs to keep things simple and stable.
14
+ #
15
+ # Compared to earlier versions of this generator, there is very limited use of
16
+ # stubs and message expectations in this spec. Stubs are only used when there
17
+ # is no simpler way to get a handle on the object needed for the example.
18
+ # Message expectations are only used when there is no simpler way to specify
19
+ # that an instance is receiving a specific message.
20
+
21
+ <% module_namespacing do -%>
22
+ describe <%= controller_class_name %>Controller do
23
+
24
+ # This should return the minimal set of attributes required to create a valid
25
+ # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
26
+ # update the return value of this method accordingly.
27
+ def valid_attributes
28
+ <%= formatted_hash(example_valid_attributes) %>
29
+ end
30
+
31
+ # This should return the minimal set of values that should be in the session
32
+ # in order to pass any filters (e.g. authentication) defined in
33
+ # <%= controller_class_name %>Controller. Be sure to keep this updated too.
34
+ def valid_session
35
+ {}
36
+ end
37
+
38
+ <% unless options[:singleton] -%>
39
+ describe "GET index" do
40
+ it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
41
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
42
+ get :index, {}, valid_session
43
+ assigns(:<%= table_name %>).should eq([<%= file_name %>])
44
+ end
45
+ end
46
+
47
+ <% end -%>
48
+ describe "GET show" do
49
+ it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
50
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
51
+ get :show, {:id => <%= file_name %>.to_param}, valid_session
52
+ assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
53
+ end
54
+ end
55
+
56
+ describe "GET new" do
57
+ it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
58
+ get :new, {}, valid_session
59
+ assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
60
+ end
61
+ end
62
+
63
+ describe "GET edit" do
64
+ it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
65
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
66
+ get :edit, {:id => <%= file_name %>.to_param}, valid_session
67
+ assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
68
+ end
69
+ end
70
+
71
+ describe "POST create" do
72
+ describe "with valid params" do
73
+ it "creates a new <%= class_name %>" do
74
+ expect {
75
+ post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
76
+ }.to change(<%= class_name %>, :count).by(1)
77
+ end
78
+
79
+ it "assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>" do
80
+ post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
81
+ assigns(:<%= ns_file_name %>).should be_a(<%= class_name %>)
82
+ assigns(:<%= ns_file_name %>).should be_persisted
83
+ end
84
+
85
+ it "redirects to the created <%= ns_file_name %>" do
86
+ post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
87
+ response.should redirect_to(<%= class_name %>.last)
88
+ end
89
+ end
90
+
91
+ describe "with invalid params" do
92
+ it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
93
+ # Trigger the behavior that occurs when invalid params are submitted
94
+ <%= class_name %>.any_instance.stub(:save).and_return(false)
95
+ post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
96
+ assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
97
+ end
98
+
99
+ it "re-renders the 'new' template" do
100
+ # Trigger the behavior that occurs when invalid params are submitted
101
+ <%= class_name %>.any_instance.stub(:save).and_return(false)
102
+ post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
103
+ response.should render_template("new")
104
+ end
105
+ end
106
+ end
107
+
108
+ describe "PUT update" do
109
+ describe "with valid params" do
110
+ it "updates the requested <%= ns_file_name %>" do
111
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
112
+ # Assuming there are no other <%= table_name %> in the database, this
113
+ # specifies that the <%= class_name %> created on the previous line
114
+ # receives the :update_attributes message with whatever params are
115
+ # submitted in the request.
116
+ <%= class_name %>.any_instance.should_receive(:update_attributes).with(<%= formatted_hash(example_params_for_update) %>)
117
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_params_for_update) %>}, valid_session
118
+ end
119
+
120
+ it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
121
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
122
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
123
+ assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
124
+ end
125
+
126
+ it "redirects to the <%= ns_file_name %>" do
127
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
128
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
129
+ response.should redirect_to(<%= file_name %>)
130
+ end
131
+ end
132
+
133
+ describe "with invalid params" do
134
+ it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
135
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
136
+ # Trigger the behavior that occurs when invalid params are submitted
137
+ <%= class_name %>.any_instance.stub(:save).and_return(false)
138
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
139
+ assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
140
+ end
141
+
142
+ it "re-renders the 'edit' template" do
143
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
144
+ # Trigger the behavior that occurs when invalid params are submitted
145
+ <%= class_name %>.any_instance.stub(:save).and_return(false)
146
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
147
+ response.should render_template("edit")
148
+ end
149
+ end
150
+ end
151
+
152
+ describe "DELETE destroy" do
153
+ it "destroys the requested <%= ns_file_name %>" do
154
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
155
+ expect {
156
+ delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
157
+ }.to change(<%= class_name %>, :count).by(-1)
158
+ end
159
+
160
+ it "redirects to the <%= table_name %> list" do
161
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
162
+ delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
163
+ response.should redirect_to(<%= index_helper %>_url)
164
+ end
165
+ end
166
+
167
+ end
168
+ <% end -%>