Sha256: 49c2817c75d4c572fe719d1c499835be96e02a10a3e014ba07bda3fd8347efb0
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require 'spec_helper' describe ::Localtower::Generators::ServiceObjects::InsertNullable do let(:service) { described_class.new(attributes) } let(:attributes) { [ 'first', 'third', 'fourth' ] } let(:base_file_content) { <<-MIGRATION.strip_heredoc class CreateTests < ActiveRecord::Migration[7.0] def change create_table :tests do |t| t.string :first t.integer :second t.string :third t.string :fourth, default: 'foo' t.integer :fifth t.timestamps end add_index :tests, :first end end MIGRATION } let(:expected_file_content) { <<-MIGRATION.strip_heredoc class CreateTests < ActiveRecord::Migration[7.0] def change create_table :tests do |t| t.string :first, null: false t.integer :second t.string :third, null: false t.string :fourth, default: 'foo', null: false t.integer :fifth t.timestamps end add_index :tests, :first end end MIGRATION } before do File.open("#{Rails.root}/db/migrate/0_migration_name_.rb", 'w') { |f| f.write(base_file_content) } end it 'works' do service.call expect(File.read(last_migration_pending)).to eq(expected_file_content) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
localtower-2.0.1 | spec/lib/localtower/generators/service_objects/insert_nullable_spec.rb |
localtower-2.0.0 | spec/lib/localtower/generators/service_objects/insert_nullable_spec.rb |