Skip to content

Commit

Permalink
Configure Travis, remove spork, add simplecov, add turbo sprokets.
Browse files Browse the repository at this point in the history
Add travis config
(cherry picked from commit e3fdb12)

Only build on Ruby 1.9.3
(cherry picked from commit 719ef38)

Exclude pry from CI build
(cherry picked from commit d60935c)

Conflicts:

	Gemfile

Attempt 2
(cherry picked from commit 2b19253)

Conflicts:

	Gemfile.lock

Configure travis for postgres
(cherry picked from commit 3a441cd)

Fix migrations that fail because of coupling to changed/removed models
(cherry picked from commit b030793)

Set up xvfb for Travis
(cherry picked from commit cdc3ab0)

Add a failing test to test travis
(cherry picked from commit 72aa8fe)

Revert "Add a failing test to test travis"

This reverts commit 72aa8fe.
(cherry picked from commit bd5533e)

Add simplecov
(cherry picked from commit 5089d3b)

Conflicts:

	Gemfile.lock

Add turbo sprockets for faster asset precompile
(cherry picked from commit 3e6c56a)

Remove spork
(cherry picked from commit ed7bded)

Conflicts:

	spec/spec_helper.rb

Remove more spork-specific things, remove unused cuc config from zeus
(cherry picked from commit fa11ff8)

Ensure order decorator is required, fix test fragility
(cherry picked from commit 1e94f88)
  • Loading branch information
RohanM committed Jun 7, 2013
1 parent 249e1e0 commit cbeffac
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 83 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -29,3 +29,4 @@ public/spree
config/abr.yml
config/heroku_env.rb
NERD_tree*
coverage
14 changes: 14 additions & 0 deletions .travis.yml
@@ -0,0 +1,14 @@
language: ruby
bundler_args: --without development
rvm:
- "1.9.3"
services: postgresql
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
before_script:
- cp config/database.travis.yml config/database.yml
- psql -c 'create database open_food_web_test;' -U postgres
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- export DISPLAY=:99.0 && bundle exec rake spec
10 changes: 8 additions & 2 deletions Gemfile
Expand Up @@ -37,6 +37,8 @@ group :assets do
gem 'therubyracer'

gem 'uglifier', '>= 1.0.3'

gem 'turbo-sprockets-rails3'
end

gem 'jquery-rails'
Expand All @@ -52,8 +54,7 @@ group :test, :development do
gem 'faker'
gem 'capybara'
gem 'database_cleaner', '0.7.1', :require => false
gem 'spork', '~> 1.0rc'
gem 'pry-debugger'
gem 'simplecov', :require => false
gem 'awesome_print'
gem 'letter_opener'
gem 'timecop'
Expand All @@ -64,3 +65,8 @@ group :chili do
gem 'eaterprises_feature', path: 'lib/chili/eaterprises_feature'
gem 'local_organics_feature', path: 'lib/chili/local_organics_feature'
end

group :development do
gem 'pry-debugger'
gem 'debugger-linecache'
end
12 changes: 10 additions & 2 deletions Gemfile.lock
Expand Up @@ -371,8 +371,11 @@ GEM
websocket (~> 1.0.4)
shoulda-matchers (1.1.0)
activesupport (>= 3.0.0)
simplecov (0.7.1)
multi_json (~> 1.0)
simplecov-html (~> 0.7.1)
simplecov-html (0.7.1)
slop (3.3.3)
spork (1.0.0rc3)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
Expand All @@ -389,6 +392,9 @@ GEM
polyglot
polyglot (>= 0.3.1)
truncate_html (0.5.5)
turbo-sprockets-rails3 (0.3.6)
railties (> 3.2.8, < 4.0.0)
sprockets (>= 2.0.0)
turn (0.8.3)
ansi
tzinfo (0.3.37)
Expand Down Expand Up @@ -420,6 +426,7 @@ DEPENDENCIES
comfortable_mexican_sofa
database_cleaner (= 0.7.1)
db2fog
debugger-linecache
deface!
eaterprises_feature!
enterprises_distributor_info_rich_text_feature!
Expand All @@ -438,14 +445,15 @@ DEPENDENCIES
sass-rails (~> 3.2.3)
shoulda-matchers
simple_form!
spork (~> 1.0rc)
simplecov
spree!
spree_i18n!
spree_last_address!
spree_paypal_express!
therubyracer
timecop
truncate_html
turbo-sprockets-rails3
turn (~> 0.8.3)
uglifier (>= 1.0.3)
unicorn
12 changes: 3 additions & 9 deletions README.markdown
Expand Up @@ -59,15 +59,9 @@ Then the tests can be run with:
bundle exec rspec spec

