tytus 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,4 +1,2 @@
1
- script: 'rake'
2
1
  rvm:
3
- - 1.8.7
4
2
  - 1.9.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ 0.1.0 (December 31, 2011)
2
+
3
+ * change code to display tiles inside headers
4
+ * added specs for driving titles through dummy rails app
5
+ * setup rails integration tests
6
+ * include capybara support
7
+ * update gemspec and spec helper to include rspec rails matchers
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Helps you manage page titles in your Rails application.
8
8
 
9
- In order to improve overall design of your app and increase findability of your pages in search ranks, Tytus gives you a declarative manner in which to title your pages.
9
+ Tytus gives you a declarative manner in which to title your pages in order to improve overall design of your app and to increase findability of your pages in search ranks.
10
10
 
11
11
  ## Installation
12
12
 
@@ -19,14 +19,14 @@ gem 'tytus'
19
19
  To configure your Rails 2.x application, in `config/environment.rb` add
20
20
 
21
21
  ```ruby
22
- config.get 'tytus'
22
+ config.gem 'tytus'
23
23
  ```
24
24
 
25
25
  ## Usage
26
26
 
27
27
  Update your locales file as in the following:
28
28
 
29
- ```ruby
29
+ ```
30
30
  en:
31
31
  titles:
32
32
  site_name: Your site name goes here
@@ -67,6 +67,10 @@ In your views:
67
67
 
68
68
  ```ruby
69
69
  <%- title 'A title for this particular view' %>
70
+
71
+ or
72
+
73
+ <h1><%= title 'A title for this particular view that renders also inside enclosed tag' %></h1>
70
74
  ```
71
75
 
72
76
  and this will overwrite controller set titles.
data/lib/tytus/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Tytus
4
- VERSION = "0.0.2"
4
+ VERSION = "0.1.0"
5
5
  end # Tytus
@@ -18,7 +18,7 @@ module Tytus
18
18
  options = args.extract_options!
19
19
  separator = options[:separator] || " :: "
20
20
  if _page_title.present?
21
- "#{[_page_title].flatten.join(separator)} #{separator} #{site_name}"
21
+ "#{[_page_title].flatten.join(separator)} #{separator.strip} #{site_name}"
22
22
  else
23
23
  site_name
24
24
  end
@@ -39,8 +39,9 @@ module Tytus
39
39
  def title(*args)
40
40
  options = args.extract_options!
41
41
  unless args.empty?
42
- @controller.class._page_title = args
42
+ @controller.class._page_title = args.join(' ')
43
43
  end
44
+ @controller.class._page_title
44
45
  end
45
46
 
46
47
  private
@@ -2,9 +2,18 @@ class ArticlesController < ApplicationController
2
2
 
3
3
  title 'All Articles'
4
4
 
5
- def index; end
5
+ def index
6
+ end
6
7
 
7
8
  def show
9
+ title 'Particular Article'
10
+ end
11
+
12
+ def new
13
+ title 'New Article'
14
+ end
15
+
16
+ def edit
8
17
  end
9
18
 
10
19
  end
@@ -0,0 +1,8 @@
1
+ class HomeController < ApplicationController
2
+
3
+ title 'Home', :only => :new
4
+
5
+ def index; end
6
+
7
+ def new; end
8
+ end
@@ -0,0 +1 @@
1
+ <% title 'Edit', 'nice', 'title' %>
@@ -1,2 +1 @@
1
1
  <h1>Articles index view</h1>
2
- <% title 'index', 'view', 'title' %>
@@ -0,0 +1 @@
1
+ <h1><%= title 'Newer Title' %></h1>
@@ -0,0 +1 @@
1
+ <h1>Home Template</h1>
@@ -0,0 +1 @@
1
+ <h1>New Home</h1>
@@ -1,4 +1,5 @@
1
1
  RailsApp::Application.routes.draw do
2
- root :to => 'articles#index'
2
+ root :to => 'home#index'
3
+ match 'home/new', :to => 'home#new', :as => 'new_home'
3
4
  resources :articles
4
5
  end
@@ -1,19 +1,61 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
- require 'tytus/railtie'
5
-
6
- Tytus::Railtie.insert_view
7
- Tytus::Railtie.insert_controller
8
4
 
9
5
  describe "Rails integration", Tytus do
10
-
11
6
  include Integration
12
7
 
13
8
  let(:controller) { Class.new(ActionController::Base)}
