From 4b776c49108e5920696a103209486c6344ad77d3 Mon Sep 17 00:00:00 2001 From: stJhimy Date: Mon, 18 Oct 2010 18:52:29 -0200 Subject: [PATCH] Added test for Devise::Generators::ViewsGenerator with scope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- test/generators/views_generator_test.rb | 36 +++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/test/generators/views_generator_test.rb b/test/generators/views_generator_test.rb index e3d50bb1..07e52158 100644 --- a/test/generators/views_generator_test.rb +++ b/test/generators/views_generator_test.rb @@ -7,17 +7,31 @@ class ViewsGeneratorTest < Rails::Generators::TestCase test "Assert all views are properly created with no params" do run_generator - assert_file "app/views/devise/confirmations/new.html.erb" - assert_file "app/views/devise/mailer/confirmation_instructions.html.erb" - assert_file "app/views/devise/mailer/reset_password_instructions.html.erb" - assert_file "app/views/devise/mailer/unlock_instructions.html.erb" - assert_file "app/views/devise/passwords/edit.html.erb" - assert_file "app/views/devise/passwords/new.html.erb" - assert_file "app/views/devise/registrations/new.html.erb" - assert_file "app/views/devise/registrations/edit.html.erb" - assert_file "app/views/devise/sessions/new.html.erb" - assert_file "app/views/devise/shared/_links.erb" - assert_file "app/views/devise/unlocks/new.html.erb" + assert_files + end + + test "Assert all views are properly created with scope param param" do + run_generator %w(users) + assert_files "users" + + run_generator %w(admins) + assert_files "admins" + end + + def assert_files(scope = nil, template_engine = nil) + scope = "devise" if scope.nil? + assert_file "app/views/#{scope}/confirmations/new.html.erb" + assert_file "app/views/#{scope}/mailer/confirmation_instructions.html.erb" + assert_file "app/views/#{scope}/mailer/reset_password_instructions.html.erb" + assert_file "app/views/#{scope}/mailer/unlock_instructions.html.erb" + assert_file "app/views/#{scope}/passwords/edit.html.erb" + assert_file "app/views/#{scope}/passwords/new.html.erb" + assert_file "app/views/#{scope}/registrations/new.html.erb" + assert_file "app/views/#{scope}/registrations/edit.html.erb" + assert_file "app/views/#{scope}/sessions/new.html.erb" + assert_file "app/views/#{scope}/shared/_links.erb" + assert_file "app/views/#{scope}/unlocks/new.html.erb" + end end