Sha256: 5f12cd7d4581558cf613f0917492742a0d3541d63331525ad854ea97ee5cd83b

Contents?: true

Size: 1.44 KB

Versions: 10

Compression:

Stored size: 1.44 KB

Contents

require "bundler/gem_tasks"
require 'rake/testtask'
require 'rspec/core/rake_task'

begin
  require 'rdoc/task'
rescue LoadError
  require 'rdoc/rdoc'
  require 'rake/rdoctask'
  RDoc::Task = Rake::RDocTask
end

module Postgres
  class << self
    def exec(query)
      `psql postgres -tAc "#{query}"`
    end

    def user_exists?(username)
      exec("SELECT 1 FROM pg_user WHERE usename='#{username}'").strip == '1'
    end

    def drop_user(username)
      puts "dropping user #{username}"
      puts exec("DROP USER #{username}").inspect
    end

    def create_user(username)
      user_exists?(username) ? false : `createuser -s #{username}`
    end
  end
end

desc "Run specs"
RSpec::Core::RakeTask.new(:spec => :setup)

RDoc::Task.new(:rdoc) do |rdoc|
  rdoc.rdoc_dir = 'rdoc'
  rdoc.title    = 'Kuhsaft'
  rdoc.options << '--line-numbers'
  rdoc.rdoc_files.include('README.rdoc')
  rdoc.rdoc_files.include('lib/**/*.rb')
end

desc 'set up the dummy app for testing'
task :setup do
  Postgres.create_user 'screenconcept'
  Dir.chdir('spec/dummy') do
    `bundle exec rake kuhsaft:install:migrations`
    `bundle exec rails generate kuhsaft:install:assets`
    `bundle exec rake db:create`
    `bundle exec rake db:migrate`
    `bundle exec rake db:test:prepare`
  end
end

task :default => [:spec]

desc 'start the dummy app'
task :start_dummy do
  Dir.chdir('spec/dummy') do
    ENV['BUNDLE_GEMFILE'] = '../../Gemfile'
    `bundle exec rails server`
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kuhsaft-2.2.6 Rakefile
kuhsaft-2.2.5 Rakefile
kuhsaft-2.2.4 Rakefile
kuhsaft-2.2.3 Rakefile
kuhsaft-2.2.2 Rakefile
kuhsaft-2.2.1 Rakefile
kuhsaft-2.2.0 Rakefile
kuhsaft-2.1.2 Rakefile
kuhsaft-2.1.1 Rakefile
kuhsaft-2.1.0 Rakefile