Skip to content

Commit

Permalink
got rid of the "ambiguous first argument; put parentheses or even spa…
Browse files Browse the repository at this point in the history
…ces" warnings in the scaffold_generator tests [#4872 state:resolved]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information
Jeff Kreeftmeijer authored and spastorino committed Sep 24, 2010
1 parent 127da54 commit d82d98d
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions railties/test/generators/scaffold_generator_test.rb
Expand Up @@ -18,44 +18,44 @@ def test_scaffold_on_invoke

# Route
assert_file "config/routes.rb" do |route|
assert_match /resources :product_lines$/, route
assert_match(/resources :product_lines$/, route)
end

# Controller
assert_file "app/controllers/product_lines_controller.rb" do |content|
assert_match /class ProductLinesController < ApplicationController/, content
assert_match(/class ProductLinesController < ApplicationController/, content)

assert_instance_method :index, content do |m|
assert_match /@product_lines = ProductLine\.all/, m
assert_match(/@product_lines = ProductLine\.all/, m)
end

assert_instance_method :show, content do |m|
assert_match /@product_line = ProductLine\.find\(params\[:id\]\)/, m
assert_match(/@product_line = ProductLine\.find\(params\[:id\]\)/, m)
end

assert_instance_method :new, content do |m|
assert_match /@product_line = ProductLine\.new/, m
assert_match(/@product_line = ProductLine\.new/, m)
end

assert_instance_method :edit, content do |m|
assert_match /@product_line = ProductLine\.find\(params\[:id\]\)/, m
assert_match(/@product_line = ProductLine\.find\(params\[:id\]\)/, m)
end

assert_instance_method :create, content do |m|
assert_match /@product_line = ProductLine\.new\(params\[:product_line\]\)/, m
assert_match /@product_line\.save/, m
assert_match /@product_line\.errors/, m
assert_match(/@product_line = ProductLine\.new\(params\[:product_line\]\)/, m)
assert_match(/@product_line\.save/, m)
assert_match(/@product_line\.errors/, m)
end

assert_instance_method :update, content do |m|
assert_match /@product_line = ProductLine\.find\(params\[:id\]\)/, m
assert_match /@product_line\.update_attributes\(params\[:product_line\]\)/, m
assert_match /@product_line\.errors/, m
assert_match(/@product_line = ProductLine\.find\(params\[:id\]\)/, m)
assert_match(/@product_line\.update_attributes\(params\[:product_line\]\)/, m)
assert_match(/@product_line\.errors/, m)
end

assert_instance_method :destroy, content do |m|
assert_match /@product_line = ProductLine\.find\(params\[:id\]\)/, m
assert_match /@product_line\.destroy/, m
assert_match(/@product_line = ProductLine\.find\(params\[:id\]\)/, m)
assert_match(/@product_line\.destroy/, m)
end
end

Expand Down Expand Up @@ -92,7 +92,7 @@ def test_scaffold_on_revoke

# Route
assert_file "config/routes.rb" do |route|
assert_no_match /resources :product_lines$/, route
assert_no_match(/resources :product_lines$/, route)
end

# Controller
Expand Down Expand Up @@ -123,44 +123,44 @@ def test_scaffold_with_namespace_on_invoke

# Route
assert_file "config/routes.rb" do |route|
assert_match /namespace :admin do resources :roles end$/, route
assert_match(/namespace :admin do resources :roles end$/, route)
end

# Controller
assert_file "app/controllers/admin/roles_controller.rb" do |content|
assert_match /class Admin::RolesController < ApplicationController/, content
assert_match(/class Admin::RolesController < ApplicationController/, content)

assert_instance_method :index, content do |m|
assert_match /@admin_roles = Admin::Role\.all/, m
assert_match(/@admin_roles = Admin::Role\.all/, m)
end

assert_instance_method :show, content do |m|
assert_match /@admin_role = Admin::Role\.find\(params\[:id\]\)/, m
assert_match(/@admin_role = Admin::Role\.find\(params\[:id\]\)/, m)
end

assert_instance_method :new, content do |m|
assert_match /@admin_role = Admin::Role\.new/, m
assert_match(/@admin_role = Admin::Role\.new/, m)
end

assert_instance_method :edit, content do |m|
assert_match /@admin_role = Admin::Role\.find\(params\[:id\]\)/, m
assert_match(/@admin_role = Admin::Role\.find\(params\[:id\]\)/, m)
end

assert_instance_method :create, content do |m|
assert_match /@admin_role = Admin::Role\.new\(params\[:admin_role\]\)/, m
assert_match /@admin_role\.save/, m
assert_match /@admin_role\.errors/, m
assert_match(/@admin_role = Admin::Role\.new\(params\[:admin_role\]\)/, m)
assert_match(/@admin_role\.save/, m)
assert_match(/@admin_role\.errors/, m)
end

assert_instance_method :update, content do |m|
assert_match /@admin_role = Admin::Role\.find\(params\[:id\]\)/, m
assert_match /@admin_role\.update_attributes\(params\[:admin_role\]\)/, m
assert_match /@admin_role\.errors/, m
assert_match(/@admin_role = Admin::Role\.find\(params\[:id\]\)/, m)
assert_match(/@admin_role\.update_attributes\(params\[:admin_role\]\)/, m)
assert_match(/@admin_role\.errors/, m)
end

assert_instance_method :destroy, content do |m|
assert_match /@admin_role = Admin::Role\.find\(params\[:id\]\)/, m
assert_match /@admin_role\.destroy/, m
assert_match(/@admin_role = Admin::Role\.find\(params\[:id\]\)/, m)
assert_match(/@admin_role\.destroy/, m)
end
end

Expand Down Expand Up @@ -198,7 +198,7 @@ def test_scaffold_with_namespace_on_revoke

# Route
assert_file "config/routes.rb" do |route|
assert_no_match /namespace :admin do resources :roles end$/, route
assert_no_match(/namespace :admin do resources :roles end$/, route)
end

# Controller
Expand Down Expand Up @@ -234,7 +234,7 @@ def test_scaffold_generator_on_revoke_does_not_mutilate_legacy_map_parameter

def test_scaffold_generator_outputs_error_message_on_missing_attribute_type
content = capture(:stderr) { run_generator ["post", "title:string", "body"]}
assert_match /Missing type for attribute 'body'/, content
assert_match /Example: 'body:string' where string is the type/, content
assert_match(/Missing type for attribute 'body'/, content)
assert_match(/Example: 'body:string' where string is the type/, content)
end
end

0 comments on commit d82d98d

Please sign in to comment.