Browse files

Add a generator spec

  • Loading branch information...
1 parent 2cfc235 commit 79781e75686b15ba9b2ba1b6045c03dce79a06f9 @mshibuya mshibuya committed Mar 4, 2014
Showing with 29 additions and 1 deletion.
  1. +1 −1 lib/generators/rails_admin/install_generator.rb
  2. +28 −0 spec/rails_admin/install_generator_spec.rb
View
2 lib/generators/rails_admin/install_generator.rb
@@ -11,7 +11,7 @@ class InstallGenerator < Rails::Generators::Base
def install
namespace = ask_for('Where do you want to mount rails_admin?', 'admin', _namespace)
- route("mount RailsAdmin::Engine => '/#{namespace}', :as => 'rails_admin'")
+ route("mount RailsAdmin::Engine => '/#{namespace}', as: 'rails_admin'")
template 'initializer.erb', 'config/initializers/rails_admin.rb'
end
end
View
28 spec/rails_admin/install_generator_spec.rb
@@ -0,0 +1,28 @@
+require 'spec_helper'
+require 'generators/rails_admin/install_generator'
+
+describe RailsAdmin::InstallGenerator, type: :generator do
+ destination File.expand_path("../../dummy_app/tmp/generator", __FILE__)
+ arguments ['admin']
+
+ before do
+ prepare_destination
+ end
+
+ it "mounts RailsAdmin as Engine and generates RailsAdmin Initializer" do
+ expect_any_instance_of(generator_class).to receive(:route).
+ with("mount RailsAdmin::Engine => '/admin', as: 'rails_admin'")
+ capture(:stdout) do
+ generator.invoke('install')
+ end
+ expect(destination_root).to have_structure{
+ directory "config" do
+ directory "initializers" do
+ file "rails_admin.rb" do
+ contains "RailsAdmin.config"
+ end
+ end
+ end
+ }
+ end
+end

0 comments on commit 79781e7

Please sign in to comment.