The site is configured to use
[Spork](https://github.com/sporkrb/spork) to reduce the pre-test
startup time while Rails loads. To use it, first start up a spork
instance:

bundle exec spork

When that's ready, you can run RSpec with the --drb flag:

bundle exec rspec --drb spec
[Zeus](https://github.com/burke/zeus) to reduce the pre-test
startup time while Rails loads. See the Zeus github page for
usage instructions.


## Deployment
Expand Down
4 changes: 4 additions & 0 deletions config/database.travis.yml
@@ -0,0 +1,4 @@
test:
adapter: postgresql
database: open_food_web_test
username: postgres
1 change: 1 addition & 0 deletions db/migrate/20120327000582_polymorphic_payments.rb
@@ -1,5 +1,6 @@
# Legacy table support
class Checkout < ActiveRecord::Base; end;
class Spree::Creditcard < ActiveRecord::Base; end;

class PolymorphicPayments < ActiveRecord::Migration
def up
Expand Down
@@ -1,4 +1,7 @@
class MoveDistributorFromOrderToProduct < ActiveRecord::Migration
class Distributor < ActiveRecord::Base; end
class Spree::Product < ActiveRecord::Base; end

def up
remove_column :spree_orders, :distributor_id

Expand Down
@@ -1,4 +1,9 @@
class ExtractDistributorAndSupplierAddressToSpreeAddress < ActiveRecord::Migration
class Supplier < ActiveRecord::Base; end
class Distributor < ActiveRecord::Base; end
class Spree::Address < ActiveRecord::Base; end


def up
# -- Distributors
add_column :distributors, :pickup_address_id, :integer
Expand Down
@@ -1,4 +1,7 @@
class RenameDistributorsProductsToProductDistributions < ActiveRecord::Migration
class Spree::ShippingMethod < ActiveRecord::Base; end
class ProductDistribution < ActiveRecord::Base; end

def up
# Convert m2m join table into explicit join model, and add a shipping method relation and timestamps
rename_table :distributors_products, :product_distributions
Expand All @@ -9,7 +12,7 @@ def up
end

# Set default shipping method on all product distributions
sm = Spree::ShippingMethod.first
sm = Spree::ShippingMethod.unscoped.first
ProductDistribution.update_all(:shipping_method_id => sm.id) if sm
end

Expand Down
6 changes: 6 additions & 0 deletions script/rails
@@ -1,6 +1,12 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

if ENV['RAILS_ENV'] == 'test'
require 'simplecov'
SimpleCov.start 'rails'
puts "required simplecov"
end

APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
2 changes: 1 addition & 1 deletion spec/lib/open_food_web/order_cycle_form_applicator_spec.rb
Expand Up @@ -160,7 +160,7 @@ module OpenFoodWeb
applicator.send(:update_exchange, sender.id, receiver.id, {:variant_ids => [variant1.id, variant3.id]})

exchange.reload
exchange.variant_ids.should == [variant1.id, variant3.id]
exchange.variant_ids.sort.should == [variant1.id, variant3.id].sort
applicator.send(:touched_exchanges).should == [exchange]
end
end
Expand Down
128 changes: 61 additions & 67 deletions spec/spec_helper.rb
@@ -1,68 +1,60 @@
require 'simplecov'
SimpleCov.start

require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'

# By default, test on eaterprises deployment settings
# This must be set before rails loads so that it's available in engine initializers
ENV['OFW_DEPLOYMENT'] ||= 'eaterprises'


Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara'
require 'database_cleaner'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
require 'spree/core/testing_support/controller_requests'

require 'active_record/fixtures'
fixtures_dir = File.expand_path('../../db/default', __FILE__)
ActiveRecord::Fixtures.create_fixtures(fixtures_dir, ['spree/states', 'spree/countries'])


RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr

# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false

# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false

# ## Filters
#
config.filter_run_excluding :skip => true

config.before(:each) do
if example.metadata[:js]
DatabaseCleaner.strategy = :truncation, { :except => ['spree_countries', 'spree_states'] }
else
DatabaseCleaner.strategy = :transaction
end
DatabaseCleaner.start
end

config.after(:each) do
DatabaseCleaner.clean
ENV["RAILS_ENV"] = 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara'
require 'database_cleaner'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
require 'spree/core/testing_support/controller_requests'

require 'active_record/fixtures'
fixtures_dir = File.expand_path('../../db/default', __FILE__)
ActiveRecord::Fixtures.create_fixtures(fixtures_dir, ['spree/states', 'spree/countries'])


RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr

# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false

# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false

# ## Filters
#
config.filter_run_excluding :skip => true

config.before(:each) do
if example.metadata[:js]
DatabaseCleaner.strategy = :truncation, { :except => ['spree_countries', 'spree_states'] }
else
DatabaseCleaner.strategy = :transaction
end

config.before(:each) do
Expand All @@ -74,18 +66,20 @@
config.include Spree::UrlHelpers
config.include Spree::Core::TestingSupport::ControllerRequests, :type => :controller
config.include Devise::TestHelpers, :type => :controller

DatabaseCleaner.start
end
end

Spork.each_run do
Dir["#{File.dirname(__FILE__)}/../app/**/*.rb"].each {|f| load f}
Dir["#{File.dirname(__FILE__)}/../lib/**/*.rb"].each {|f| load f}
config.after(:each) do
DatabaseCleaner.clean
end

Rails.application.reload_routes!
config.include Rails.application.routes.url_helpers
config.include Spree::UrlHelpers
config.include Spree::Core::TestingSupport::ControllerRequests, :type => :controller
config.include Devise::TestHelpers, :type => :controller

# Factory girl
require 'factory_girl_rails'

RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
config.include FactoryGirl::Syntax::Methods
end
1 change: 0 additions & 1 deletion zeus.json
Expand Up @@ -13,7 +13,6 @@
"dbconsole": []
},
"test_environment": {
"cucumber_environment": {"cucumber": []},
"test_helper": {"test": ["rspec", "testrb"]}
}
}
Expand Down

0 comments on commit cbeffac

Please sign in to comment.