Sha256: a20b0c594993a4cfdaac1ac7015740895884654176c2f73f18167805aa18e669

Contents?: true

Size: 705 Bytes

Versions: 13

Compression:

Stored size: 705 Bytes

Contents

module Cadenero
  module GeneratorMacros
    def cleanup!
      Dir.chdir(Rails.root) do
        FileUtils.rm_rf("db/migrate")
      end

      backup_or_restore = "#{example.metadata[:run] ? "restore" : "backup"}_file"
      ["#{Rails.root}/app/controllers/application_controller.rb",
       "#{Rails.root}/config/routes.rb"].each do |file|
        send(backup_or_restore, file)
      end
    end

    def backup_file(file)
      FileUtils.cp(file, file + ".bak")
    end

    def restore_file(file)
      FileUtils.mv(file + ".bak", file)
    end
  end
end

RSpec.configure do |c|
  c.include Cadenero::GeneratorMacros, :example_group => {
    :file_path => c.escaped_path(%w[spec (generators)])
  }
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cadenero-0.0.2.b10 spec/support/generator_macros.rb
cadenero-0.0.2.b8 spec/support/generator_macros.rb
cadenero-0.0.2.b7 spec/support/generator_macros.rb
cadenero-0.0.2.b6 spec/support/generator_macros.rb
cadenero-0.0.2.b5 spec/support/generator_macros.rb
cadenero-0.0.2.b4 spec/support/generator_macros.rb
cadenero-0.0.2.b3 spec/support/generator_macros.rb
cadenero-0.0.2.b2 spec/support/generator_macros.rb
cadenero-0.0.2.b1 spec/support/generator_macros.rb
cadenero-0.0.2.a3 spec/support/generator_macros.rb
cadenero-0.0.2.a2 spec/support/generator_macros.rb
cadenero-0.0.2.a1 spec/support/generator_macros.rb
cadenero-0.0.2.a spec/support/generator_macros.rb