Sha256: de65dcb7973da4ee0b73903c517a4b514b4e25fe78630c267273931172496368

Contents?: true

Size: 1.85 KB

Versions: 7

Compression:

Stored size: 1.85 KB

Contents

module Helper
  module Generator
    def expect_file_eq(file, expected_file)
      file_content = File.read(file)
      expected_file_content = File.read(expected_file)

      expect(File.exists?(file)).to be_truthy
      expect(file_content).to eq(expected_file_content)
    end

    def expected_default_files(target_dir, expected_value)
      config_dir       = "#{target_dir}/config"
      assets_dir       = "#{target_dir}/assets"
      public_dir       = "#{target_dir}/public"
      boot             = "#{config_dir}/boot.rb"
      application      = "#{config_dir}/application.rb"

      app_dir          = "#{target_dir}/app"
      routes_dir       = "#{target_dir}/app/routes"
      views_dir        = "#{target_dir}/app/views"
      layout           = "#{target_dir}/app/views/layout.erb"
      home_index       = "#{target_dir}/app/views/home/index.erb"

      expect(File.exists?(config_dir)).to eq(expected_value)
      expect(File.exists?("#{config_dir}/boot.rb")).to eq(expected_value)
      expect(File.exists?("#{config_dir}/application.rb")).to eq(expected_value)
      expect(File.exists?(assets_dir)).to eq(expected_value)
      expect(File.exists?(public_dir)).to eq(expected_value)

      expect(Dir.exists?(app_dir)).to eq(expected_value)
      expect(Dir.exists?(routes_dir)).to eq(expected_value)
      expect(Dir.exists?(views_dir)).to eq(expected_value)
      expect(File.exists?(layout)).to eq(expected_value)
      expect(File.exists?(home_index)).to eq(expected_value)
    end

    def expected_generated_files_with_db(target_dir, expected_value)
      sample_migration = "#{target_dir}/db/migrations/000_example.rb"

      expect(Dir.exists?("#{target_dir}/app/models")).to eq(expected_value)
      expect(File.exists?("#{target_dir}/config/database.yml")).to eq(expected_value)
      expect(File.exists?(sample_migration)).to eq(expected_value)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sinator-3.1.1 spec/helpers/generator.rb
sinator-3.1.0 spec/helpers/generator.rb
sinator-3.0.4 spec/helpers/generator.rb
sinator-3.0.3 spec/helpers/generator.rb
sinator-3.0.2 spec/helpers/generator.rb
sinator-3.0.1 spec/helpers/generator.rb
sinator-3.0.0 spec/helpers/generator.rb