diff --git a/.gitignore b/.gitignore index 1377554..a058759 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.swp +spec/test_app diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..cd4a9e6 --- /dev/null +++ b/Gemfile @@ -0,0 +1,32 @@ +source 'http://rubygems.org' + +gem 'sqlite3-ruby', :require => 'sqlite3' + +group :test do + gem 'rspec-rails', '= 2.4.1' + gem 'factory_girl_rails' + gem 'rcov' + gem 'shoulda' + gem 'faker' + if RUBY_VERSION < "1.9" + gem "ruby-debug" + else + gem "ruby-debug19" + end +end + +group :cucumber do + gem 'cucumber-rails' + gem 'database_cleaner', '~> 0.5.2' + gem 'nokogiri' + gem 'capybara' + gem 'factory_girl_rails' + gem 'faker' + gem 'launchy' + + if RUBY_VERSION < "1.9" + gem "ruby-debug" + else + gem "ruby-debug19" + end +end diff --git a/Rakefile b/Rakefile index cdcaf5f..88c1ab6 100644 --- a/Rakefile +++ b/Rakefile @@ -1,13 +1,13 @@ -#require File.expand_path('../../config/application', __FILE__) - +# encoding: utf-8 require 'rubygems' require 'rake' require 'rake/testtask' -require 'rake/packagetask' -require 'rake/gempackagetask' + +desc "Default Task" +task :default => [ :spec ] gemfile = File.expand_path('../spec/test_app/Gemfile', __FILE__) -if File.exists?(gemfile) +if File.exists?(gemfile) && %w(rcov spec cucumber).include?(ARGV.first.to_s) require 'bundler' ENV['BUNDLE_GEMFILE'] = gemfile Bundler.setup @@ -19,44 +19,33 @@ if File.exists?(gemfile) Cucumber::Rake::Task.new do |t| t.cucumber_opts = %w{--format pretty} end -end - -spec = eval(File.read('spree_comments.gemspec')) - -Rake::GemPackageTask.new(spec) do |p| - p.gem_spec = spec -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 -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 ] - -# TODO: pull in the spree/core/Rakefile bits that set up for testing -desc "Regenerates a Rails 3 app for testing" +desc "Regenerates a rails 3 app for testing" task :test_app do -# TODO - this path requires a certain directory structure -- need -# to think about how to refactor - require '../spree/lib/generators/spree/test_app_generator' - class SpreeCommentsTestAppGenerator < Spree::Generators::TestAppGenerator + 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" , - <<-gems - -gem 'spree_core', '>=0.30.0' -gem 'spree_auth', '>=0.30.0' -gem 'spree_comments', :path => "#{File.dirname(__FILE__)}" - - gems + 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_comments', :path => '#{File.dirname(__FILE__)}' +gems + end end - def install_spree_gems + def install_gems inside "test_app" do run 'rake spree_core:install' run 'rake spree_auth:install' @@ -64,17 +53,11 @@ gem 'spree_comments', :path => "#{File.dirname(__FILE__)}" end end -# def install_spree_auth -# inside "test_app" do -# run 'rake spree_auth:install' -# end -# end - def migrate_db run_migrations end end - SpreeCommentsTestAppGenerator.start + AuthTestAppGenerator.start end namespace :test_app do diff --git a/spree_comments.gemspec b/spree_comments.gemspec index 1134355..bd7df19 100644 --- a/spree_comments.gemspec +++ b/spree_comments.gemspec @@ -8,12 +8,11 @@ Gem::Specification.new do |s| s.email = 'gems@railsdog.com' s.required_ruby_version = '>= 1.8.7' - s.files = Dir['CHANGELOG', 'README.md', 'LICENSE', 'lib/**/*', 'app/**/*'] - s.require_path = 'lib' - s.requirements << 'none' - - s.has_rdoc = true + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.require_paths = ["lib"] + s.has_rdoc = false s.add_dependency('spree_core', '>=0.30.0') - s.add_dependency('acts_as_commentable') + s.add_dependency('acts_as_commentable', '3.0.0') end