Sha256: 0c0951aca36f5ca04a04fe6e03bdcec5fd26312bca3b6a87fd92637ab4efd13c

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'
require 'generators/roboto/install_generator'

describe Roboto::Generators::InstallGenerator do
  destination File.expand_path("../../../dummy_generator", __FILE__)

  before {prepare_destination}

  describe 'presence of roboto configuration file' do
    before do
      @env_availabe = ["roboto_env", "staging", "production"]
      create_fake_env
      create_routes_rb
      run_generator
    end

    ["roboto_env", "staging", "production"].each  do |env|
       describe 'config/robots/#{env}.txt' do
        subject { file("config/robots/#{env}.txt") }
        it { is_expected.to exist }
        it { is_expected.to contain "User-Agent: *" }
        it { is_expected.to contain "Disallow: /" }
      end
    end

    describe 'config/routes.rb' do
      subject { file('config/routes.rb') }
      it { is_expected.to exist }
      it { is_expected.to contain "mount_roboto" }
    end
  end

  def create_routes_rb
    routes = File.expand_path("../../../dummy/config/routes.rb", __FILE__)
    destination = File.join(destination_root, "config")
    FileUtils.mkdir_p(destination)
    FileUtils.cp routes, destination
  end

  def create_fake_env
    destination = File.join(destination_root, "config/environments")
    FileUtils.mkdir_p(destination)
    @env_availabe.each {|env|  FileUtils.touch(destination_root + "/config/environments/#{env}.rb")}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roboto-1.0.0 spec/generators/roboto/install_generator_spec.rb