Skip to content

Commit

Permalink
Getting the tests running, test_app task is now working
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Boertien <[email protected]>
  • Loading branch information
Cluster444 committed Dec 6, 2011
1 parent 13d164a commit 9aa0a8f
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 92 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*.swp
pkg
Gemfile.lock
spec/dummy

14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
before_script:
- "ruby --version"
- "bundle exec rake test_app"
script: "bundle exec rake"
notifications:
irc: "irc.freenode.org#spree"
branches:
only:
- master
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- ree
21 changes: 2 additions & 19 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'http://rubygems.org'

# temporarily needed until next capybara release
gem 'selenium-webdriver', '0.2.1'
gem 'sqlite3'

group :test do
gem 'rspec-rails'
Expand All @@ -17,22 +17,5 @@ group :test do
end
end

group :cucumber do
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'nokogiri'
gem 'capybara'
gem 'factory_girl'
gem 'factory_girl_rails'
gem 'faker'
gem 'launchy'

if RUBY_VERSION < "1.9"
gem "ruby-debug"
else
gem "ruby-debug19"
end
end
gemspec

gem 'spree', :git => 'git://github.com/spree/spree.git'
gem 'spree_volume_pricing', :git => 'git://github.com/spree/spree_volume_pricing.git'
62 changes: 12 additions & 50 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,33 @@ require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rubygems/package_task'
require 'rspec/core/rake_task'
require 'spree_core/testing_support/common_rake'

RSpec::Core::RakeTask.new

desc "Default Task"
task :default => [:spec ]

spec = eval(File.read('spree_volume_pricing.gemspec'))

Rake::GemPackageTask.new(spec) do |p|
Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end


desc "Release to gemcutter"
task :release => :package do
require 'rake/gemcutter'
Rake::Gemcutter::Tasks.new(spec).define
Rake::Task['gem:push'].invoke
end

gemfile = File.expand_path('../spec/test_app/Gemfile', __FILE__)
if File.exists?(gemfile) && (%w(spec cucumber).include?(ARGV.first.to_s) || ARGV.size == 0)
require 'bundler'
ENV['BUNDLE_GEMFILE'] = gemfile
Bundler.setup

require 'rspec'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
end

desc "Default Task"
task :default => [:spec ]

spec = eval(File.read('spree_volume_pricing.gemspec'))

Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end

desc "Regenerates a rails 3 app for testing"
task :test_app do
SPREE_ROOT = ENV['SPREE_ROOT']
raise "SPREE_ROOT should be specified (where is your source code for spree?)" unless SPREE_ROOT

require File.join(SPREE_ROOT, 'lib/generators/spree/test_app_generator')

class SpreeVolumePricingTestAppGenerator < Spree::Generators::TestAppGenerator

def install_gems
inside "test_app" do
run 'bundle exec rake spree:install'
run 'bundle exec rake spree_volume_pricing:install'
end
end

def migrate_db
run_migrations
end

protected
def full_path_for_local_gems
<<-gems
gem 'spree', :path => \'#{SPREE_ROOT}\'
gem 'spree_volume_pricing', :path => \'#{File.expand_path('..', __FILE__)}\'
gems
end

end
SpreeVolumePricingTestAppGenerator.start
ENV['LIB_NAME'] = 'spree_volume_pricing'
Rake::Task['common:test_app'].invoke
end

namespace :test_app do
Expand Down
28 changes: 12 additions & 16 deletions lib/spree_volume_pricing/engine.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
require "spree_volume_pricing"

module SpreeVolumePricing

class Engine < Rails::Engine

def self.activate
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end

String.class_eval do
def to_range
case self.count('.')
when 2
elements = self.split('..')
return Range.new(elements[0].from(1).to_i, elements[1].to_i)
when 3
elements = self.split('...')
return Range.new(elements[0].from(1).to_i, elements[1].to_i-1)
else
raise ArgumentError.new("Couldn't convert to Range: #{self}")
end
end
def to_range
case self.count('.')
when 2
elements = self.split('..')
return Range.new(elements[0].from(1).to_i, elements[1].to_i)
when 3
elements = self.split('...')
return Range.new(elements[0].from(1).to_i, elements[1].to_i-1)
else
raise ArgumentError.new("Couldn't convert to Range: #{self}")
end
end
end
end

config.autoload_paths += %W(#{config.root}/lib)

config.to_prepare &method(:activate).to_proc

end
end

4 changes: 2 additions & 2 deletions spec/models/order_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../spec_helper'
require 'spec_helper'

describe Order do
before(:each) do
Expand Down Expand Up @@ -29,4 +29,4 @@
@order.line_items.first.price.should == 9
end
end
end
end
2 changes: 1 addition & 1 deletion spec/models/volume_price_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../spec_helper'
require 'spec_helper'

describe VolumePrice do
before(:each) do
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../test_app/config/environment", __FILE__)
require File.expand_path("../dummy/config/environment", __FILE__)
require 'rspec/rails'

#include spree's factories
Expand Down
4 changes: 1 addition & 3 deletions spree_volume_pricing.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'

s.has_rdoc = false

s.add_dependency('spree_core')
s.add_dependency('spree_core', '>= 0.70.0')
end

0 comments on commit 9aa0a8f

Please sign in to comment.