Sha256: f28f9052aa311eaaab9404b3c92ce1bb7017bc1855e77f61d0a970e91834a738

Contents?: true

Size: 1.93 KB

Versions: 42

Compression:

Stored size: 1.93 KB

Contents

# -*- coding: utf-8 -*-
require_relative '../spec_helper'
require 'smalruby_editor'

describe SmalrubyEditor do
  describe '.create_home_directory' do
    before(:all) do
      @home_dir = Pathname(Dir.tmpdir).join('.smalruby-editor')
    end

    shared_examples 'ホームディレクトリを作成する', create_home_directory: true do
      after(:all) do
        FileUtils.rm_rf(@home_dir)
      end

      it 'ホームディレクトリを作成する' do
        expect(@home_dir).to be_directory
      end

      describe 'ホームディレクトリ' do
        %w(config db log tmp
           tmp/cache tmp/pids tmp/sessions tmp/sockets).each do |dir|
          it "#{dir}ディレクトリを作成する" do
            expect(@home_dir.join(dir)).to be_directory
          end
        end

        describe 'configディレクトリ' do
          let(:path) { @home_dir.join('config', 'database.yml') }

          it 'database.ymlを作成する' do
            expect(path).to be_exist
          end

          it 'database.ymlの内容が正しい' do
            expect(path.read).to eq(<<-EOS.strip_heredoc)
            standalone:
              adapter: sqlite3
              database: #{@home_dir.join('db', 'standalone.sqlite3')}
              pool: 5
              timeout: 5000
          EOS
          end
        end
      end
    end

    it '戻り値は作成したホームディレクトリである' do
      expect(SmalrubyEditor.create_home_directory(@home_dir)).to eq(@home_dir)
    end

    context '引数を指定した場合', create_home_directory: true do
      before(:all) do
        SmalrubyEditor.create_home_directory(@home_dir)
      end
    end

    describe '引数を指定しない場合は環境変数SMALRUBY_EDITOR_HOMEに従う',
             create_home_directory: true do
      before(:all) do
        ENV['SMALRUBY_EDITOR_HOME'] = @home_dir.to_s
        SmalrubyEditor.create_home_directory
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
smalruby-editor-0.1.15-x86-mingw32 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.15 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.14-x86-mingw32 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.14 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.13-x86-mingw32 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.13 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.12-x86-mingw32 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.12 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.11-x86-mingw32 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.10-x86-mingw32 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.10 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.9-x86-mingw32 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.9 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.8-x86-mingw32 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.8 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.7-x86-mingw32 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.7 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.6-x86-mingw32 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.6 spec/lib/smalruby_editor_spec.rb
smalruby-editor-0.1.5-x86-mingw32 spec/lib/smalruby_editor_spec.rb