Sha256: 8583c3c765cc2f89137f34d86f74c0fe6c83246ca9c3c347546982857966f48a

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'test_helper'
require 'generators/shopify_app/shop_model/shop_model_generator'

class ShopModelGeneratorTest < Rails::Generators::TestCase
  tests ShopifyApp::Generators::ShopModelGenerator
  destination File.expand_path("../tmp", File.dirname(__FILE__))
  setup :prepare_destination

  test "create the shop model" do
    run_generator
    assert_file "app/models/shop.rb" do |shop|
      assert_match "class Shop < ActiveRecord::Base", shop
      assert_match "include ShopifyApp::Shop", shop
      assert_match "include ShopifyApp::SessionStorage", shop
    end
  end

  test "creates ShopModel migration" do
    run_generator
    assert_migration "db/migrate/create_shops.rb" do |migration|
      assert_match "create_table :shops  do |t|", migration
    end
  end

  test "adds the shopify_session_repository initializer" do
    run_generator
    assert_file "config/initializers/shopify_session_repository.rb" do |file|
      assert_match "ShopifyApp::SessionRepository.storage = Shop", file
    end
  end

  test "creates default shop fixtures" do
    run_generator
    assert_file "test/fixtures/shops.yml" do |file|
      assert_match "regular_shop:", file
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shopify_app-6.4.2 test/generators/shop_model_generator_test.rb
shopify_app-6.4.1 test/generators/shop_model_generator_test.rb
shopify_app-6.4.0 test/generators/shop_model_generator_test.rb
shopify_app-6.3.0 test/generators/shop_model_generator_test.rb