Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a generator spec

  • Loading branch information...
commit 79781e75686b15ba9b2ba1b6045c03dce79a06f9 1 parent 2cfc235
@mshibuya mshibuya authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.