Permalink
Browse files

Finish namespace updates by fixing the specs and refactoring to use b…

…undler.
  • Loading branch information...
1 parent 5e89286 commit 349a23583163682f822b2329f5d0fe24a4dd1089 @JDutil JDutil committed Dec 1, 2011
View
@@ -1,3 +1,4 @@
+spec/dummy
spec/test_app
-Gemfile
+Gemfile.lock
*.swp
@@ -1,6 +1,4 @@
--colour
--format
progress
---loadby
mtime
---reverse
View
@@ -0,0 +1,11 @@
+source "http://rubygems.org"
+
+# TODO: remove when 0.80.0.beta or higher is out.
+gem 'spree', :git => 'git://github.com/spree/spree.git'
+
+group :test do
+ gem 'faker'
+end
+
+# Specify your dependencies in spree_wishlist.gemspec
+gemspec
View
@@ -17,3 +17,12 @@ of a recommended product.
3. To setup the asset pipeline includes and copy migrations run: `rails g spree_wishlist:install`
+## Development
+
+ * Fork the repo
+ * clone your repo
+ * Run `bundle`
+ * Run `bundle exec rake test_app` to create the test application in `spec/test_app`.
+ * Make your changes.
+ * Ensure specs pass by running `bundle exec rake`
+ * Submit your pull request
View
@@ -1,70 +1,19 @@
# encoding: utf-8
-require 'rubygems'
-require 'rake'
-require 'rake/testtask'
-desc "Default Task"
-task :default => [ :spec ]
-
-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
-
- require 'rspec/core/rake_task'
- RSpec::Core::RakeTask.new
+require 'bundler'
+Bundler::GemHelper.install_tasks
+Bundler.setup
- require 'cucumber/rake/task'
- Cucumber::Rake::Task.new do |t|
- t.cucumber_opts = %w{--format pretty}
- end
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new
- 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
+require 'spree/core/testing_support/common_rake'
-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
- 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_wishlist', :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_wishlist:install'
- end
- end
-
- def migrate_db
- run_migrations
- end
- end
- AuthTestAppGenerator.start
-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
+ ENV['LIB_NAME'] = 'spree_wishlist'
+ Rake::Task['common:test_app'].invoke
end
-
-
View
@@ -1,4 +1,4 @@
-"0.80.x" => { :branch => 'namespace' }
+"0.80.x" => { :branch => 'master' }
"0.70.x" => { :ref => "0400d9e7c85f4ad637ac", :version => "1.2" }
"0.60.x" => { :ref => "5172de86dd46905e6d60288584b567155055675e", :version => "1.1" }
"0.50.x" => { :ref => "5172de86dd46905e6d60288584b567155055675e", :version => "1.1" }
@@ -1,5 +1,7 @@
class WishlistAbility
-# stuff like class AbilityDecorator goes here
+
+ # Stuff like class AbilityDecorator goes here.
+
include CanCan::Ability
def initialize(user)
@@ -10,19 +12,19 @@ def initialize(user)
can :create, Spree::Wishlist
# You can your own wishlists, and everyone cas see public ones
- can :show, Spree::Wishlist do |wishlist|
+ can :read, Spree::Wishlist do |wishlist|
wishlist.user == user || wishlist.is_public?
end
# You can only change your own wishlist
- can [:show, :move, :update, :edit, :destroy], Spree::Wishlist do |wishlist|
+ can [:read, :move, :update, :edit, :destroy], Spree::Wishlist do |wishlist|
wishlist.user == user
end
can :create, Spree::WishedProduct do |wished_product|
!user.new_record?
end
- can :show, Spree::WishedProduct do |wished_product|
+ can :read, Spree::WishedProduct do |wished_product|
wished_product.wishlist.user == user || wished_product.wishlist.is_public?
end
can [:index, :update, :delete], Spree::WishedProduct do |wished_product|
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Spree::WishedProductsController do
+
+ #Delete this example and add some real ones
+ it "should use Spree::WishedProductsController" do
+ controller.should be_an_instance_of(Spree::WishedProductsController)
+ end
+
+end
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Spree::WishlistsController do
+
+ #Delete this example and add some real ones
+ it "should use Spree::WishlistsController" do
+ controller.should be_an_instance_of(Spree::WishlistsController)
+ end
+
+end
@@ -1,10 +0,0 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-
-describe WishedProductsController do
-
- #Delete this example and add some real ones
- it "should use WishedProductsController" do
- controller.should be_an_instance_of(WishedProductsController)
- end
-
-end
@@ -1,10 +0,0 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-
-describe WishlistsController do
-
- #Delete this example and add some real ones
- it "should use WishlistsController" do
- controller.should be_an_instance_of(WishlistsController)
- end
-
-end
@@ -3,13 +3,13 @@
describe WishlistAbility do
- let(:user) { User.new }
- let(:ability) { Ability.new(user) }
+ let(:user) { Spree::User.new }
+ let(:ability) { WishlistAbility.new(user) }
let(:token) { nil }
TOKEN = "token123"
- after(:each) { Ability.abilities = Set.new }
+ # after(:each) { WishlistAbility.abilities = Set.new }
shared_examples_for "allow CRUD" do
it "should allow create" do
@@ -79,12 +79,12 @@
context "for Wishlist" do
context "private" do
- let(:resource) { Wishlist.new(:is_private => true) }
+ let(:resource) { Spree::Wishlist.new(:is_private => true) }
pending
end
context "public" do
- let(:resource) { Wishlist.new(:is_private => false) }
+ let(:resource) { Spree::Wishlist.new(:is_private => false) }
context "requested by same user" do
before { resource.user = user }
pending
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Spree::WishedProduct do
+ before(:each) do
+ @wished_product = Spree::WishedProduct.new
+ end
+
+ it "should be valid" do
+ @wished_product.should be_valid
+ end
+end
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe Spree::Wishlist do
+ before(:each) do
+ @wishlist = Spree::Wishlist.new(:name => 'test')
+ end
+
+ it "should be valid" do
+ @wishlist.should be_valid
+ end
+end
@@ -1,11 +0,0 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-
-describe WishedProduct do
- before(:each) do
- @wished_product = WishedProduct.new
- end
-
- it "should be valid" do
- @wished_product.should be_valid
- end
-end
@@ -1,11 +0,0 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-
-describe Wishlist do
- before(:each) do
- @wishlist = Wishlist.new
- end
-
- it "should be valid" do
- @wishlist.should be_valid
- end
-end
View
@@ -1,17 +1,15 @@
# 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'
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
-Dir["#{File.dirname(__FILE__)}/factories/**/*.rb"].each do |f|
- fp = File.expand_path(f)
- require fp
-end
+# Requires factories defined in spree_core
+require 'spree/core/testing_support/factories'
RSpec.configure do |config|
# == Mock Framework
@@ -31,11 +29,10 @@
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")
@@ -15,5 +15,9 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.require_paths = ["lib"]
- s.add_dependency('spree_core', '>= 0.30.1')
+ s.add_dependency 'spree_core', '>= 0.80.0.beta'
+
+ s.add_development_dependency 'factory_girl'
+ s.add_development_dependency 'rspec-rails', ' ~> 2.8.0.rc1'
+ s.add_development_dependency 'sqlite3'
end

0 comments on commit 349a235

Please sign in to comment.