draper 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.markdown +2 -2
- data/lib/draper/version.rb +1 -1
- data/lib/generators/test_unit/decorator_generator.rb +17 -0
- data/lib/generators/test_unit/templates/application_decorator_test.rb +11 -0
- data/lib/generators/test_unit/templates/decorator_test.rb +12 -0
- data/spec/generators/test_unit/decorator_generator_spec.rb +28 -0
- metadata +6 -1
data/Readme.markdown
CHANGED
@@ -22,14 +22,14 @@
|
|
22
22
|
|
23
23
|
## What's New
|
24
24
|
|
25
|
-
### Version 0.9.
|
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
|
32
|
+
* Automatically generate RSpec/Test::Unit stub for decorator class
|
33
33
|
|
34
34
|
## Goals
|
35
35
|
|
data/lib/draper/version.rb
CHANGED
@@ -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,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.
|
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
|