Sha256: fd18e9e0e3cc8e4ffa3df1a33df447cacbac8bf0fbab10a7b9bd84427ba27edb

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

require "bundler/setup"
require 'appraisal'
require "bundler/gem_tasks"

require 'rspec/core/rake_task'
require 'rake/testtask'
require 'cucumber/rake/task'

namespace :spec do
  RSpec::Core::RakeTask.new(:unit) do |t|
    t.pattern = "spec/unit/**/*_spec.rb"
  end
  RSpec::Core::RakeTask.new(:rspec) do |t|
    t.pattern = "integration/rspec/rspec_spec.rb"
  end

  RSpec::Core::RakeTask.new(:active_record => 'prepare:active_record') do |t|
    t.pattern = "integration/active_record/active_record_spec.rb"
  end
  RSpec::Core::RakeTask.new(:active_record_truncation => 'prepare:active_record') do |t|
    t.pattern = "integration/active_record/active_record_truncation_spec.rb"
  end

  RSpec::Core::RakeTask.new(:mongoid) do |t|
    t.pattern = "integration/mongoid/mongoid_spec.rb"
  end

  Rake::TestTask.new(:minitest) do |t|
    t.pattern = "integration/minitest/test_*.rb"
  end

  Cucumber::Rake::Task.new(:cucumber) do |t|
    t.cucumber_opts = "integration/cucumber --format pretty"
  end
end

namespace :prepare do
  desc "Prepare database schema for active record"
  task :active_record do
    require_relative 'integration/active_record/setup'
    ActiveRecord::Schema.define(:version => 0) do
      create_table :fruits, :force => true do |t|
        t.string :species
        t.integer :size
        t.belongs_to :parent
      end
    end
  end
end

desc 'Run all specs'
task :spec do
  def find_gem(name)
    Bundler.setup.specs.find { |spec| spec.name == name }
  end

  def run(task)
    puts "Running #{task}"
    Rake::Task[task].invoke
    puts "\n\n"
  end

  if find_gem('activerecord')
    run 'spec:active_record'
    run 'spec:active_record_truncation'
  elsif find_gem('mongoid')
    run 'spec:mongoid'
  else
    run 'spec:rspec'
    run 'spec:minitest'
    run 'spec:unit'
    run 'spec:cucumber'
  end
end

task :default => :spec

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blueprints_boy-1.0.0 Rakefile