From 7e45a1f7723eb40ed63d379396e4e27b09ef091c Mon Sep 17 00:00:00 2001 From: Thiago Almeida Date: Tue, 14 Feb 2012 00:19:03 -0200 Subject: [PATCH] draper:decorator defaults to rspec too --- .../decorator/decorator_generator_spec.rb | 85 ++++++++++++++++++- .../rspec/decorator_generator_spec.rb | 22 ----- .../test_unit/decorator_generator_spec.rb | 22 ----- 3 files changed, 83 insertions(+), 46 deletions(-) delete mode 100644 spec/generators/rspec/decorator_generator_spec.rb delete mode 100644 spec/generators/test_unit/decorator_generator_spec.rb diff --git a/spec/generators/draper/decorator/decorator_generator_spec.rb b/spec/generators/draper/decorator/decorator_generator_spec.rb index fb696b6..4c79d3a 100644 --- a/spec/generators/draper/decorator/decorator_generator_spec.rb +++ b/spec/generators/draper/decorator/decorator_generator_spec.rb @@ -9,6 +9,50 @@ describe Draper::DecoratorGenerator do 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 @@ describe Draper::DecoratorGenerator do it { should exist } it { should contain "class ProductsDecorator < ApplicationDecorator" } end - 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 \ No newline at end of file diff --git a/spec/generators/rspec/decorator_generator_spec.rb b/spec/generators/rspec/decorator_generator_spec.rb deleted file mode 100644 index e7b19fb..0000000 --- a/spec/generators/rspec/decorator_generator_spec.rb +++ /dev/null @@ -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 diff --git a/spec/generators/test_unit/decorator_generator_spec.rb b/spec/generators/test_unit/decorator_generator_spec.rb deleted file mode 100644 index 7b19cad..0000000 --- a/spec/generators/test_unit/decorator_generator_spec.rb +++ /dev/null @@ -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