9
+ let(:site_title) { 'My Site Name' }
10
+ let(:article) { 1 }
11
+
12
+ context 'rendering tiles with only locales set' do
13
+
14
+ it 'should display only site title' do
15
+ visit root_path
16
+ page.should have_css('title', :text => site_title)
17
+ end
18
+
19
+ end
20
+
21
+ context 'rendering titles through controller stack' do
22
+
23
+ it 'should be able to set title for controller' do
24
+ visit articles_path
25
+ page.should have_css('title', :text => 'All Articles :: ' + site_title)
26
+ end
27
+
28
+ it 'should be able to set title on controller level for specific actions' do
29
+ visit new_home_path
30
+ page.should have_css('title', :text => 'Home :: ' + site_title)
31
+ end
32
+
33
+ it 'should be able to override title for particular action' do
34
+ visit article_path(article)
35
+ page.should have_css('title', :text => 'Particular Article :: ' + site_title)
36
+ end
14
37
 
15
- it 'should be able to set title for controller' do
16
- pending
17
- # visit root_path
18
38
  end
19
- end
39
+
40
+ context "rendering titles in view" do
41
+
42
+ it "should be able to overide controller titles" do
43
+ visit new_article_path
44
+ page.should have_css('title', :text => 'Newer Title :: ' + site_title)
45
+ end
46
+
47
+ it "should render title back to the view" do
48
+ visit new_article_path
49
+ page.should have_css('h1', :text => 'Newer Title')
50
+ end
51
+
52
+ end
53
+
54
+ context "setting title with an array" do
55
+ it "should accept separated strings" do
56
+ visit edit_article_path(article)
57
+ page.should have_css('title', :text => 'Edit nice title :: ' + site_title)
58
+ end
59
+ end
60
+
61
+ end # Rails integration
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,7 @@ require 'tytus'
4
4
  ENV["RAILS_ENV"] = "test"
5
5
 
6
6
  require File.expand_path("../rails_app/config/environment.rb", __FILE__)
7
- require "rails/test_help"
7
+ require "rspec/rails"
8
8
 
9
9
  require 'action_controller'
10
10
  require 'action_view'
