Sha256: a584dac270b1860d5d3b43b059b32a1c30203680e12964eb6d056651b9508826

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'test_helper'

class BuildybuildCmsGeneratorTest < Rails::Generators::TestCase
  tests Buildybuild::CmsGenerator
  destination File.expand_path("../../../../tmp", File.dirname(__FILE__))
  setup :prepare_destination

  test "model is generated" do
    generator.generate_model
    assert_file "app/models/page.rb", /class Page/
  end

  test "migration is generated" do
    generator.generate_migration
    assert_migration "db/migrate/create_pages.rb"
  end

  test "controller is generated" do
    generator.generate_controller
    assert_file "app/controllers/pages_controller.rb"
  end

  test "views are generated" do
    generator.generate_views
    assert_file "app/views/pages/show.html.haml", /:markdown/
    assert_file "app/views/pages/edit.html.haml", / render partial: "form", locals: { f:f }/
    assert_file "app/views/pages/new.html.haml", / render partial: "form", locals: { f:f }/
    assert_file "app/views/pages/_form.html.haml", /f\.label :name/
  end

  test "routes are updated" do
    #create the file in the test so we can insert into it.
    generator.create_file("config/routes.rb", "class Routes \n\nend")
    generator.add_routes
    assert_file "config/routes.rb", /get "\/:slug", to: "pages#show", as: :slug/
    assert_file "config/routes.rb", /:slug\n\nend$/
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buildybuild-0.0.1 test/generators/buildybuild/cms/cms_generator_test.rb