From 6630527824f6dcf9ac4ccbe6fd34f8bd2a9ea8c1 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 12 Apr 2013 16:34:22 +0200 Subject: [PATCH] misc: Modernize the files and copy them from another extensions --- Rakefile | 78 +++++--------------------------------------- spec/spec_helper.rb | 40 ++++++++++++++++------- sysmocom_dhl.gemspec | 7 ++++ 3 files changed, 44 insertions(+), 81 deletions(-) diff --git a/Rakefile b/Rakefile index 6f30923..da592ec 100644 --- a/Rakefile +++ b/Rakefile @@ -1,75 +1,15 @@ -require 'rubygems' -require 'rake' -require 'rake/testtask' -require 'rake/packagetask' -require 'rake/gempackagetask' +require 'bundler' +Bundler::GemHelper.install_tasks -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/core/rake_task' +require 'spree/core/testing_support/common_rake' - require 'rspec' - require 'rspec/core/rake_task' - RSpec::Core::RakeTask.new +RSpec::Core::RakeTask.new - require 'cucumber/rake/task' - Cucumber::Rake::Task.new do |t| - t.cucumber_opts = %w{--format progress} - end -end +task :default => [:spec] -desc "Default Task" -task :default => [:spec, :cucumber ] - -spec = eval(File.read('sysmocom_dhl.gemspec')) - -Rake::GemPackageTask.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 - -desc "Default Task" -task :default => [ :spec ] - -desc "Regenerates a rails 3 app for testing" +desc 'Generates a dummy app for testing' task :test_app do - require '../spree/lib/generators/spree/test_app_generator' - class SysmocomDhlTestAppGenerator < Spree::Generators::TestAppGenerator - - def install_gems - inside "test_app" do - run 'bundle exec rake spree_core:install' - run 'bundle exec rake sysmocom_dhl:install' - end - end - - def migrate_db - run_migrations - end - - protected - def full_path_for_local_gems - <<-gems -gem 'spree_core', :path => \'#{File.join(File.dirname(__FILE__), "../spree/", "core")}\' -gem 'sysmocom_dhl', :path => \'#{File.dirname(__FILE__)}\' - gems - end - - end - SysmocomDhlTestAppGenerator.start -end - -namespace :test_app do - desc 'Rebuild test and cucumber databases' - task :rebuild_dbs do - system("cd spec/test_app && bundle exec rake db:drop db:migrate RAILS_ENV=test && rake db:drop db:migrate RAILS_ENV=cucumber") - end + ENV['LIB_NAME'] = 'sysmocom_dhl' + Rake::Task['common:test_app'].invoke end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 032425a..51c3956 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,14 +1,32 @@ -# 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 'rspec/rails' +# Configure Rails Environment +ENV['RAILS_ENV'] = 'test' -# Requires supporting files with custom matchers and macros, etc, -# in ./support/ and its subdirectories. -Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} +require File.expand_path('../dummy/config/environment.rb', __FILE__) + +require 'rspec/rails' +require 'ffaker' + +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f } + +# Requires factories defined in spree_core +require 'spree/core/testing_support/factories' +require 'spree/core/testing_support/controller_requests' +require 'spree/core/testing_support/authorization_helpers' +require 'spree/core/url_helpers' RSpec.configure do |config| + config.include FactoryGirl::Syntax::Methods + + # == URL Helpers + # + # Allows access to Spree's routes in specs: + # + # visit spree.admin_path + # current_path.should eql(spree.products_path) + config.include Spree::Core::UrlHelpers + # == Mock Framework # # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: @@ -18,13 +36,11 @@ RSpec.configure do |config| # config.mock_with :rr config.mock_with :rspec + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures config.fixture_path = "#{::Rails.root}/spec/fixtures" - #config.include Devise::TestHelpers, :type => :controller # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, comment the following line or assign false + # examples within a transaction, remove the following line or assign false # instead of true. config.use_transactional_fixtures = true end - -@configuration ||= AppConfiguration.find_or_create_by_name("Default configuration") diff --git a/sysmocom_dhl.gemspec b/sysmocom_dhl.gemspec index f631bc9..f3acac1 100644 --- a/sysmocom_dhl.gemspec +++ b/sysmocom_dhl.gemspec @@ -6,6 +6,7 @@ Gem::Specification.new do |s| s.description = 'Deal with shipping cost, zones, insurance' s.required_ruby_version = '>= 1.9.1' + s.author = 'Holger Freyther' # s.author = 'David Heinemeier Hansson' # s.email = 'david@loudthinking.com' # s.homepage = 'http://www.rubyonrails.org' @@ -17,4 +18,10 @@ Gem::Specification.new do |s| s.requirements << 'none' s.add_dependency('spree_core', '>= 1.2.0') + + s.add_development_dependency 'capybara', '1.0.1' + s.add_development_dependency 'factory_girl', '~> 2.6.4' + s.add_development_dependency 'ffaker' + s.add_development_dependency 'rspec-rails', '~> 2.9' + s.add_development_dependency 'sqlite3' end