Sha256: fb436b498e8d524aa8440d3fbf1c1a79d67477a58047259b6dda52f722a14f60

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require "rails_helper"
require "generators/theblog/install/install_generator"

describe Theblog::InstallGenerator, type: :generator do
  destination File.expand_path("../tmp", Rails.root)

  let(:seeds_file) { File.expand_path("../tmp/db/seeds.rb", Rails.root) }
  let(:routes_file) { File.expand_path("../tmp/config/routes.rb", Rails.root) }

  before do
    prepare_destination

    FileUtils.mkdir(File.expand_path("../tmp/config", Rails.root))
    File.open(routes_file, "w") do |f|
      f << "Rails.application.routes.draw do\n"
      f << "end"
    end
    FileUtils.mkdir(File.expand_path("../tmp/db", Rails.root))
    FileUtils.touch(seeds_file)
    run_generator
  end

  it "mounts blog to routes" do
    routes = File.read(routes_file)
    expect(routes).to eq("Rails.application.routes.draw do\n  mount Incarnator::Engine => '/auth'" \
                         "\n  mount Theblog::Engine => '/blog'\nend")
  end

  it "adds blog seeds to application seeds" do
    seeds = File.read(seeds_file)
    expect(seeds).to eq("Theblog::Engine.load_seed")

    run_generator

    seeds = File.read(seeds_file)
    expect(seeds).to eq("Theblog::Engine.load_seed")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
theblog-0.0.2.3 spec/generators/theblog/install/install_generator_spec.rb
theblog-0.0.2.2 spec/generators/theblog/install/install_generator_spec.rb
theblog-0.0.2 spec/generators/theblog/install/install_generator_spec.rb