draper 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,14 +22,14 @@
22
22
 
23
23
  ## What's New
24
24
 
25
- ### Version 0.9.1
25
+ ### Version 0.9.2
26
26
 
27
27
  * Automatically generate a named accessor for the wrapped object, so now inside of `ArticleDecorator` you can use `article` instead of just `model`
28
28
  * Removed the `lazy_helpers` method to favor using `include Draper::LazyHelpers`
29
29
  * Refactored how methods are selected for delegation to the wrapped model
30
30
  * Fixed how the view context is stored in the `Thread.current` to resolve cross-request issues
31
31
  * Decorated collections now return a collection proxy instead of an array, which fixes many compatibility issues
32
- * Automatically generate `RSpec` stub for decorators [PENDING: Make this work properly for `Test::Unit` -- help?]
32
+ * Automatically generate RSpec/Test::Unit stub for decorator class
33
33
 
34
34
  ## Goals
35
35
 
@@ -1,3 +1,3 @@
1
1
  module Draper
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
@@ -0,0 +1,17 @@
1
+ module TestUnit
2
+ class DecoratorGenerator < ::Rails::Generators::NamedBase
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ TEST_ROOT = 'test/decorators/'
6
+ APPLICATION_DECORATOR_TEST = 'application_decorator_test.rb'
7
+ APPLICATION_DECORATOR_TEST_PATH = TEST_ROOT + APPLICATION_DECORATOR_TEST
8
+
9
+ def build_model_and_application_decorator_tests
10
+ empty_directory TEST_ROOT
11
+ unless File.exists?(APPLICATION_DECORATOR_TEST_PATH)
12
+ template APPLICATION_DECORATOR_TEST, APPLICATION_DECORATOR_TEST_PATH
13
+ end
14
+ template 'decorator_test.rb', "#{TEST_ROOT}#{singular_name}_decorator_test.rb"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ require 'test_helper'
2
+
3
+ class ApplicationDecoratorTest < ActiveSupport::TestCase
4
+ def setup
5
+ ApplicationController.new.set_current_view_context
6
+ end
7
+
8
+ # test "the truth" do
9
+ # assert true
10
+ # end
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+
3
+ class <%= singular_name.camelize %>DecoratorTest < ActiveSupport::TestCase
4
+ def setup
5
+ ApplicationController.new.set_current_view_context
6
+ end
7
+
8
+ # test "the truth" do
9
+ # assert true
10
+ # end
11
+ end
12
+
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ # Generators are not automatically loaded by Rails
4
+ require 'generators/test_unit/decorator_generator'
5
+
6
+ describe TestUnit::DecoratorGenerator do
7
+ # Tell the generator where to put its output (what it thinks of as Rails.root)
8
+ destination File.expand_path("../../../../tmp", __FILE__)
9
+
10
+ before { prepare_destination }
11
+
12
+ describe 'no arguments' do
13
+ before { run_generator %w(products) }
14
+
15
+ describe 'test/decorators/application_decorator_test.rb' do
16
+ subject { file('test/decorators/application_decorator_test.rb') }
17
+ it { should exist }
18
+ it { should contain "class ApplicationDecoratorTest < ActiveSupport::TestCase" }
19
+ end
20
+
21
+ describe 'test/decorators/products_decorator_test.rb' do
22
+ subject { file('test/decorators/products_decorator_test.rb') }
23
+ it { should exist }
24
+ it { should contain "class ProductsDecoratorTest < ActiveSupport::TestCase" }
25
+ end
26
+
27
+ end
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: draper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -63,10 +63,14 @@ files:
63
63
  - lib/generators/rspec/decorator_generator.rb
64
64
  - lib/generators/rspec/templates/application_decorator_spec.rb
65
65
  - lib/generators/rspec/templates/decorator_spec.rb
66
+ - lib/generators/test_unit/decorator_generator.rb
67
+ - lib/generators/test_unit/templates/application_decorator_test.rb
68
+ - lib/generators/test_unit/templates/decorator_test.rb
66
69
  - spec/base_spec.rb
67
70
  - spec/draper/model_support_spec.rb
68
71
  - spec/generators/draper/decorator/decorator_generator_spec.rb
69
72
  - spec/generators/rspec/decorator_generator_spec.rb
73
+ - spec/generators/test_unit/decorator_generator_spec.rb
70
74
  - spec/samples/active_record.rb
71
75
  - spec/samples/application_controller.rb
72
76
  - spec/samples/application_helper.rb
@@ -107,6 +111,7 @@ test_files:
107
111
  - spec/draper/model_support_spec.rb
108
112
  - spec/generators/draper/decorator/decorator_generator_spec.rb
109
113
  - spec/generators/rspec/decorator_generator_spec.rb
114
+ - spec/generators/test_unit/decorator_generator_spec.rb
110
115
  - spec/samples/active_record.rb
111
116
  - spec/samples/application_controller.rb
112
117
  - spec/samples/application_helper.rb