active_decorator 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +0 -1
- data/README.md +31 -0
- data/Rakefile +8 -5
- data/gemfiles/Gemfile-rails.3.2.x +2 -2
- data/gemfiles/Gemfile-rails.4.0.x +2 -2
- data/gemfiles/Gemfile-rails.4.1.x +2 -2
- data/gemfiles/Gemfile-rails.4.2.x +2 -2
- data/gemfiles/Gemfile-rails.5.0.0.beta1 +2 -2
- data/lib/active_decorator/decorator.rb +6 -2
- data/lib/active_decorator/version.rb +1 -1
- data/{spec/configuration_spec.rb → test/configuration_test.rb} +8 -9
- data/test/controllers/fake_detection_test.rb +8 -0
- data/{spec → test}/fake_app/app/views/authors/index.html.erb +1 -1
- data/{spec → test}/fake_app/app/views/authors/show.html.erb +0 -0
- data/test/fake_app/app/views/authors/show.json.jbuilder +2 -0
- data/{spec → test}/fake_app/app/views/book_mailer/thanks.text.erb +0 -0
- data/{spec → test}/fake_app/app/views/books/_book.html.erb +0 -0
- data/{spec → test}/fake_app/app/views/books/_book.json.jbuilder +0 -0
- data/{spec → test}/fake_app/app/views/books/_book_locals.html.erb +0 -0
- data/{spec → test}/fake_app/app/views/books/error.html.erb +0 -0
- data/{spec → test}/fake_app/app/views/books/index.html.erb +0 -0
- data/{spec → test}/fake_app/app/views/books/purchase.html.erb +0 -0
- data/test/fake_app/app/views/books/show.html.erb +4 -0
- data/{spec → test}/fake_app/app/views/movies/show.html.erb +0 -0
- data/{spec → test}/fake_app/fake_app.rb +16 -8
- data/test/features/action_view_helpers_test.rb +36 -0
- data/test/features/controller_ivar_test.rb +39 -0
- data/test/features/jbuilder_test.rb +14 -0
- data/test/features/partial_test.rb +27 -0
- data/test/test_helper.rb +29 -0
- metadata +44 -44
- data/.rspec +0 -2
- data/spec/controllers/fake_detection_spec.rb +0 -7
- data/spec/fake_app/app/views/authors/show.json.jbuilder +0 -2
- data/spec/fake_app/app/views/books/show.html.erb +0 -4
- data/spec/features/action_view_helpers_spec.rb +0 -25
- data/spec/features/controller_ivar_spec.rb +0 -37
- data/spec/features/jbuilder_spec.rb +0 -12
- data/spec/features/partial_spec.rb +0 -25
- data/spec/spec_helper.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a855bb5a5b2a7810e08850debb930d60b7675a3
|
4
|
+
data.tar.gz: 11d92465273c6867f71c92027c9866465169b4ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40b0e9630767955088a50dd9c705431ea5dbfa0765fbfd9d363503737cfb52730bc4ce8f5a2dc2cc8992a6dc3a044aec74270ff4f730d7e6746d50f080e2747f
|
7
|
+
data.tar.gz: f8a888c5d6474ceb8d629ba0abc8c48dd87f6f3db6cca473b339a42e3cf66b20c14ca2c3fa3bbc4a55aae89a8385d281c3688c7174035bd5c7080fb6158198ef
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -107,6 +107,37 @@ end
|
|
107
107
|
<% end %>
|
108
108
|
```
|
109
109
|
|
110
|
+
## Testing
|
111
|
+
|
112
|
+
You can test a decorator using your favorite test framework by decorating the model instance with
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
ActiveDecorator::Decorator.instance.decorate(model_instance)
|
116
|
+
```
|
117
|
+
|
118
|
+
Considering an `Organization` model and it's simple decorator:
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
module OrganizationDecorator
|
122
|
+
def full_name
|
123
|
+
"#{first_name} #{last_name}"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
```
|
127
|
+
|
128
|
+
An RSpec test would look like:
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
describe '#full_name' do
|
132
|
+
it 'returns the full organization name' do
|
133
|
+
organization = Organization.new(first_name: 'John', last_name: 'Doe')
|
134
|
+
decorated_organization = ActiveDecorator::Decorator.instance.decorate(organization)
|
135
|
+
|
136
|
+
expect(decorated_organization.full_name).to eq('John Doe')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
```
|
140
|
+
|
110
141
|
## Configuring the decorator suffix
|
111
142
|
|
112
143
|
By default, ActiveDecorator searches a decorator module named `target_class.name + "Decorator"`
|
data/Rakefile
CHANGED
@@ -3,10 +3,13 @@
|
|
3
3
|
require 'bundler'
|
4
4
|
Bundler::GemHelper.install_tasks
|
5
5
|
|
6
|
-
require '
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
require 'rake/testtask'
|
7
|
+
|
8
|
+
Rake::TestTask.new do |t|
|
9
|
+
t.libs << "test"
|
10
|
+
t.pattern = 'test/**/*_test.rb'
|
11
|
+
t.warning = true
|
12
|
+
t.verbose = true
|
10
13
|
end
|
11
14
|
|
12
|
-
task :
|
15
|
+
task default: :test
|
@@ -1,9 +1,9 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'active_decorator', :
|
3
|
+
gem 'active_decorator', path: '..'
|
4
4
|
|
5
5
|
gem 'rails', '~> 3.2.0'
|
6
|
-
gem '
|
6
|
+
gem 'test-unit-rails', '1.0.2'
|
7
7
|
if RUBY_VERSION <= '1.8.7'
|
8
8
|
gem 'i18n', '~> 0.6.11'
|
9
9
|
end
|
@@ -41,8 +41,12 @@ module ActiveDecorator
|
|
41
41
|
@@decorators[model_class] = nil
|
42
42
|
end
|
43
43
|
rescue NameError
|
44
|
-
|
45
|
-
|
44
|
+
if model_class.respond_to?(:base_class) && (model_class.base_class != model_class)
|
45
|
+
@@decorators[model_class] = decorator_for model_class.base_class
|
46
|
+
else
|
47
|
+
# Cache nil results
|
48
|
+
@@decorators[model_class] = nil
|
49
|
+
end
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
1
3
|
Comic = Struct.new(:title, :price)
|
2
4
|
|
3
5
|
module ComicPresenter
|
@@ -6,22 +8,19 @@ module ComicPresenter
|
|
6
8
|
end
|
7
9
|
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
context 'with a custom decorator_suffix' do
|
13
|
-
before do
|
11
|
+
class ConfigurationTest < Test::Unit::TestCase
|
12
|
+
test 'with a custom decorator_suffix' do
|
13
|
+
begin
|
14
14
|
ActiveDecorator.configure do |config|
|
15
15
|
config.decorator_suffix = 'Presenter'
|
16
16
|
end
|
17
|
-
end
|
18
17
|
|
19
|
-
|
18
|
+
comic = ActiveDecorator::Decorator.instance.decorate Comic.new("amatsuda's (Poignant) Guide to ActiveDecorator", 3)
|
19
|
+
assert_equal '$3', comic.price
|
20
|
+
ensure
|
20
21
|
ActiveDecorator.configure do |config|
|
21
22
|
config.decorator_suffix = 'Decorator'
|
22
23
|
end
|
23
24
|
end
|
24
|
-
|
25
|
-
specify { comic.price.should == '$3' }
|
26
25
|
end
|
27
26
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<%= render author.books %>
|
7
7
|
<% elsif params[:partial] == 'locals' %>
|
8
8
|
<% author.books.each do |book| %>
|
9
|
-
<%= render :
|
9
|
+
<%= render partial: 'books/book_locals', locals: {b: book} %>
|
10
10
|
<% end %>
|
11
11
|
<% else %>
|
12
12
|
<% author.books.each do |book| %>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -6,12 +6,12 @@ require 'ostruct'
|
|
6
6
|
require 'jbuilder'
|
7
7
|
|
8
8
|
# config
|
9
|
-
ActiveRecord::Base.establish_connection(:
|
9
|
+
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
|
10
10
|
|
11
11
|
module ActiveDecoratorTestApp
|
12
12
|
class Application < Rails::Application
|
13
13
|
config.secret_token = '"confusion" will be my epitaph.'
|
14
|
-
config.session_store :cookie_store, :
|
14
|
+
config.session_store :cookie_store, key: '_myapp_session'
|
15
15
|
config.active_support.deprecation = :log
|
16
16
|
config.eager_load = false
|
17
17
|
config.action_dispatch.show_exceptions = false
|
@@ -24,15 +24,21 @@ ActiveDecoratorTestApp::Application.initialize!
|
|
24
24
|
|
25
25
|
# routes
|
26
26
|
ActiveDecoratorTestApp::Application.routes.draw do
|
27
|
-
resources :authors, :
|
28
|
-
resources :books, :
|
27
|
+
resources :authors, only: [:index, :show] do
|
28
|
+
resources :books, only: [:index, :show] do
|
29
|
+
member do
|
30
|
+
get :error
|
31
|
+
post :purchase
|
32
|
+
end
|
33
|
+
end
|
34
|
+
resources :novels, only: [:index, :show] do
|
29
35
|
member do
|
30
36
|
get :error
|
31
37
|
post :purchase
|
32
38
|
end
|
33
39
|
end
|
34
40
|
end
|
35
|
-
resources :movies, :
|
41
|
+
resources :movies, only: :show
|
36
42
|
end
|
37
43
|
|
38
44
|
# models
|
@@ -42,6 +48,8 @@ end
|
|
42
48
|
class Book < ActiveRecord::Base
|
43
49
|
belongs_to :author
|
44
50
|
end
|
51
|
+
class Novel < Book
|
52
|
+
end
|
45
53
|
class Movie < ActiveRecord::Base
|
46
54
|
end
|
47
55
|
|
@@ -68,7 +76,7 @@ module BookDecorator
|
|
68
76
|
end
|
69
77
|
|
70
78
|
def link
|
71
|
-
link_to title, "#{request.protocol}#{request.host_with_port}/assets/sample.png", :
|
79
|
+
link_to title, "#{request.protocol}#{request.host_with_port}/assets/sample.png", class: 'title'
|
72
80
|
end
|
73
81
|
|
74
82
|
def cover_image
|
@@ -153,7 +161,7 @@ end
|
|
153
161
|
class BookMailer < ActionMailer::Base
|
154
162
|
def thanks(book)
|
155
163
|
@book = book
|
156
|
-
mail :
|
164
|
+
mail from: 'nobody@example.com', to: 'test@example.com', subject: 'Thanks'
|
157
165
|
end
|
158
166
|
end
|
159
167
|
|
@@ -161,7 +169,7 @@ end
|
|
161
169
|
class CreateAllTables < ActiveRecord::Migration
|
162
170
|
def self.up
|
163
171
|
create_table(:authors) {|t| t.string :name}
|
164
|
-
create_table(:books) {|t| t.string :title; t.references :author}
|
172
|
+
create_table(:books) {|t| t.string :title; t.references :author; t.string :type }
|
165
173
|
create_table(:movies) {|t| t.string :name}
|
166
174
|
end
|
167
175
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ActionViewHelpersTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
aamine = Author.create! name: 'aamine'
|
6
|
+
@rhg = aamine.books.create! title: 'RHG'
|
7
|
+
@rhg_novel = aamine.books.create! title: 'RHG Novel', type: 'Novel'
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'invoking action_view helper methods' do
|
11
|
+
visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}"
|
12
|
+
within 'a.title' do
|
13
|
+
assert page.has_content? 'RHG'
|
14
|
+
end
|
15
|
+
assert page.has_css?('img')
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'invoking action_view helper methods on model subclass' do
|
19
|
+
visit "/authors/#{@rhg_novel.author.id}/books/#{@rhg_novel.id}"
|
20
|
+
within 'a.title' do
|
21
|
+
assert page.has_content? 'RHG Novel'
|
22
|
+
end
|
23
|
+
assert page.has_css?('img')
|
24
|
+
end
|
25
|
+
|
26
|
+
test 'invoking action_view helper methods in rescue_from view' do
|
27
|
+
visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}/error"
|
28
|
+
assert page.has_content?('ERROR')
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'make sure that action_view + action_mailer works' do
|
32
|
+
visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}"
|
33
|
+
click_link 'purchase'
|
34
|
+
assert page.has_content? 'done'
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ControllerIvarTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@matz = Author.create! name: 'matz'
|
6
|
+
@matz.books.create! title: 'the world of code'
|
7
|
+
Author.create! name: 'takahashim'
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'decorating a model object in ivar' do
|
11
|
+
visit "/authors/#{@matz.id}"
|
12
|
+
assert page.has_content? 'matz'
|
13
|
+
assert page.has_content? 'matz'.capitalize
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'decorating model scope in ivar' do
|
17
|
+
visit '/authors'
|
18
|
+
assert page.has_content? 'takahashim'
|
19
|
+
assert page.has_content? 'takahashim'.reverse
|
20
|
+
end
|
21
|
+
|
22
|
+
test "decorating models' array in ivar" do
|
23
|
+
visit '/authors?variable_type=array'
|
24
|
+
assert page.has_content? 'takahashim'
|
25
|
+
assert page.has_content? 'takahashim'.reverse
|
26
|
+
end
|
27
|
+
|
28
|
+
test "decorating models' proxy object in ivar" do
|
29
|
+
visit '/authors?variable_type=proxy'
|
30
|
+
assert page.has_content? 'takahashim'
|
31
|
+
assert page.has_content? 'takahashim'.reverse
|
32
|
+
end
|
33
|
+
|
34
|
+
test 'decorating model association proxy in ivar' do
|
35
|
+
visit "/authors/#{@matz.id}/books"
|
36
|
+
assert page.has_content? 'the world of code'
|
37
|
+
assert page.has_content? 'the world of code'.reverse
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class JbuilderTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
Author.create! name: 'aamine'
|
6
|
+
nari = Author.create! name: 'nari'
|
7
|
+
nari.books.create! title: 'the gc book'
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'decorating objects in Jbuilder partials' do
|
11
|
+
visit "/authors/#{Author.last.id}.json"
|
12
|
+
assert_equal '{"name":"nari","books":[{"title":"the gc book","reverse_title":"koob cg eht"}]}', page.source
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PartialTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
Author.create! name: 'aamine'
|
6
|
+
nari = Author.create! name: 'nari'
|
7
|
+
nari.books.create! title: 'the gc book'
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'decorating implicit @object' do
|
11
|
+
visit '/authors'
|
12
|
+
assert page.has_content? 'the gc book'
|
13
|
+
assert page.has_content? 'the gc book'.reverse
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'decorating implicit @collection' do
|
17
|
+
visit '/authors?partial=collection'
|
18
|
+
assert page.has_content? 'the gc book'
|
19
|
+
assert page.has_content? 'the gc book'.reverse
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'decorating objects in @locals' do
|
23
|
+
visit '/authors?partial=locals'
|
24
|
+
assert page.has_content? 'the gc book'
|
25
|
+
assert page.has_content? 'the gc book'.upcase
|
26
|
+
end
|
27
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
# load Rails first
|
4
|
+
require 'rails'
|
5
|
+
|
6
|
+
# load the plugin
|
7
|
+
require 'active_decorator'
|
8
|
+
|
9
|
+
# needs to load the app next
|
10
|
+
require 'fake_app/fake_app'
|
11
|
+
|
12
|
+
require 'test/unit/rails/test_help'
|
13
|
+
|
14
|
+
class ActionDispatch::IntegrationTest
|
15
|
+
include Capybara::DSL
|
16
|
+
end
|
17
|
+
|
18
|
+
module DatabaseDeleter
|
19
|
+
def setup
|
20
|
+
Book.delete_all
|
21
|
+
Author.delete_all
|
22
|
+
Movie.delete_all
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Test::Unit::TestCase.send :prepend, DatabaseDeleter
|
28
|
+
|
29
|
+
CreateAllTables.up unless ActiveRecord::Base.connection.table_exists? 'authors'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_decorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple and Rubyish view helper for Rails
|
14
14
|
email:
|
@@ -18,7 +18,6 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- ".gitignore"
|
21
|
-
- ".rspec"
|
22
21
|
- ".travis.yml"
|
23
22
|
- Gemfile
|
24
23
|
- MIT-LICENSE
|
@@ -46,26 +45,26 @@ files:
|
|
46
45
|
- lib/generators/rspec/templates/decorator_spec.rb
|
47
46
|
- lib/generators/test_unit/decorator_generator.rb
|
48
47
|
- lib/generators/test_unit/templates/decorator_test.rb
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
67
|
-
-
|
68
|
-
-
|
48
|
+
- test/configuration_test.rb
|
49
|
+
- test/controllers/fake_detection_test.rb
|
50
|
+
- test/fake_app/app/views/authors/index.html.erb
|
51
|
+
- test/fake_app/app/views/authors/show.html.erb
|
52
|
+
- test/fake_app/app/views/authors/show.json.jbuilder
|
53
|
+
- test/fake_app/app/views/book_mailer/thanks.text.erb
|
54
|
+
- test/fake_app/app/views/books/_book.html.erb
|
55
|
+
- test/fake_app/app/views/books/_book.json.jbuilder
|
56
|
+
- test/fake_app/app/views/books/_book_locals.html.erb
|
57
|
+
- test/fake_app/app/views/books/error.html.erb
|
58
|
+
- test/fake_app/app/views/books/index.html.erb
|
59
|
+
- test/fake_app/app/views/books/purchase.html.erb
|
60
|
+
- test/fake_app/app/views/books/show.html.erb
|
61
|
+
- test/fake_app/app/views/movies/show.html.erb
|
62
|
+
- test/fake_app/fake_app.rb
|
63
|
+
- test/features/action_view_helpers_test.rb
|
64
|
+
- test/features/controller_ivar_test.rb
|
65
|
+
- test/features/jbuilder_test.rb
|
66
|
+
- test/features/partial_test.rb
|
67
|
+
- test/test_helper.rb
|
69
68
|
homepage: https://github.com/amatsuda/active_decorator
|
70
69
|
licenses: []
|
71
70
|
metadata: {}
|
@@ -85,28 +84,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
84
|
version: '0'
|
86
85
|
requirements: []
|
87
86
|
rubyforge_project: active_decorator
|
88
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.5.1
|
89
88
|
signing_key:
|
90
89
|
specification_version: 4
|
91
90
|
summary: A simple and Rubyish view helper for Rails
|
92
91
|
test_files:
|
93
|
-
-
|
94
|
-
-
|
95
|
-
-
|
96
|
-
-
|
97
|
-
-
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
-
|
102
|
-
-
|
103
|
-
-
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
108
|
-
-
|
109
|
-
-
|
110
|
-
-
|
111
|
-
-
|
112
|
-
-
|
92
|
+
- test/configuration_test.rb
|
93
|
+
- test/controllers/fake_detection_test.rb
|
94
|
+
- test/fake_app/app/views/authors/index.html.erb
|
95
|
+
- test/fake_app/app/views/authors/show.html.erb
|
96
|
+
- test/fake_app/app/views/authors/show.json.jbuilder
|
97
|
+
- test/fake_app/app/views/book_mailer/thanks.text.erb
|
98
|
+
- test/fake_app/app/views/books/_book.html.erb
|
99
|
+
- test/fake_app/app/views/books/_book.json.jbuilder
|
100
|
+
- test/fake_app/app/views/books/_book_locals.html.erb
|
101
|
+
- test/fake_app/app/views/books/error.html.erb
|
102
|
+
- test/fake_app/app/views/books/index.html.erb
|
103
|
+
- test/fake_app/app/views/books/purchase.html.erb
|
104
|
+
- test/fake_app/app/views/books/show.html.erb
|
105
|
+
- test/fake_app/app/views/movies/show.html.erb
|
106
|
+
- test/fake_app/fake_app.rb
|
107
|
+
- test/features/action_view_helpers_test.rb
|
108
|
+
- test/features/controller_ivar_test.rb
|
109
|
+
- test/features/jbuilder_test.rb
|
110
|
+
- test/features/partial_test.rb
|
111
|
+
- test/test_helper.rb
|
112
|
+
has_rdoc:
|
data/.rspec
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
feature 'fallback to helpers' do
|
2
|
-
background do
|
3
|
-
aamine = Author.create! :name => 'aamine'
|
4
|
-
@rhg = aamine.books.create! :title => 'RHG'
|
5
|
-
end
|
6
|
-
|
7
|
-
scenario 'invoking action_view helper methods' do
|
8
|
-
visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}"
|
9
|
-
within 'a.title' do
|
10
|
-
page.should have_content 'RHG'
|
11
|
-
end
|
12
|
-
page.should have_css('img')
|
13
|
-
end
|
14
|
-
|
15
|
-
scenario 'invoking action_view helper methods in rescue_from view' do
|
16
|
-
visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}/error"
|
17
|
-
page.should have_content('ERROR')
|
18
|
-
end
|
19
|
-
|
20
|
-
scenario 'make sure that action_view + action_mailer works' do
|
21
|
-
visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}"
|
22
|
-
click_link 'purchase'
|
23
|
-
page.should have_content 'done'
|
24
|
-
end
|
25
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
feature 'decorating controller ivar' do
|
2
|
-
background do
|
3
|
-
@matz = Author.create! :name => 'matz'
|
4
|
-
@matz.books.create! :title => 'the world of code'
|
5
|
-
Author.create! :name => 'takahashim'
|
6
|
-
end
|
7
|
-
|
8
|
-
scenario 'decorating a model object in ivar' do
|
9
|
-
visit "/authors/#{@matz.id}"
|
10
|
-
page.should have_content 'matz'
|
11
|
-
page.should have_content 'matz'.capitalize
|
12
|
-
end
|
13
|
-
|
14
|
-
scenario 'decorating model scope in ivar' do
|
15
|
-
visit '/authors'
|
16
|
-
page.should have_content 'takahashim'
|
17
|
-
page.should have_content 'takahashim'.reverse
|
18
|
-
end
|
19
|
-
|
20
|
-
scenario "decorating models' array in ivar" do
|
21
|
-
visit '/authors?variable_type=array'
|
22
|
-
page.should have_content 'takahashim'
|
23
|
-
page.should have_content 'takahashim'.reverse
|
24
|
-
end
|
25
|
-
|
26
|
-
scenario "decorating models' proxy object in ivar" do
|
27
|
-
visit '/authors?variable_type=proxy'
|
28
|
-
page.should have_content 'takahashim'
|
29
|
-
page.should have_content 'takahashim'.reverse
|
30
|
-
end
|
31
|
-
|
32
|
-
scenario 'decorating model association proxy in ivar' do
|
33
|
-
visit "/authors/#{@matz.id}/books"
|
34
|
-
page.should have_content 'the world of code'
|
35
|
-
page.should have_content 'the world of code'.reverse
|
36
|
-
end
|
37
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
feature 'decorating partial object in Jbuilder' do
|
2
|
-
background do
|
3
|
-
Author.create! :name => 'aamine'
|
4
|
-
nari = Author.create! :name => 'nari'
|
5
|
-
nari.books.create! :title => 'the gc book'
|
6
|
-
end
|
7
|
-
|
8
|
-
scenario 'decorating objects in Jbuilder partials' do
|
9
|
-
visit "/authors/#{Author.last.id}.json"
|
10
|
-
page.source.should eq '{"name":"nari","books":[{"title":"the gc book","reverse_title":"koob cg eht"}]}'
|
11
|
-
end
|
12
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
feature 'decorating partial object' do
|
2
|
-
background do
|
3
|
-
Author.create! :name => 'aamine'
|
4
|
-
nari = Author.create! :name => 'nari'
|
5
|
-
nari.books.create! :title => 'the gc book'
|
6
|
-
end
|
7
|
-
|
8
|
-
scenario 'decorating implicit @object' do
|
9
|
-
visit '/authors'
|
10
|
-
page.should have_content 'the gc book'
|
11
|
-
page.should have_content 'the gc book'.reverse
|
12
|
-
end
|
13
|
-
|
14
|
-
scenario 'decorating implicit @collection' do
|
15
|
-
visit '/authors?partial=collection'
|
16
|
-
page.should have_content 'the gc book'
|
17
|
-
page.should have_content 'the gc book'.reverse
|
18
|
-
end
|
19
|
-
|
20
|
-
scenario 'decorating objects in @locals' do
|
21
|
-
visit '/authors?partial=locals'
|
22
|
-
page.should have_content 'the gc book'
|
23
|
-
page.should have_content 'the gc book'.upcase
|
24
|
-
end
|
25
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
-
# load Rails first
|
4
|
-
require 'rails'
|
5
|
-
require 'active_decorator'
|
6
|
-
# needs to load the app before loading rspec/rails => capybara
|
7
|
-
require 'fake_app/fake_app'
|
8
|
-
require 'rspec/rails'
|
9
|
-
# Requires supporting files with custom matchers and macros, etc,
|
10
|
-
# in ./support/ and its subdirectories.
|
11
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
12
|
-
|
13
|
-
RSpec.configure do |config|
|
14
|
-
config.expect_with :rspec do |c|
|
15
|
-
c.syntax = [:should, :expect]
|
16
|
-
end
|
17
|
-
|
18
|
-
config.before :all do
|
19
|
-
CreateAllTables.up unless ActiveRecord::Base.connection.table_exists? 'authors'
|
20
|
-
end
|
21
|
-
|
22
|
-
config.before :each do
|
23
|
-
Book.delete_all
|
24
|
-
Author.delete_all
|
25
|
-
Movie.delete_all
|
26
|
-
end
|
27
|
-
end
|