From 2ecc4af98be805f77a378b16df338ce16604d908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hrvoje=20=C5=A0imi=C4=87?= Date: Sat, 27 Jul 2013 13:53:28 +0200 Subject: [PATCH] travis tweaks and working local coverage --- .travis.yml | 5 ++++- Gemfile | 2 +- Rakefile | 6 +----- features/support/env.rb | 7 +++++-- lib/tasks/config.rake | 1 + spec/spec_helper.rb | 13 ++++++++++--- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e21329..84ff8cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,9 @@ +language: ruby +env: + - TRAVIS=true rvm: - "1.9.3" before_script: - rake config:defaults - rake config:travis - - rake db:test:prepare + - RAILS_ENV=test rake db:setup diff --git a/Gemfile b/Gemfile index d79457a..a89cdc9 100644 --- a/Gemfile +++ b/Gemfile @@ -55,7 +55,7 @@ group :development, :test do end group :test do - gem "simplecov" + gem "simplecov", require: false gem "database_cleaner" gem "email_spec" end diff --git a/Rakefile b/Rakefile index 63e4dbe..4686c3d 100644 --- a/Rakefile +++ b/Rakefile @@ -7,8 +7,4 @@ require 'rspec/core/rake_task' Cipele46Web::Application.load_tasks -RSpec::Core::RakeTask.new(:spec) - -task :default do - Rake::Task["spec"].invoke -end +task :default => [:spec, :spinach] diff --git a/features/support/env.rb b/features/support/env.rb index a3735f3..7c9458a 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,11 +1,14 @@ -require 'simplecov' unless ENV['CI'] +ENV['RAILS_ENV'] ||= 'test' if ENV['TRAVIS'] require 'coveralls' Coveralls.wear! +elsif ENV["RAILS_ENV"] == "test" + require 'simplecov' + SimpleCov.start 'rails' + SimpleCov.coverage_dir 'coverage/features' end -ENV['RAILS_ENV'] ||= 'test' require "./config/environment" require "rspec/rails" diff --git a/lib/tasks/config.rake b/lib/tasks/config.rake index 2082e9d..e14e6ed 100644 --- a/lib/tasks/config.rake +++ b/lib/tasks/config.rake @@ -12,6 +12,7 @@ namespace :config do end exit 0 end + desc "Copy travis config over database.yml" task :travis do cp Rails.root.join('config/database.yml.travis'), Rails.root.join('config/database.yml') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ba50b88..00c5443 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,8 +1,15 @@ -require 'coveralls' -Coveralls.wear!('rails') +ENV["RAILS_ENV"] ||= 'test' + +if ENV['TRAVIS'] + require 'coveralls' + Coveralls.wear! +elsif ENV["RAILS_ENV"] == "test" + require 'simplecov' + SimpleCov.start 'rails' + SimpleCov.coverage_dir 'coverage/spec' +end # This file is copied to spec/ when you run 'rails generate rspec:install' -ENV["RAILS_ENV"] = 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'email_spec'