Skip to content

Commit

Permalink
Set up testing for project
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed Jan 31, 2012
1 parent 34e34ed commit bb48274
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
Gemfile.lock
spec/dummy
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
before_script:
- "bundle exec rake refinery:testing:dummy_app > /dev/null"
script: "bundle exec rspec ./spec"
notifications:
email:
- parndt@gmail.com
- ugis.ozolss@gmail.com
env:
- DB=postgres
- DB=mysql
- DB=sqlite3
rvm:
- 1.8.7
- ree
- 1.9.2
- 1.9.3
- rbx
- jruby
63 changes: 63 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
source 'http://rubygems.org'

gemspec

git 'git://github.com/resolve/refinerycms.git' do
gem 'refinerycms'

group :development, :test do
gem 'refinerycms-testing'
end
end

group :development, :test do
require 'rbconfig'

gem 'sqlite3'
gem 'mysql2'
gem 'pg'

platforms :mswin, :mingw do
gem 'win32console'
gem 'rb-fchange', '~> 0.0.5'
gem 'rb-notifu', '~> 0.0.4'
end

platforms :ruby do
gem 'spork', '0.9.0.rc9'
gem 'guard-spork'

unless ENV['TRAVIS']
if RbConfig::CONFIG['target_os'] =~ /darwin/i
gem 'rb-fsevent', '>= 0.3.9'
gem 'growl', '~> 1.0.3'
end
if RbConfig::CONFIG['target_os'] =~ /linux/i
gem 'rb-inotify', '>= 0.5.1'
gem 'libnotify', '~> 0.1.3'
gem 'therubyracer', '~> 0.9.9'
end
end
end

platforms :jruby do
unless ENV['TRAVIS']
if RbConfig::CONFIG['target_os'] =~ /darwin/i
gem 'growl', '~> 1.0.3'
end
if RbConfig::CONFIG['target_os'] =~ /linux/i
gem 'rb-inotify', '>= 0.5.1'
gem 'libnotify', '~> 0.1.3'
end
end
end
end

# Refinery/rails should pull in the proper versions of these
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
end

gem 'jquery-rails'
19 changes: 19 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end

ENGINE_PATH = File.dirname(__FILE__)
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)

if File.exists?(APP_RAKEFILE)
load 'rails/tasks/engine.rake'
end

require "refinerycms-testing"
Refinery::Testing::Railtie.load_tasks
Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)

load File.expand_path('../tasks/rspec.rake', __FILE__)
2 changes: 0 additions & 2 deletions db/migrate/20101208082840_create_inquiries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def up

add_index ::Refinery::Inquiry.table_name, :id
end

Refinery::Inquiries::Engine.load_seed
end

def down
Expand Down
59 changes: 59 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
require 'rubygems'

def setup_environment
# Configure Rails Environment
ENV["RAILS_ENV"] ||= 'test'

require File.expand_path("../dummy/config/environment", __FILE__)

require 'rspec/rails'
require 'capybara/rspec'
require 'factory_girl_rails'

Rails.backtrace_cleaner.remove_silencers!

RSpec.configure do |config|
config.mock_with :rspec
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
end

# set javascript driver for capybara
Capybara.javascript_driver = :selenium

# minimize password hashing stretches
Devise.stretches = 1
end

def each_run
ActiveSupport::Dependencies.clear

FactoryGirl.reload

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories including factories.
([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
}.flatten.sort.each do |support_file|
require support_file
end
end

# If spork is available in the Gemfile it'll be used but we don't force it.
unless (begin; require 'spork'; rescue LoadError; nil end).nil?
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
setup_environment
end

Spork.each_run do
# This code will be run each time you run your specs.
each_run
end
else
setup_environment
each_run
end
4 changes: 4 additions & 0 deletions tasks/rspec.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'rspec/core/rake_task'

desc "Run specs"
RSpec::Core::RakeTask.new

0 comments on commit bb48274

Please sign in to comment.