From c997f03bc188b502a1b6a3f7434277a5448bded4 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Tue, 7 Aug 2012 10:48:36 -0400 Subject: [PATCH] Adding initial controller specs. Both failing --- Gemfile | 2 +- spec/controllers/digitals_controller_spec.rb | 43 ++++++++++++++++++++ spec/models/order_spec.rb | 1 - spec/spec_helper.rb | 24 ++++------- 4 files changed, 51 insertions(+), 19 deletions(-) create mode 100644 spec/controllers/digitals_controller_spec.rb diff --git a/Gemfile b/Gemfile index 4e3bea9..ff9e196 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,6 @@ group :test do end end -gem 'spree', '~> 1.1.2' +gem 'spree', '~> 1.1.3' gemspec diff --git a/spec/controllers/digitals_controller_spec.rb b/spec/controllers/digitals_controller_spec.rb new file mode 100644 index 0000000..93f30b4 --- /dev/null +++ b/spec/controllers/digitals_controller_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe Spree::Admin::DigitalsController do + before do + @product = FactoryGirl.create :product + + controller.stub :authorize! => true + end + + let(:product) { @product } + + context "with variants" do + before do + # TODO add variants with digital + end + + it "should display an empty page when no digitals exist" do + + end + + it "should display list of digitals when they exist" do + + end + end + + context "without variants" do + render_views + + it "should display an empty page when no digitals exist" do + spree_get :index, "product_id" => product.permalink + response.code.should == "200" + response.body.should include("This product has no variants") + end + + it "should display list of digitals when they exist" do + @digital = FactoryGirl.create :digital, :variant => product.master + spree_get :index, :product_id => product.permalink + response.code.should == "200" + + end + + end +end \ No newline at end of file diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index 554409d..8314c82 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -81,7 +81,6 @@ describe Spree::Order do order.rate_hash.count.should == 1 order.rate_hash.first.shipping_method.calculator.class.should_not == Spree::Calculator::DigitalDelivery - puts "SHIPP #{order.rate_hash.first}" order.rate_hash.first.cost.should == 10.0 end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index aa638f7..1b4db0a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,34 +1,24 @@ -# Configure Rails Environment ENV["RAILS_ENV"] = "test" - require File.expand_path("../dummy/config/environment.rb", __FILE__) - require 'rspec/rails' # 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/env' +require 'spree/core/testing_support/controller_requests' +require 'spree/core/url_helpers' RSpec.configure do |config| - # == Mock Framework - # - # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: - # - # config.mock_with :mocha - # config.mock_with :flexmock - # 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" - - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. config.use_transactional_fixtures = true + + config.include Spree::Core::UrlHelpers + config.include Spree::Core::TestingSupport::ControllerRequests + config.include Devise::TestHelpers, :type => :controller end Dir[File.join(File.dirname(__FILE__), "factories/*.rb")].each {|f| require f }