Browse Source

More namespace changes

1-2-stable-sysmocom
John Dyer 10 years ago
parent
commit
e724b5f7ef
  1. 78
      Rakefile
  2. 24
      lib/spree_paypal_express.rb
  3. 27
      lib/spree_paypal_express/engine.rb
  4. 6
      spec/spec_helper.rb
  5. 7
      spree_paypal_express.gemspec

78
Rakefile

@ -1,69 +1,31 @@
# encoding: utf-8
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
require 'rubygems/package_task'
require 'rspec/core/rake_task'
require 'cucumber/rake/task'
require 'spree_core/testing_support/common_rake'
desc "Default Task"
task :default => [ :spec ]
RSpec::Core::RakeTask.new
Cucumber::Rake::Task.new
gemfile = File.expand_path('../spec/test_app/Gemfile', __FILE__)
if File.exists?(gemfile) && %w(rcov spec cucumber).include?(ARGV.first.to_s)
require 'bundler'
ENV['BUNDLE_GEMFILE'] = gemfile
Bundler.setup
task :default => [:spec, :cucumber ]
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
require 'cucumber/rake/task'
Cucumber::Rake::Task.new do |t|
t.cucumber_opts = %w{--format pretty}
end
desc "Run specs with RCov"
RSpec::Core::RakeTask.new(:rcov) do |t|
t.rcov = true
t.rcov_opts = %w{ --exclude gems\/,spec\/,features\/}
t.verbose = true
end
spec = eval(File.read('spree_paypal_express.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_PATH = ENV['SPREE_PATH']
raise "SPREE_PATH should be specified" unless SPREE_PATH
require File.join(SPREE_PATH, 'lib/generators/spree/test_app_generator')
class AuthTestAppGenerator < Spree::Generators::TestAppGenerator
def tweak_gemfile
append_file 'Gemfile' do
<<-gems
gem 'spree_core', :path => '#{File.join(SPREE_PATH, 'core')}'
gem 'spree_auth', :path => '#{File.join(SPREE_PATH, 'auth')}'
gem 'spree_paypal_express', :path => '#{File.dirname(__FILE__)}'
gems
end
end
def install_gems
inside "test_app" do
run 'rake spree_core:install'
run 'rake spree_auth:install'
run 'rake spree_paypal_express:install'
end
end
def migrate_db
run_migrations
end
end
AuthTestAppGenerator.start
desc "Release to gemcutter"
task :release => :package do
require 'rake/gemcutter'
Rake::Gemcutter::Tasks.new(spec).define
Rake::Task['gem:push'].invoke
end
namespace :test_app do
desc 'Rebuild test and cucumber databases'
task :rebuild_dbs do
system("cd spec/test_app && rake db:drop db:migrate RAILS_ENV=test && rake db:drop db:migrate RAILS_ENV=cucumber")
end
desc "Generates a dummy app for testing"
task :test_app do
ENV['LIB_NAME'] = 'spree_paypal_express'
Rake::Task['common:test_app'].invoke
end

24
lib/spree_paypal_express.rb

@ -1,24 +1,2 @@
require 'spree_core'
module SpreePaypalExpress
class Engine < Rails::Engine
engine_name 'spree_paypal_express'
config.autoload_paths += %W(#{config.root}/lib)
def self.activate
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
Rails.env.production? ? require(c) : load(c)
end
end
initializer "spree_paypal_express.register.payment_methods" do |app|
app.config.spree.payment_methods += [
Spree::BillingIntegration::PaypalExpress,
Spree::BillingIntegration::PaypalExpressUk
]
end
config.to_prepare &method(:activate).to_proc
end
end
require 'spree_paypal_express/engine'

27
lib/spree_paypal_express/engine.rb

@ -0,0 +1,27 @@
module SpreePaypalExpress
class Engine < Rails::Engine
engine_name 'spree_paypal_express'
config.autoload_paths += %W(#{config.root}/lib)
# use rspec for tests
config.generators do |g|
g.test_framework :rspec
end
def self.activate
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
Rails.env.production? ? require(c) : load(c)
end
end
initializer "spree_paypal_express.register.payment_methods" do |app|
app.config.spree.payment_methods += [
Spree::BillingIntegration::PaypalExpress,
Spree::BillingIntegration::PaypalExpressUk
]
end
config.to_prepare &method(:activate).to_proc
end
end

6
spec/spec_helper.rb

@ -1,7 +1,7 @@
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
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
@ -31,10 +31,10 @@ RSpec.configure do |config|
config.use_transactional_fixtures = true
end
Zone.class_eval do
Spree::Zone.class_eval do
def self.global
find_by_name("GlobalZone") || Factory(:global_zone)
end
end
@configuration ||= AppConfiguration.find_or_create_by_name("Default configuration")
@configuration ||= Spree::AppConfiguration.find_or_create_by_name("Default configuration")

7
spree_paypal_express.gemspec

@ -8,10 +8,11 @@ Gem::Specification.new do |s|
s.email = 'gems@railsdog.com'
s.required_ruby_version = '>= 1.8.7'
s.files = `git ls-files`.split("\n")
#s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.require_paths = ["lib"]
s.require_paths = ["lib"]
s.has_rdoc = false
s.add_dependency('spree_core', '>=0.40.3')
s.add_dependency('spree_core', '>=0.70.1')
s.add_development_dependency('rspec-rails')
end

Loading…
Cancel
Save