Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

draper:decorator defaults to rspec too

  • Loading branch information...
commit 7e45a1f7723eb40ed63d379396e4e27b09ef091c 1 parent 852b647
@thejamespinto thejamespinto authored
View
83 spec/generators/draper/decorator/decorator_generator_spec.rb
@@ -9,6 +9,50 @@
before { prepare_destination }
+ context 'decorator context' do
+ before { run_generator ["product"] }
+
+ describe 'app/decorators/product_decorator.rb' do
+ subject { file('app/decorators/product_decorator.rb') }
+ it { should exist }
+ it { should contain "class ProductDecorator < ApplicationDecorator" }
+ end
+ end
+
+ context 'default test framework' do
+ before { run_generator ["product"] }
+
+ describe 'spec/decorators/product_decorator_spec.rb' do
+ subject { file('spec/decorators/product_decorator_spec.rb') }
+ it { should exist }
+ it { should contain "describe ProductDecorator" }
+ end
+ end
+
+ context 'using rspec' do
+ before { run_generator ["product", "-t=rspec"] }
+
+ describe 'spec/decorators/product_decorator_spec.rb' do
+ subject { file('spec/decorators/product_decorator_spec.rb') }
+ it { should exist }
+ it { should contain "describe ProductDecorator" }
+ end
+ end
+
+ context 'using rspec' do
+ before { run_generator ["product", "-t=test_unit"] }
+
+ describe 'test/decorators/product_decorator_test.rb' do
+ subject { file('test/decorators/product_decorator_test.rb') }
+ it { should exist }
+ it { should contain "class ProductDecoratorTest < ActiveSupport::TestCase" }
+ end
+ end
+
+end
+
+
+=begin
describe 'no arguments' do
before { run_generator %w(products) }
@@ -17,6 +61,43 @@
it { should exist }
it { should contain "class ProductsDecorator < ApplicationDecorator" }
end
+ end
+
+
+ context 'simple' do
+ before { run_generator %w(products) }
+
+ describe 'app/decorators/products_decorator.rb' do
+ subject { file('app/decorators/products_decorator.rb') }
+ it { should exist }
+ it { should contain "class ProductsDecorator < ApplicationDecorator" }
+ end
+ end
+
+
+
+
+
+ context 'using rspec' do
+
+ describe 'app/decorators/products_decorator.rb' do
+ subject { file('app/decorators/products_decorator.rb') }
+ it { should exist }
+ it { should contain "class ProductsDecorator < ApplicationDecorator" }
+ end
+
+ shared_examples_for "ApplicationDecoratorGenerator" do
+ describe 'app/decorators/application_decorator.rb' do
+ subject { file('app/decorators/application_decorator.rb') }
+ it { should exist }
+ it { should contain "class ApplicationDecorator < Draper::Base" }
+ end
+ end
+ describe 'spec/decorators/application_decorator_spec.rb' do
+ subject { file('spec/decorators/application_decorator_spec.rb') }
+ it { should exist }
+ it { should contain "describe ApplicationDecorator do" }
+ end
end
-end
+=end
View
22 spec/generators/rspec/decorator_generator_spec.rb
@@ -1,22 +0,0 @@
-require 'spec_helper'
-
-# Generators are not automatically loaded by Rails
-require 'generators/rspec/decorator_generator'
-
-describe Rspec::DecoratorGenerator do
- # Tell the generator where to put its output (what it thinks of as Rails.root)
- destination File.expand_path("../../../../tmp", __FILE__)
-
- before { prepare_destination }
-
- describe 'no arguments' do
- before { run_generator %w(products) }
-
- describe 'spec/decorators/products_decorator_spec.rb' do
- subject { file('spec/decorators/products_decorator_spec.rb') }
- it { should exist }
- it { should contain "describe ProductsDecorator" }
- end
-
- end
-end
View
22 spec/generators/test_unit/decorator_generator_spec.rb
@@ -1,22 +0,0 @@
-require 'spec_helper'
-
-# Generators are not automatically loaded by Rails
-require 'generators/test_unit/decorator_generator'
-
-describe TestUnit::DecoratorGenerator do
- # Tell the generator where to put its output (what it thinks of as Rails.root)
- destination File.expand_path("../../../../tmp", __FILE__)
-
- before { prepare_destination }
-
- describe 'no arguments' do
- before { run_generator %w(products) }
-
- describe 'test/decorators/products_decorator_test.rb' do
- subject { file('test/decorators/products_decorator_test.rb') }
- it { should exist }
- it { should contain "class ProductsDecoratorTest < ActiveSupport::TestCase" }
- end
-
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.