active_leonardo 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
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,3 +1,3 @@
1
- class <%= controller_class_name %>Controller < InheritedResources::Base
2
- respond_to :html, :xml, :json
3
- end
1
+ class <%= controller_class_name %>Controller < InheritedResources::Base
2
+ respond_to :html, :xml, :json
3
+ end
@@ -1,35 +1,35 @@
1
- require 'generators/rspec/integration/integration_generator'
2
- require File.join(File.dirname(__FILE__), '../../active_leonardo')
3
-
4
- module Rspec
5
- module Generators
6
- class LeointegrationGenerator < ::Rspec::Generators::IntegrationGenerator
7
- include ::ActiveLeonardo::Base
8
- include ::ActiveLeonardo::Leosca
9
- include ::ActiveLeonardo::Test
10
- #include ::ActiveLeonardo::Nested
11
- #include ::ActiveLeonardo::Nested::Test
12
-
13
- #puts 'Rspec:Generators:LeointegrationGenerator'
14
- source_paths << File.expand_path('../templates', __FILE__)
15
-
16
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
17
-
18
- class_option :remote, :type => :boolean, :default => true, :desc => "It checks ajax sections"
19
- class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "Nested resources"
20
- class_option :activespace, :type => :string, :default => "admin", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
21
-
22
- def generate_request_spec
23
- return unless options[:request_specs]
24
-
25
- template 'feature.rb',
26
- #File.join('spec/requests', class_path, base_namespaces, "#{table_name}_spec.rb")
27
- File.join('spec/features', class_path, "#{table_name}.rb")
28
- template "#{options[:activespace]}/feature.rb",
29
- #File.join('spec/requests', class_path, base_namespaces, "#{table_name}_spec.rb")
30
- File.join('spec/features', options[:activespace], class_path, "#{table_name}.rb")
31
- end
32
-
33
- end
34
- end
35
- end
1
+ require 'generators/rspec/integration/integration_generator'
2
+ require File.join(File.dirname(__FILE__), '../../active_leonardo')
3
+
4
+ module Rspec
5
+ module Generators
6
+ class LeointegrationGenerator < ::Rspec::Generators::IntegrationGenerator
7
+ include ::ActiveLeonardo::Base
8
+ include ::ActiveLeonardo::Leosca
9
+ include ::ActiveLeonardo::Test
10
+ #include ::ActiveLeonardo::Nested
11
+ #include ::ActiveLeonardo::Nested::Test
12
+
13
+ #puts 'Rspec:Generators:LeointegrationGenerator'
14
+ source_paths << File.expand_path('../templates', __FILE__)
15
+
16
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
17
+
18
+ class_option :remote, :type => :boolean, :default => true, :desc => "It checks ajax sections"
19
+ class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "Nested resources"
20
+ class_option :activespace, :type => :string, :default => "admin", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
21
+
22
+ def generate_request_spec
23
+ return unless options[:request_specs]
24
+
25
+ template 'feature.rb',
26
+ #File.join('spec/requests', class_path, base_namespaces, "#{table_name}_spec.rb")
27
+ File.join('spec/features', class_path, "#{table_name}.rb")
28
+ template "#{options[:activespace]}/feature.rb",
29
+ #File.join('spec/requests', class_path, base_namespaces, "#{table_name}_spec.rb")
30
+ File.join('spec/features', options[:activespace], class_path, "#{table_name}.rb")
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -1,67 +1,67 @@
1
- require 'spec_helper'
2
- <%- check_attr_to_have, check_attr_to_not_have = get_attr_to_match -%>
3
-
4
- feature "<%= options[:activespace].classify %>::<%= class_name.pluralize %>" do
5
- scenario "displays <%= plural_table_name %>" do
6
- <%= singular_table_name %> = Factory(:<%= singular_table_name %>)
7
- visit <%= list_resources_path_test %>
8
- <%= "login_view_as(:user_guest)" if authentication? -%>
9
- #save_and_open_page #uncomment to debug
10
- page.should <%= check_attr_to_have %>
11
- assert page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}").visible?
12
- end
13
-
14
- scenario "creates a new <%= singular_table_name %>" do
15
- <%= singular_table_name %> = Factory.build(:<%= singular_table_name %>)
16
- visit <%= new_resource_path_test %>
17
- <%= "login_view_as(:user_admin)" if authentication? %>
18
- <%= fill_form_with_values.join(CRLF) %>
19
- click_button "Create #{I18n.t('models.<%= singular_table_name %>')}"
20
- #save_and_open_page #uncomment to debug
21
- page.should have_content(I18n.t(:created, :model => I18n.t('models.<%= singular_table_name %>')))
22
- page.should <%= check_attr_to_have %>
23
- end
24
-
25
- scenario "edit a <%= singular_table_name %>" do
26
- <%= singular_table_name %> = Factory(:<%= singular_table_name %>)
27
- visit <%= list_resources_path_test %>
28
- <%= "login_view_as(:user_manager)" if authentication? -%>
29
- #save_and_open_page #uncomment to debug
30
- page.should <%= check_attr_to_have %>
31
- assert page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}").visible?
32
- check("check#{<%= singular_table_name %>.id}")
33
- click_link I18n.t(:edit)
34
- page.should have_content(I18n.t(:edit))
35
- <%= fill_form_with_values("#{plural_table_name}_#_name").join(CRLF) %>
36
- click_button I18n.t(:submit)
37
- page.should have_content(I18n.t(:show))
38
- end
39
-
40
- scenario "destroy one <%= singular_table_name %>" do
41
- <%= singular_table_name %> = Factory(:<%= singular_table_name %>)
42
- visit <%= list_resources_path_test %>
43
- <%= "login_view_as(:user_manager)" if authentication? -%>
44
- #save_and_open_page #uncomment to debug
45
- page.should <%= check_attr_to_have %>
46
- assert page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}").visible?
47
- click_link I18n.t(:delete)
48
- #page.should have_no_content("<%= singular_table_name %>#{<%= singular_table_name %>.id}")
49
- assert_not page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}")
50
- end
51
-
52
- scenario "destroy several <%= plural_table_name %>", :js => true do
53
- <%= plural_table_name %> = FactoryGirl.create_list(:<%= singular_table_name %>, 2)
54
- visit <%= list_resources_path_test %>
55
- <%= "login_view_as(:user_manager)" if authentication? -%>
56
- #save_and_open_page #uncomment to debug
57
- <%= plural_table_name %>.each do |<%= singular_table_name %>|
58
- page.should <%= check_attr_to_have %>
59
- assert page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}").visible?
60
- check "batch_action_item_#{<%= singular_table_name %>.id}"
61
- end
62
- click_link I18n.t('active_admin.batch_actions.action_label', :title => 'active_admin.batch_actions.labels.destroy')
63
- <%= plural_table_name %>.each do |<%= singular_table_name %>|
64
- page.should_not <%= check_attr_to_have %>
65
- end
66
- end
67
- end
1
+ require 'spec_helper'
2
+ <%- check_attr_to_have, check_attr_to_not_have = get_attr_to_match -%>
3
+
4
+ feature "<%= options[:activespace].classify %>::<%= class_name.pluralize %>" do
5
+ scenario "displays <%= plural_table_name %>" do
6
+ <%= singular_table_name %> = Factory(:<%= singular_table_name %>)
7
+ visit <%= list_resources_path_test %>
8
+ <%= "login_view_as(:user_guest)" if authentication? -%>
9
+ #save_and_open_page #uncomment to debug
10
+ page.should <%= check_attr_to_have %>
11
+ assert page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}").visible?
12
+ end
13
+
14
+ scenario "creates a new <%= singular_table_name %>" do
15
+ <%= singular_table_name %> = Factory.build(:<%= singular_table_name %>)
16
+ visit <%= new_resource_path_test %>
17
+ <%= "login_view_as(:user_admin)" if authentication? %>
18
+ <%= fill_form_with_values.join(CRLF) %>
19
+ click_button "Create #{I18n.t('models.<%= singular_table_name %>')}"
20
+ #save_and_open_page #uncomment to debug
21
+ page.should have_content(I18n.t(:created, :model => I18n.t('models.<%= singular_table_name %>')))
22
+ page.should <%= check_attr_to_have %>
23
+ end
24
+
25
+ scenario "edit a <%= singular_table_name %>" do
26
+ <%= singular_table_name %> = Factory(:<%= singular_table_name %>)
27
+ visit <%= list_resources_path_test %>
28
+ <%= "login_view_as(:user_manager)" if authentication? -%>
29
+ #save_and_open_page #uncomment to debug
30
+ page.should <%= check_attr_to_have %>
31
+ assert page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}").visible?
32
+ check("check#{<%= singular_table_name %>.id}")
33
+ click_link I18n.t(:edit)
34
+ page.should have_content(I18n.t(:edit))
35
+ <%= fill_form_with_values("#{plural_table_name}_#_name").join(CRLF) %>
36
+ click_button I18n.t(:submit)
37
+ page.should have_content(I18n.t(:show))
38
+ end
39
+
40
+ scenario "destroy one <%= singular_table_name %>" do
41
+ <%= singular_table_name %> = Factory(:<%= singular_table_name %>)
42
+ visit <%= list_resources_path_test %>
43
+ <%= "login_view_as(:user_manager)" if authentication? -%>
44
+ #save_and_open_page #uncomment to debug
45
+ page.should <%= check_attr_to_have %>
46
+ assert page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}").visible?
47
+ click_link I18n.t(:delete)
48
+ #page.should have_no_content("<%= singular_table_name %>#{<%= singular_table_name %>.id}")
49
+ assert_not page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}")
50
+ end
51
+
52
+ scenario "destroy several <%= plural_table_name %>", :js => true do
53
+ <%= plural_table_name %> = FactoryGirl.create_list(:<%= singular_table_name %>, 2)
54
+ visit <%= list_resources_path_test %>
55
+ <%= "login_view_as(:user_manager)" if authentication? -%>
56
+ #save_and_open_page #uncomment to debug
57
+ <%= plural_table_name %>.each do |<%= singular_table_name %>|
58
+ page.should <%= check_attr_to_have %>
59
+ assert page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}").visible?
60
+ check "batch_action_item_#{<%= singular_table_name %>.id}"
61
+ end
62
+ click_link I18n.t('active_admin.batch_actions.action_label', :title => 'active_admin.batch_actions.labels.destroy')
63
+ <%= plural_table_name %>.each do |<%= singular_table_name %>|
64
+ page.should_not <%= check_attr_to_have %>
65
+ end
66
+ end
67
+ end
@@ -1,9 +1,9 @@
1
- require 'spec_helper'
2
-
3
- feature "<%= class_name.pluralize %>" do
4
- scenario "When visit the index i should see some <%= plural_table_name %>" do
5
- # Write some real scenario
6
- visit <%= index_helper %>_path
7
- response.status.should be(200)
8
- end
9
- end
1
+ require 'spec_helper'
2
+
3
+ feature "<%= class_name.pluralize %>" do
4
+ scenario "When visit the index i should see some <%= plural_table_name %>" do
5
+ # Write some real scenario
6
+ visit <%= index_helper %>_path
7
+ response.status.should be(200)
8
+ end
9
+ end
@@ -1,57 +1,57 @@
1
- require 'generators/rspec/scaffold/scaffold_generator'
2
- require File.join(File.dirname(__FILE__), '../../active_leonardo')
3
-
4
- module Rspec
5
- module Generators
6
- class LeoscaGenerator < ::Rspec::Generators::ScaffoldGenerator
7
- include ::ActiveLeonardo::Base
8
- include ::ActiveLeonardo::Leosca
9
- include ::ActiveLeonardo::Test
10
- #include ::ActiveLeonardo::Nested
11
- #include ::ActiveLeonardo::Nested::Test
12
- #puts 'Rspec:Generators:LeoscaGenerator'
13
- source_paths << File.expand_path('../templates', __FILE__)
14
-
15
- #Leonardo options
16
- class_option :remote, :type => :boolean, :default => true, :desc => "It checks ajax sections"
17
- class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "Nested resources"
18
- class_option :activespace, :type => :string, :default => "admin", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
19
-
20
- #Override
21
- def generate_controller_spec
22
- return unless options[:controller_specs]
23
-
24
- template 'controller_spec.rb',
25
- #File.join('spec/controllers', base_namespaces, controller_class_path, "#{controller_file_name}_controller_spec.rb")
26
- File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb")
27
-
28
- template "#{options[:activespace]}/controller_spec.rb",
29
- #File.join('spec/controllers', base_namespaces, controller_class_path, "#{controller_file_name}_controller_spec.rb")
30
- File.join('spec/controllers', options[:activespace], controller_class_path, "#{controller_file_name}_controller_spec.rb")
31
- end
32
-
33
- #Override
34
- def generate_routing_spec
35
- return unless options[:routing_specs]
36
-
37
- template 'routing_spec.rb',
38
- #File.join('spec/routing', base_namespaces, controller_class_path, "#{controller_file_name}_routing_spec.rb")
39
- File.join('spec/routing', controller_class_path, "#{controller_file_name}_routing_spec.rb")
40
-
41
- template "#{options[:activespace]}/routing_spec.rb",
42
- #File.join('spec/routing', base_namespaces, controller_class_path, "#{controller_file_name}_routing_spec.rb")
43
- File.join('spec/routing', options[:activespace], controller_class_path, "#{controller_file_name}_routing_spec.rb")
44
- end
45
-
46
- hook_for :integration_tool, :as => :leointegration
47
-
48
- protected
49
-
50
- #Override
51
- #def copy_view(view)
52
- # template "#{view}_spec.rb",
53
- # File.join("spec/views", base_namespaces, controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
54
- #end
55
- end
56
- end
57
- end
1
+ require 'generators/rspec/scaffold/scaffold_generator'
2
+ require File.join(File.dirname(__FILE__), '../../active_leonardo')
3
+
4
+ module Rspec
5
+ module Generators
6
+ class LeoscaGenerator < ::Rspec::Generators::ScaffoldGenerator
7
+ include ::ActiveLeonardo::Base
8
+ include ::ActiveLeonardo::Leosca
9
+ include ::ActiveLeonardo::Test
10
+ #include ::ActiveLeonardo::Nested
11
+ #include ::ActiveLeonardo::Nested::Test
12
+ #puts 'Rspec:Generators:LeoscaGenerator'
13
+ source_paths << File.expand_path('../templates', __FILE__)
14
+
15
+ #Leonardo options
16
+ class_option :remote, :type => :boolean, :default => true, :desc => "It checks ajax sections"
17
+ class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "Nested resources"
18
+ class_option :activespace, :type => :string, :default => "admin", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
19
+
20
+ #Override
21
+ def generate_controller_spec
22
+ return unless options[:controller_specs]
23
+
24
+ template 'controller_spec.rb',
25
+ #File.join('spec/controllers', base_namespaces, controller_class_path, "#{controller_file_name}_controller_spec.rb")
26
+ File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb")
27
+
28
+ template "#{options[:activespace]}/controller_spec.rb",
29
+ #File.join('spec/controllers', base_namespaces, controller_class_path, "#{controller_file_name}_controller_spec.rb")
30
+ File.join('spec/controllers', options[:activespace], controller_class_path, "#{controller_file_name}_controller_spec.rb")
31
+ end
32
+
33
+ #Override
34
+ def generate_routing_spec
35
+ return unless options[:routing_specs]
36
+
37
+ template 'routing_spec.rb',
38
+ #File.join('spec/routing', base_namespaces, controller_class_path, "#{controller_file_name}_routing_spec.rb")
39
+ File.join('spec/routing', controller_class_path, "#{controller_file_name}_routing_spec.rb")
40
+
41
+ template "#{options[:activespace]}/routing_spec.rb",
42
+ #File.join('spec/routing', base_namespaces, controller_class_path, "#{controller_file_name}_routing_spec.rb")
43
+ File.join('spec/routing', options[:activespace], controller_class_path, "#{controller_file_name}_routing_spec.rb")
44
+ end
45
+
46
+ hook_for :integration_tool, :as => :leointegration
47
+
48
+ protected
49
+
50
+ #Override
51
+ #def copy_view(view)
52
+ # template "#{view}_spec.rb",
53
+ # File.join("spec/views", base_namespaces, controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
54
+ #end
55
+ end
56
+ end
57
+ end
@@ -1,181 +1,181 @@
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
- describe <%= options[:activespace].classify %>::<%= controller_class_name %>Controller do
22
-
23
- <% unless options[:singleton] -%>
24
- describe "GET index" do
25
- it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
26
- <%= "login_controller_as(:user)" if authentication? %>
27
- <%= file_name %> = Factory(:<%= file_name %>)
28
- get :index
29
- assigns(:<%= table_name %>).should eq([<%= file_name %>])
30
- end
31
- end
32
-
33
- <% end -%>
34
- describe "GET show" do
35
- it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
36
- <%= "login_controller_as(:user)" if authentication? %>
37
- <%= file_name %> = Factory(:<%= file_name %>)
38
- get :show, :id => <%= file_name %>.id.to_s
39
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
40
- end
41
- end
42
-
43
- describe "GET new" do
44
- it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
45
- <%= "login_controller_as(:user)" if authentication? %>
46
- get :new
47
- assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
48
- end
49
- end
50
-
51
- describe "GET edit" do
52
- it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
53
- <%= "login_controller_as(:user)" if authentication? %>
54
- <%= file_name %> = Factory(:<%= file_name %>)
55
- get :edit, :id => <%= file_name %>.id.to_s
56
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
57
- end
58
- end
59
-
60
- describe "POST create" do
61
- describe "with valid params" do
62
- it "creates a new <%= class_name %>" do
63
- <%= "login_controller_as(:user)" if authentication? %>
64
- expect {
65
- post :create, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
66
- }.to change(<%= class_name %>, :count).by(1)
67
- end
68
-
69
- it "assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>" do
70
- <%= "login_controller_as(:user)" if authentication? %>
71
- post :create, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
72
- assigns(:<%= ns_file_name %>).should be_a(<%= class_name %>)
73
- assigns(:<%= ns_file_name %>).should be_persisted
74
- end
75
-
76
- it "redirects to the created <%= ns_file_name %>" do
77
- <%= "login_controller_as(:user)" if authentication? %>
78
- post :create, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
79
- response.should redirect_to(<%= show_resource_path_test "#{class_name}.last" %>)
80
- end
81
- end
82
-
83
- describe "with invalid params" do
84
- it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
85
- <%= "login_controller_as(:user)" if authentication? %>
86
- # Trigger the behavior that occurs when invalid params are submitted
87
- <%= class_name %>.any_instance.stub(:save).and_return(false)
88
- post :create, :<%= ns_file_name %> => {}
89
- assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
90
- end
91
-
92
- it "re-renders the 'new' template" do
93
- <%= "login_controller_as(:user)" if authentication? %>
94
- # Trigger the behavior that occurs when invalid params are submitted
95
- <%= class_name %>.any_instance.stub(:save).and_return(false)
96
- post :create, :<%= ns_file_name %> => {}
97
- response.should render_template("new")
98
- end
99
- end
100
- end
101
-
102
- describe "PUT update" do
103
- describe "with valid params" do
104
- it "updates the requested <%= ns_file_name %>" do
105
- <%= "login_controller_as(:user)" if authentication? %>
106
- <%= file_name %> = Factory(:<%= file_name %>)
107
- # Assuming there are no other <%= table_name %> in the database, this
108
- # specifies that the <%= class_name %> created on the previous line
109
- # receives the :update_attributes message with whatever params are
110
- # submitted in the request.
111
- <%= class_name %>.any_instance.should_receive(:update_attributes).with(Factory.attributes_for(:<%= file_name %>))
112
- put :update, :id => <%= file_name %>.id, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
113
- end
114
-
115
- it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
116
- <%= "login_controller_as(:user)" if authentication? %>
117
- <%= file_name %> = Factory(:<%= file_name %>)
118
- put :update, :id => <%= file_name %>.id, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
119
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
120
- end
121
-
122
- it "redirects to the <%= ns_file_name %>" do
123
- <%= "login_controller_as(:user)" if authentication? %>
124
- <%= file_name %> = Factory(:<%= file_name %>)
125
- put :update, :id => <%= file_name %>.id, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
126
- response.should redirect_to(<%= show_resource_path_test %>)
127
- end
128
- end
129
-
130
- describe "with invalid params" do
131
- it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
132
- <%= "login_controller_as(:user)" if authentication? %>
133
- <%= file_name %> = Factory(:<%= file_name %>)
134
- # Trigger the behavior that occurs when invalid params are submitted
135
- <%= class_name %>.any_instance.stub(:save).and_return(false)
136
- put :update, :id => <%= file_name %>.id.to_s, :<%= ns_file_name %> => {}
137
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
138
- end
139
-
140
- it "re-renders the 'edit' template" do
141
- <%= "login_controller_as(:user)" if authentication? %>
142
- <%= file_name %> = Factory(:<%= file_name %>)
143
- # Trigger the behavior that occurs when invalid params are submitted
144
- <%= class_name %>.any_instance.stub(:save).and_return(false)
145
- put :update, :id => <%= file_name %>.id.to_s, :<%= ns_file_name %> => {}
146
- response.should render_template("edit")
147
- end
148
- end
149
- end
150
-
151
- describe "DELETE destroy" do
152
- describe "with authorization" do
153
- it "destroys the requested <%= ns_file_name %>" do
154
- <%= "login_controller_as(:user_manager)" if authentication? %>
155
- <%= file_name %> = Factory(:<%= file_name %>)
156
- expect {
157
- delete :destroy, :id => <%= file_name %>.id.to_s
158
- }.to change(<%= class_name %>, :count).by(-1)
159
- end
160
-
161
- it "redirects to the <%= table_name %> list" do
162
- <%= "login_controller_as(:user_manager)" if authentication? %>
163
- <%= file_name %> = Factory(:<%= file_name %>)
164
- delete :destroy, :id => <%= file_name %>.id.to_s
165
- response.should redirect_to(<%= list_resources_path_test %>)
166
- end
167
- end
168
- <%- if authorization? -%>
169
- describe "without authorization" do
170
- it "destroys the requested <%= ns_file_name %>" do
171
- <%= "login_controller_as(:user_guest)" if authentication? %>
172
- <%= file_name %> = Factory(:<%= file_name %>)
173
- expect {
174
- delete :destroy, :id => <%= file_name %>.id.to_s
175
- }.to change(<%= class_name %>, :count).by(0)
176
- end
177
- end
178
- <%- end -%>
179
- end
180
-
181
- 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
+ describe <%= options[:activespace].classify %>::<%= controller_class_name %>Controller do
22
+
23
+ <% unless options[:singleton] -%>
24
+ describe "GET index" do
25
+ it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
26
+ <%= "login_controller_as(:user)" if authentication? %>
27
+ <%= file_name %> = Factory(:<%= file_name %>)
28
+ get :index
29
+ assigns(:<%= table_name %>).should eq([<%= file_name %>])
30
+ end
31
+ end
32
+
33
+ <% end -%>
34
+ describe "GET show" do
35
+ it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
36
+ <%= "login_controller_as(:user)" if authentication? %>
37
+ <%= file_name %> = Factory(:<%= file_name %>)
38
+ get :show, :id => <%= file_name %>.id.to_s
39
+ assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
40
+ end
41
+ end
42
+
43
+ describe "GET new" do
44
+ it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
45
+ <%= "login_controller_as(:user)" if authentication? %>
46
+ get :new
47
+ assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
48
+ end
49
+ end
50
+
51
+ describe "GET edit" do
52
+ it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
53
+ <%= "login_controller_as(:user)" if authentication? %>
54
+ <%= file_name %> = Factory(:<%= file_name %>)
55
+ get :edit, :id => <%= file_name %>.id.to_s
56
+ assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
57
+ end
58
+ end
59
+
60
+ describe "POST create" do
61
+ describe "with valid params" do
62
+ it "creates a new <%= class_name %>" do
63
+ <%= "login_controller_as(:user)" if authentication? %>
64
+ expect {
65
+ post :create, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
66
+ }.to change(<%= class_name %>, :count).by(1)
67
+ end
68
+
69
+ it "assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>" do
70
+ <%= "login_controller_as(:user)" if authentication? %>
71
+ post :create, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
72
+ assigns(:<%= ns_file_name %>).should be_a(<%= class_name %>)
73
+ assigns(:<%= ns_file_name %>).should be_persisted
74
+ end
75
+
76
+ it "redirects to the created <%= ns_file_name %>" do
77
+ <%= "login_controller_as(:user)" if authentication? %>
78
+ post :create, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
79
+ response.should redirect_to(<%= show_resource_path_test "#{class_name}.last" %>)
80
+ end
81
+ end
82
+
83
+ describe "with invalid params" do
84
+ it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
85
+ <%= "login_controller_as(:user)" if authentication? %>
86
+ # Trigger the behavior that occurs when invalid params are submitted
87
+ <%= class_name %>.any_instance.stub(:save).and_return(false)
88
+ post :create, :<%= ns_file_name %> => {}
89
+ assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
90
+ end
91
+
92
+ it "re-renders the 'new' template" do
93
+ <%= "login_controller_as(:user)" if authentication? %>
94
+ # Trigger the behavior that occurs when invalid params are submitted
95
+ <%= class_name %>.any_instance.stub(:save).and_return(false)
96
+ post :create, :<%= ns_file_name %> => {}
97
+ response.should render_template("new")
98
+ end
99
+ end
100
+ end
101
+
102
+ describe "PUT update" do
103
+ describe "with valid params" do
104
+ it "updates the requested <%= ns_file_name %>" do
105
+ <%= "login_controller_as(:user)" if authentication? %>
106
+ <%= file_name %> = Factory(:<%= file_name %>)
107
+ # Assuming there are no other <%= table_name %> in the database, this
108
+ # specifies that the <%= class_name %> created on the previous line
109
+ # receives the :update_attributes message with whatever params are
110
+ # submitted in the request.
111
+ <%= class_name %>.any_instance.should_receive(:update_attributes).with(Factory.attributes_for(:<%= file_name %>))
112
+ put :update, :id => <%= file_name %>.id, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
113
+ end
114
+
115
+ it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
116
+ <%= "login_controller_as(:user)" if authentication? %>
117
+ <%= file_name %> = Factory(:<%= file_name %>)
118
+ put :update, :id => <%= file_name %>.id, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
119
+ assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
120
+ end
121
+
122
+ it "redirects to the <%= ns_file_name %>" do
123
+ <%= "login_controller_as(:user)" if authentication? %>
124
+ <%= file_name %> = Factory(:<%= file_name %>)
125
+ put :update, :id => <%= file_name %>.id, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
126
+ response.should redirect_to(<%= show_resource_path_test %>)
127
+ end
128
+ end
129
+
130
+ describe "with invalid params" do
131
+ it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
132
+ <%= "login_controller_as(:user)" if authentication? %>
133
+ <%= file_name %> = Factory(:<%= file_name %>)
134
+ # Trigger the behavior that occurs when invalid params are submitted
135
+ <%= class_name %>.any_instance.stub(:save).and_return(false)
136
+ put :update, :id => <%= file_name %>.id.to_s, :<%= ns_file_name %> => {}
137
+ assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
138
+ end
139
+
140
+ it "re-renders the 'edit' template" do
141
+ <%= "login_controller_as(:user)" if authentication? %>
142
+ <%= file_name %> = Factory(:<%= file_name %>)
143
+ # Trigger the behavior that occurs when invalid params are submitted
144
+ <%= class_name %>.any_instance.stub(:save).and_return(false)
145
+ put :update, :id => <%= file_name %>.id.to_s, :<%= ns_file_name %> => {}
146
+ response.should render_template("edit")
147
+ end
148
+ end
149
+ end
150
+
151
+ describe "DELETE destroy" do
152
+ describe "with authorization" do
153
+ it "destroys the requested <%= ns_file_name %>" do
154
+ <%= "login_controller_as(:user_manager)" if authentication? %>
155
+ <%= file_name %> = Factory(:<%= file_name %>)
156
+ expect {
157
+ delete :destroy, :id => <%= file_name %>.id.to_s
158
+ }.to change(<%= class_name %>, :count).by(-1)
159
+ end
160
+
161
+ it "redirects to the <%= table_name %> list" do
162
+ <%= "login_controller_as(:user_manager)" if authentication? %>
163
+ <%= file_name %> = Factory(:<%= file_name %>)
164
+ delete :destroy, :id => <%= file_name %>.id.to_s
165
+ response.should redirect_to(<%= list_resources_path_test %>)
166
+ end
167
+ end
168
+ <%- if authorization? -%>
169
+ describe "without authorization" do
170
+ it "destroys the requested <%= ns_file_name %>" do
171
+ <%= "login_controller_as(:user_guest)" if authentication? %>
172
+ <%= file_name %> = Factory(:<%= file_name %>)
173
+ expect {
174
+ delete :destroy, :id => <%= file_name %>.id.to_s
175
+ }.to change(<%= class_name %>, :count).by(0)
176
+ end
177
+ end
178
+ <%- end -%>
179
+ end
180
+
181
+ end