dry_views 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/README.md +7 -2
- data/dry_views.gemspec +1 -1
- data/lib/dry_views/railtie.rb +1 -1
- data/lib/dry_views/version.rb +1 -1
- data/spec/controllers/dummy_controller_spec.rb +44 -4
- data/spec/dummy/app/controllers/dummy_controller.rb +7 -1
- data/spec/dummy/app/views/dummy/_no_main_content.html.erb +1 -0
- data/spec/dummy/app/views/dummy/{index.html.erb → content_for.html.erb} +6 -0
- data/spec/dummy/app/views/dummy/content_for_with_default.html.erb +4 -0
- data/spec/dummy/app/views/dummy/no_content.html.erb +9 -0
- data/spec/dummy/app/views/layouts/application.html.erb +2 -0
- metadata +11 -5
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
# DryViews
|
1
|
+
# DryViews [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/pboling/dry_views) [![Build Status](https://secure.travis-ci.org/pboling/dry_views.png?branch=master)](http://travis-ci.org/pboling/dry_views)
|
2
2
|
|
3
|
-
|
3
|
+
## Why?
|
4
|
+
|
5
|
+
* Keep the views dry with content_for_with_default and friends!
|
6
|
+
* Complete flexibility in defining defaults and overrides.
|
7
|
+
* Remove most or all logic from views.
|
8
|
+
* Allow for no content to override a default.
|
4
9
|
|
5
10
|
DryViews provides extensions to ActionView::Helpers::CaptureHelper, which is part of ActionPack:
|
6
11
|
* content_for_with_default
|
data/dry_views.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
# Development Dependencies
|
19
19
|
gem.add_development_dependency(%q<rails>, ["> 3"])
|
20
20
|
gem.add_development_dependency(%q<activesupport>, ["> 3"])
|
21
|
-
gem.add_development_dependency(%q<rspec-rails>, [">= 2.
|
21
|
+
gem.add_development_dependency(%q<rspec-rails>, [">= 2.11.0"])
|
22
22
|
gem.add_development_dependency(%q<reek>, [">= 1.2.8"])
|
23
23
|
gem.add_development_dependency(%q<roodi>, [">= 2.1.0"])
|
24
24
|
|
data/lib/dry_views/railtie.rb
CHANGED
data/lib/dry_views/version.rb
CHANGED
@@ -4,21 +4,61 @@ describe DummyController do
|
|
4
4
|
|
5
5
|
render_views
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
describe "content_for" do
|
8
|
+
before(:each) do
|
9
|
+
get :content_for
|
10
|
+
end
|
10
11
|
|
11
|
-
describe "CaptureHelper" do
|
12
12
|
it "should be success" do
|
13
13
|
response.should be_success
|
14
14
|
end
|
15
15
|
it "should render :main_content override" do
|
16
16
|
response.body.should =~ /This is main_content override/m
|
17
17
|
end
|
18
|
+
it "should render :top_content override" do
|
19
|
+
response.body.should =~ /This is top_content override/m
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "content_for_with_default" do
|
24
|
+
before(:each) do
|
25
|
+
get :content_for_with_default
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be success" do
|
29
|
+
response.should be_success
|
30
|
+
end
|
31
|
+
it "should render action template in body" do
|
32
|
+
response.body.should =~ /This is just an action template/m
|
33
|
+
end
|
34
|
+
it "should render :main_content default" do
|
35
|
+
response.body.should =~ /This is default main_content/m
|
36
|
+
end
|
18
37
|
it "should render :top_content default" do
|
19
38
|
response.body.should =~ /This is default top_content/m
|
20
39
|
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "no_content_for" do
|
43
|
+
before(:each) do
|
44
|
+
get :no_content
|
45
|
+
end
|
21
46
|
|
47
|
+
it "should be success" do
|
48
|
+
response.should be_success
|
49
|
+
end
|
50
|
+
it "should not render :main_content default" do
|
51
|
+
response.body.should_not =~ /This is main_content override/m
|
52
|
+
end
|
53
|
+
it "should not render :main_content override" do
|
54
|
+
response.body.should_not =~ /This is default main_content/m
|
55
|
+
end
|
56
|
+
it "should not render :top_content default" do
|
57
|
+
response.body.should_not =~ /This is top_content override/m
|
58
|
+
end
|
59
|
+
it "should not render :top_content override" do
|
60
|
+
response.body.should_not =~ /This is default top_content/m
|
61
|
+
end
|
22
62
|
end
|
23
63
|
|
24
64
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%- no_content_for :main_content %>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry_views
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
53
|
+
version: 2.11.0
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: 2.11.0
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: reek
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +123,10 @@ files:
|
|
123
123
|
- spec/dummy/app/helpers/application_helper.rb
|
124
124
|
- spec/dummy/app/mailers/.gitkeep
|
125
125
|
- spec/dummy/app/models/.gitkeep
|
126
|
-
- spec/dummy/app/views/dummy/
|
126
|
+
- spec/dummy/app/views/dummy/_no_main_content.html.erb
|
127
|
+
- spec/dummy/app/views/dummy/content_for.html.erb
|
128
|
+
- spec/dummy/app/views/dummy/content_for_with_default.html.erb
|
129
|
+
- spec/dummy/app/views/dummy/no_content.html.erb
|
127
130
|
- spec/dummy/app/views/layouts/application.html.erb
|
128
131
|
- spec/dummy/config.ru
|
129
132
|
- spec/dummy/config/application.rb
|
@@ -186,7 +189,10 @@ test_files:
|
|
186
189
|
- spec/dummy/app/helpers/application_helper.rb
|
187
190
|
- spec/dummy/app/mailers/.gitkeep
|
188
191
|
- spec/dummy/app/models/.gitkeep
|
189
|
-
- spec/dummy/app/views/dummy/
|
192
|
+
- spec/dummy/app/views/dummy/_no_main_content.html.erb
|
193
|
+
- spec/dummy/app/views/dummy/content_for.html.erb
|
194
|
+
- spec/dummy/app/views/dummy/content_for_with_default.html.erb
|
195
|
+
- spec/dummy/app/views/dummy/no_content.html.erb
|
190
196
|
- spec/dummy/app/views/layouts/application.html.erb
|
191
197
|
- spec/dummy/config.ru
|
192
198
|
- spec/dummy/config/application.rb
|