Sha256: ab498a1bdd1d94d1f82954304288bc2fd51561b19ae2580d75a7a842a7c2aca7

Contents?: true

Size: 965 Bytes

Versions: 7

Compression:

Stored size: 965 Bytes

Contents

require 'rails_helper'
require "generators/curupira/install/install_generator"

describe Curupira::Generators::InstallGenerator, :generator do
  
  before do
    provide_existing_routes_file
  end

  describe "role_model" do
    context "no existing role class" do
      it_behaves_like "valid role model"
    end

    context "role class already exists" do
      before do
        provide_existing_class("role")
      end

      it_behaves_like "valid role model"
    end
  end

  describe "role migration" do
    context "roles table does not exist" do
      it "creates a migration to create the roles table" do
        allow(ActiveRecord::Base.connection).to receive(:table_exists?).and_return(false)

        run_generator
        migration = migration_file("db/migrate/create_roles.rb")

        expect(migration).to exist
        expect(migration).to have_correct_syntax
        expect(migration).to contain("create_table :roles")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
curupira-0.1.7 spec/generators/curupira/install/role_generator_spec.rb
curupira-0.1.6 spec/generators/curupira/install/role_generator_spec.rb
curupira-0.1.4 spec/generators/curupira/install/role_generator_spec.rb
curupira-0.1.3 spec/generators/curupira/install/role_generator_spec.rb
curupira-0.1.2 spec/generators/curupira/install/role_generator_spec.rb
curupira-0.1.1 spec/generators/curupira/install/role_generator_spec.rb
curupira-0.1.0 spec/generators/curupira/install/role_generator_spec.rb