Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor the test_unit scaffold generator to use the key_value method

  • Loading branch information...
commit 7c00cde79f7973d168b1b6aaa396594447e39a0a 1 parent 21b69b2
@rafaelfranca rafaelfranca authored
View
2  railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
@@ -26,7 +26,7 @@ def attributes_hash
accessible_attributes.map do |a|
name = a.name
- "#{name}: @#{singular_table_name}.#{name}"
+ key_value name, "@#{singular_table_name}.#{name}"
end.sort.join(', ')
end
View
8 railties/test/generators/scaffold_controller_generator_test.rb
@@ -75,8 +75,8 @@ def test_functional_tests
assert_file "test/functional/users_controller_test.rb" do |content|
assert_match(/class UsersControllerTest < ActionController::TestCase/, content)
assert_match(/test "should get index"/, content)
- assert_match(/post :create, user: { age: @user.age, name: @user.name }/, content)
- assert_match(/put :update, id: @user, user: { age: @user.age, name: @user.name }/, content)
+ assert_match(/post :create, user: \{ age: @user.age, name: @user.name \}/, content)
+ assert_match(/put :update, id: @user, user: \{ age: @user.age, name: @user.name \}/, content)
end
end
@@ -86,8 +86,8 @@ def test_functional_tests_without_attributes
assert_file "test/functional/users_controller_test.rb" do |content|
assert_match(/class UsersControllerTest < ActionController::TestCase/, content)
assert_match(/test "should get index"/, content)
- assert_match(/post :create, user: { }/, content)
- assert_match(/put :update, id: @user, user: { }/, content)
+ assert_match(/post :create, user: \{ \}/, content)
+ assert_match(/put :update, id: @user, user: \{ \}/, content)
end
end
View
8 railties/test/generators/scaffold_generator_test.rb
@@ -64,8 +64,8 @@ def test_scaffold_on_invoke
assert_file "test/functional/product_lines_controller_test.rb" do |test|
assert_match(/class ProductLinesControllerTest < ActionController::TestCase/, test)
- assert_match(/post :create, product_line: { title: @product_line.title }/, test)
- assert_match(/put :update, id: @product_line, product_line: { title: @product_line.title }/, test)
+ assert_match(/post :create, product_line: \{ title: @product_line.title \}/, test)
+ assert_match(/put :update, id: @product_line, product_line: \{ title: @product_line.title \}/, test)
end
# Views
@@ -94,8 +94,8 @@ def test_functional_tests_without_attributes
assert_file "test/functional/product_lines_controller_test.rb" do |content|
assert_match(/class ProductLinesControllerTest < ActionController::TestCase/, content)
assert_match(/test "should get index"/, content)
- assert_match(/post :create, product_line: { }/, content)
- assert_match(/put :update, id: @product_line, product_line: { }/, content)
+ assert_match(/post :create, product_line: \{ \}/, content)
+ assert_match(/put :update, id: @product_line, product_line: \{ \}/, content)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.