mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
got rid of the "ambiguous first argument; put parentheses or even spaces" warnings in the scaffold_generator tests [#4872 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
committed by
Santiago Pastorino
parent
127da544bb
commit
d82d98dcd5
@@ -18,44 +18,44 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
|
||||
|
||||
# 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
|
||||
|
||||
@@ -92,7 +92,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
|
||||
|
||||
# Route
|
||||
assert_file "config/routes.rb" do |route|
|
||||
assert_no_match /resources :product_lines$/, route
|
||||
assert_no_match(/resources :product_lines$/, route)
|
||||
end
|
||||
|
||||
# Controller
|
||||
@@ -123,44 +123,44 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
|
||||
|
||||
# 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
|
||||
|
||||
@@ -198,7 +198,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
|
||||
|
||||
# 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
|
||||
@@ -234,7 +234,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user