Sha256: 753d4c0aa7434083c3bd78784b9a4b2286f986cbd4cefcb3a026264ef07f4a35

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require 'test_helper'
require 'generators/shopify_app/home_controller/home_controller_generator'

class HomeControllerGeneratorTest < Rails::Generators::TestCase
  tests ShopifyApp::Generators::HomeControllerGenerator
  destination File.expand_path("../tmp", File.dirname(__FILE__))

  setup do
    ShopifyApp.configure do |config|
      config.embedded_app = true
    end

    prepare_destination
    provide_existing_application_file
    provide_existing_routes_file
    provide_existing_application_controller
  end

  test "creates the home controller" do
    run_generator
    assert_file "app/controllers/home_controller.rb"
  end

  test "creates the home index view with embedded options" do
    run_generator
    assert_file "app/views/home/index.html.erb" do |index|
      assert_match "ShopifyApp.ready", index
    end
  end

  test "creates the home index view with embedded false" do
    stub_embedded_false
    run_generator
    assert_file "app/views/home/index.html.erb" do |index|
      refute_match "ShopifyApp.ready", index
    end
  end

  test "adds engine and home route to routes" do
    run_generator
    assert_file "config/routes.rb" do |routes|
      assert_match "mount ShopifyApp::Engine, at: '/'", routes
      assert_match "root :to => 'home#index'", routes
    end
  end

  def stub_embedded_false
    ShopifyApp.configuration.embedded_app = false
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shopify_app-6.4.2 test/generators/home_controller_generator_test.rb
shopify_app-6.4.1 test/generators/home_controller_generator_test.rb