Sha256: 4c3b3ec772a17b0ac5116b651c297134ab8178c8dbadfbb73a46b6d45d2c845f

Contents?: true

Size: 1.45 KB

Versions: 7

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'
require 'generator_spec/test_case'

describe AbAdmin::Generators::ResourceGenerator do
  include GeneratorSpec::TestCase
  destination File.expand_path('../../tmp', __FILE__)
  arguments %w(Header)

  before(:all) do
    prepare_destination

    dir = File.expand_path('../../', __FILE__)
    FileUtils.mkdir_p(File.join(dir, 'tmp/config'))
    FileUtils.copy_file(File.join(dir, 'dummy/config/routes.rb'), File.join(dir, 'tmp/config', 'routes.rb'))
    FileUtils.mkdir_p(File.join(dir, 'tmp/app/models'))
    FileUtils.copy_file(File.join(dir, 'dummy/app/models/admin_menu.rb'), File.join(dir, 'tmp/app/models', 'admin_menu.rb'))

    run_generator
  end

  it 'creates a admin resource' do
    assert_file 'config/routes.rb', /resources\(:headers\) { post :batch, on: :collection }/
    assert_file 'app/models/admin_menu.rb', /model Header/

    assert_file 'app/controllers/admin/headers_controller.rb', /HeadersController/

    assert_file 'app/views/admin/headers/_form.html.slim',
                /admin_form_for @header/, /f\.locale_tabs/, /f\.input :headerable_type/, /f\.save_buttons/
    assert_file 'app/views/admin/headers/_table.html.slim',
                /table/, /collection\.each/, /batch_action_item/, /td/, /item_index_actions/
    assert_file 'app/views/admin/headers/_search_form.html.slim',
                /f\.input :title/, /f\.input :created_at/
    assert_file 'app/helpers/admin/headers_helper.rb', /Admin::HeadersHelper/
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ab_admin-0.3.6 spec/generators/resource_generator_spec.rb
ab_admin-0.3.5 spec/generators/resource_generator_spec.rb
ab_admin-0.3.4 spec/generators/resource_generator_spec.rb
ab_admin-0.3.3 spec/generators/resource_generator_spec.rb
ab_admin-0.3.2 spec/generators/resource_generator_spec.rb
ab_admin-0.3.1 spec/generators/resource_generator_spec.rb
ab_admin-0.3.0 spec/generators/resource_generator_spec.rb