@@ -0,0 +1,6 @@
1
+ require 'capybara/rails'
2
+ require 'capybara/dsl'
3
+
4
+ RSpec.configure do |config|
5
+ config.include Capybara::DSL, :example_group => { :file_path => /\bspec\// }
6
+ end
@@ -0,0 +1,7 @@
1
+ ApplicationController.subclasses.each do |controller_class|
2
+ controller_class.class_eval <<-STRING
3
+ def view_assigns
4
+ { :controller => #{controller_class}.new }
5
+ end
6
+ STRING
7
+ end
data/spec/tytus_spec.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Tytus do
6
+ include Integration
6
7
 
7
8
  let(:controller) { Class.new(ActionController::Base) }
8
9
  let(:controller_instance) { controller.new }
@@ -23,6 +24,10 @@ describe Tytus do
23
24
  it "shoulbe be available to ActionController instance methods" do
24
25
  controller_instance.should respond_to :title
25
26
  end
27
+
28
+ it "should be able to set title" do
29
+ controller.title 'My Title'
30
+ end
26
31
  end
27
32
 
28
33
  end # ControllerExtensions
@@ -67,14 +72,6 @@ describe Tytus do
67
72
  it 'should be available to view' do
68
73
  view_instance.should respond_to :title
69
74
  end
70
-
71
- it "should " do
72
- pending
73
- # controller_instance.stub(:class).and_return controller
74
- # controller.stub(:name).and_return 'ArticlesController'
75
- # view_instance.title 'some', 'view'
76
- # controller._page_title.should eq 'some :: view'
77
- end
78
75
  end
79
76
  end # ViewExtensions
80
77
 
data/tytus.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = [""]
10
10
  s.homepage = "https://github.com/peter-murach/tytus"
11
11
  s.summary = %q{Helps you manage page titles in your Rails application.}
12
- s.description = %q{In order to improve overall design of your app and increase findability of your pages in search ranks, Tytus gives you a declarative manner in which to title your pages.}
12
+ s.description = %q{Tytus gives you a declarative manner in which to title your pages in order to improve overall design of your app and increase findability of your pages in search ranks.}
13
13
 
14
14
  s.rubyforge_project = "tytus"
15
15
 
@@ -22,6 +22,6 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_development_dependency "rails"
24
24
  s.add_development_dependency "sqlite3"
25
- s.add_development_dependency "rspec"
25
+ s.add_development_dependency "rspec-rails"
26
26
  s.add_development_dependency "capybara"
27
27
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: tytus
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Piotr Murach
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-12-26 00:00:00 +00:00
13
+ date: 2011-12-31 00:00:00 +00:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -47,7 +47,7 @@ dependencies:
47
47
  type: :development
48
48
  version_requirements: *id003
49
49
  - !ruby/object:Gem::Dependency
50
- name: rspec
50
+ name: rspec-rails
51
51
  prerelease: false
52
52
  requirement: &id004 !ruby/object:Gem::Requirement
53
53
  none: false
@@ -68,7 +68,7 @@ dependencies:
68
68
  version: "0"
69
69
  type: :development
70
70
  version_requirements: *id005
71
- description: In order to improve overall design of your app and increase findability of your pages in search ranks, Tytus gives you a declarative manner in which to title your pages.
71
+ description: Tytus gives you a declarative manner in which to title your pages in order to improve overall design of your app and increase findability of your pages in search ranks.
72
72
  email:
73
73
  - ""
74
74
  executables: []
@@ -82,6 +82,7 @@ files:
82
82
  - .rspec
83
83
  - .rvmrc
84
84
  - .travis.yml
85
+ - CHANGELOG.md
85
86
  - Gemfile
86
87
  - LICENSE
87
88
  - README.md
@@ -98,11 +99,16 @@ files:
98
99
  - spec/rails_app/app/assets/stylesheets/application.css
99
100
  - spec/rails_app/app/controllers/application_controller.rb
100
101
  - spec/rails_app/app/controllers/articles_controller.rb
102
+ - spec/rails_app/app/controllers/home_controller.rb
101
103
  - spec/rails_app/app/helpers/application_helper.rb
102
104
  - spec/rails_app/app/mailers/.gitkeep
103
105
  - spec/rails_app/app/models/.gitkeep
106
+ - spec/rails_app/app/views/articles/edit.html.erb
104
107
  - spec/rails_app/app/views/articles/index.html.erb
108
+ - spec/rails_app/app/views/articles/new.html.erb
105
109
  - spec/rails_app/app/views/articles/show.html.erb
110
+ - spec/rails_app/app/views/home/index.html.erb
111
+ - spec/rails_app/app/views/home/new.html.erb
106
112
  - spec/rails_app/app/views/layouts/application.html.erb
107
113
  - spec/rails_app/config.ru
108
114
  - spec/rails_app/config/application.rb
@@ -129,6 +135,8 @@ files:
129
135
  - spec/rails_app/script/rails
130
136
  - spec/rails_integration_spec.rb
131
137
  - spec/spec_helper.rb
138
+ - spec/support/capybara.rb
139
+ - spec/support/fake_controller.rb
132
140
  - spec/support/integration.rb
133
141
  - spec/tytus_spec.rb
134
142
  - tytus.gemspec
@@ -167,11 +175,16 @@ test_files:
167
175
  - spec/rails_app/app/assets/stylesheets/application.css
168
176
  - spec/rails_app/app/controllers/application_controller.rb
169
177
  - spec/rails_app/app/controllers/articles_controller.rb
178
+ - spec/rails_app/app/controllers/home_controller.rb
170
179
  - spec/rails_app/app/helpers/application_helper.rb
171
180
  - spec/rails_app/app/mailers/.gitkeep
172
181
  - spec/rails_app/app/models/.gitkeep
182
+ - spec/rails_app/app/views/articles/edit.html.erb
173
183
  - spec/rails_app/app/views/articles/index.html.erb
184
+ - spec/rails_app/app/views/articles/new.html.erb
174
185
  - spec/rails_app/app/views/articles/show.html.erb
186
+ - spec/rails_app/app/views/home/index.html.erb
187
+ - spec/rails_app/app/views/home/new.html.erb
175
188
  - spec/rails_app/app/views/layouts/application.html.erb
176
189
  - spec/rails_app/config.ru
177
190
  - spec/rails_app/config/application.rb
@@ -198,5 +211,7 @@ test_files:
198
211
  - spec/rails_app/script/rails
199
212
  - spec/rails_integration_spec.rb
200
213
  - spec/spec_helper.rb
214
+ - spec/support/capybara.rb
215
+ - spec/support/fake_controller.rb
201
216
  - spec/support/integration.rb
202
217
  - spec/tytus_spec.rb