page_title_helper 10.0.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a2d2a86550563f06693c579a4d0fa876aa7a914292d6d335075a234d436f69d
4
- data.tar.gz: d4ef09751337d5a57635a9577654944494d2d5f3987d4abc6418ae162ec8545c
3
+ metadata.gz: 814c87d118a884882a8b973f8400381a1f49ffea958b4d54dce1e2b3833b714d
4
+ data.tar.gz: 7cdd22ada5241cd9479bcbffa3eb22bbe5d7a393be28eaec792c0acc433d3c1e
5
5
  SHA512:
6
- metadata.gz: 2d438f0e98ea5115f2ef0c661a95e4e2d8346428bff0d46f7db1470405f55895b2c108ffba587476a87aafa9800e92d3c35565b4ae22d0dcb7c5df8786027e63
7
- data.tar.gz: eabfd4cda52224608d36d2ba9ea68b545303f34a3dffc6a3b869d92f0e1487705f0be56437b1f0ded2f6b1f3a807d59abfffe054d3d5f7414cad2a2a7945d5f2
6
+ metadata.gz: 7139b11ec04058df050796a9f5c67655e526f2a060b75ca810387eea73d94fcd91b777b702ab6cf3c26390958bd89162ba95003d20658f88444c385cdc953e68
7
+ data.tar.gz: 8af793d5d6ebb7a1b0dc49058af8c42c24238abed90804bd97172f21589b03e96868ceeeaa92e7298345cc18f3ac7b28185fec4c0eef8910392c4b7025f85a0f
data/CHANGELOG.md CHANGED
@@ -20,6 +20,17 @@ about why a change log is important.
20
20
 
21
21
  ### Security
22
22
 
23
+ ## 11.0.0: Add support for Ruby 4.0, drop support for Rails 7.2 and Ruby 3.2
24
+
25
+ ### Added
26
+
27
+ - Add support for Ruby 4.0 (#240)
28
+
29
+ ### Removed
30
+
31
+ - Drop support for Rails 7.2 (#264)
32
+ - Drop support for Ruby 3.2 (#246)
33
+
23
34
  ## 10.0.0: Add support for Rails 8.1, drop support for Ruby 3.1 and Rails < 7.2
24
35
 
25
36
  ### Added
data/Gemfile CHANGED
@@ -3,3 +3,9 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
+
7
+ gem 'rake', '~> 13.4.2'
8
+ gem 'rubocop', '~> 1.92.0'
9
+ gem 'rubocop-rails', '~> 2.38.0'
10
+ gem 'rubocop-rake', '~> 0.7.1'
11
+ gem 'shoulda', '~> 4.0.0'
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Page title helper
2
2
 
3
- [![GitHub CI Status](https://github.com/lwe/page_title_helper/workflows/CI/badge.svg?branch=main)](https://github.com/lwe/page_title_helper/actions)
3
+ [![Build Status](https://github.com/lwe/page_title_helper/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/lwe/page_title_helper/actions/)
4
4
  [![Gem Version](https://badge.fury.io/rb/page_title_helper.svg)](https://badge.fury.io/rb/page_title_helper)
5
5
 
6
6
  This project adheres to [Semantic Versioning](https://semver.org/).
data/Rakefile CHANGED
@@ -16,3 +16,8 @@ Rake::TestTask.new(:test) do |t|
16
16
  t.pattern = 'test/**/*_test.rb'
17
17
  t.verbose = true
18
18
  end
19
+
20
+ desc 'Runs RuboCop for checking the Ruby files.'
21
+ task :rubocop do
22
+ sh 'rubocop gemfiles/ lib/ test/ page_title_helper.gemspec Gemfile Rakefile'
23
+ end
@@ -1,31 +1,36 @@
1
- $LOAD_PATH.push File.expand_path('lib', __dir__)
2
- require 'page_title_helper/version'
1
+ # frozen_string_literal: true
3
2
 
4
- Gem::Specification.new do |s|
5
- s.name = 'page_title_helper'
6
- s.version = PageTitleHelper::VERSION
7
- s.platform = Gem::Platform::RUBY
8
- s.summary = 'Simple, internationalized and DRY page titles and headings for Rails.'
9
- s.description = 'Simple, internationalized and DRY page titles and headings for Rails.'
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'page_title_helper'
5
+ spec.summary = 'Simple, internationalized and DRY page titles and headings for Railspec.'
6
+ spec.version = '11.0.0'
7
+ spec.license = 'MIT'
10
8
 
11
- s.required_ruby_version = '>= 3.2.0'
9
+ spec.required_ruby_version = '>= 3.3.0'
12
10
 
13
- s.authors = ['Lukas Westermann']
14
- s.email = ['lukas.westermann@gmail.com']
15
- s.homepage = 'https://github.com/lwe/page_title_helper'
11
+ spec.homepage = 'https://github.com/lwe/page_title_helper'
12
+ spec.authors = ['Lukas Westermann']
13
+ spec.email = ['lukaspec.westermann@gmail.com']
16
14
 
17
- s.files = %w[Gemfile LICENSE README.md CODE_OF_CONDUCT.md CHANGELOG.md Rakefile
18
- page_title_helper.gemspec] + Dir['**/*.{rb,yml}']
19
- s.test_files = s.files.grep(%r{^(test|spec)/})
20
- s.require_path = 'lib'
15
+ spec.metadata = {
16
+ 'bug_tracker_uri' => 'https://github.com/lwe/page_title_helper/issues',
17
+ 'changelog_uri' => 'https://github.com/lwe/page_title_helper/blob/master/CHANGELOG.md',
18
+ 'documentation_uri' => 'https://www.rubydoc.info/gems/page_title_helper',
19
+ 'homepage_uri' => spec.homepage,
20
+ 'source_code_uri' => 'https://github.com/lwe/page_title_helper'
21
+ }
21
22
 
22
- s.license = 'MIT'
23
+ spec.files = %w[
24
+ CHANGELOG.md
25
+ Gemfile
26
+ LICENSE
27
+ README.md
28
+ Rakefile
29
+ lib/page_title_helper.rb
30
+ page_title_helper.gemspec
31
+ ]
32
+ spec.extra_rdoc_files = %w[CHANGELOG.md LICENSE README.md]
33
+ spec.require_paths = ['lib']
23
34
 
24
- s.add_dependency 'rails', '>= 7.2.0', '< 8.2'
25
-
26
- s.add_development_dependency 'rake', '~> 13.3.0'
27
- s.add_development_dependency 'rubocop', '~> 1.81.1'
28
- s.add_development_dependency 'rubocop-rails', '~> 2.33.3'
29
- s.add_development_dependency 'rubocop-rake', '~> 0.7.1'
30
- s.add_development_dependency 'shoulda', '~> 4.0.0'
35
+ spec.add_dependency 'rails', '>= 8.0.0', '< 8.2'
31
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_title_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0
4
+ version: 11.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Westermann
@@ -15,7 +15,7 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 7.2.0
18
+ version: 8.0.0
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: '8.2'
@@ -25,105 +25,35 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: 7.2.0
28
+ version: 8.0.0
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
31
  version: '8.2'
32
- - !ruby/object:Gem::Dependency
33
- name: rake
34
- requirement: !ruby/object:Gem::Requirement
35
- requirements:
36
- - - "~>"
37
- - !ruby/object:Gem::Version
38
- version: 13.3.0
39
- type: :development
40
- prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- requirements:
43
- - - "~>"
44
- - !ruby/object:Gem::Version
45
- version: 13.3.0
46
- - !ruby/object:Gem::Dependency
47
- name: rubocop
48
- requirement: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - "~>"
51
- - !ruby/object:Gem::Version
52
- version: 1.81.1
53
- type: :development
54
- prerelease: false
55
- version_requirements: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: 1.81.1
60
- - !ruby/object:Gem::Dependency
61
- name: rubocop-rails
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - "~>"
65
- - !ruby/object:Gem::Version
66
- version: 2.33.3
67
- type: :development
68
- prerelease: false
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - "~>"
72
- - !ruby/object:Gem::Version
73
- version: 2.33.3
74
- - !ruby/object:Gem::Dependency
75
- name: rubocop-rake
76
- requirement: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - "~>"
79
- - !ruby/object:Gem::Version
80
- version: 0.7.1
81
- type: :development
82
- prerelease: false
83
- version_requirements: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - "~>"
86
- - !ruby/object:Gem::Version
87
- version: 0.7.1
88
- - !ruby/object:Gem::Dependency
89
- name: shoulda
90
- requirement: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - "~>"
93
- - !ruby/object:Gem::Version
94
- version: 4.0.0
95
- type: :development
96
- prerelease: false
97
- version_requirements: !ruby/object:Gem::Requirement
98
- requirements:
99
- - - "~>"
100
- - !ruby/object:Gem::Version
101
- version: 4.0.0
102
- description: Simple, internationalized and DRY page titles and headings for Rails.
103
32
  email:
104
- - lukas.westermann@gmail.com
33
+ - lukaspec.westermann@gmail.com
105
34
  executables: []
106
35
  extensions: []
107
- extra_rdoc_files: []
36
+ extra_rdoc_files:
37
+ - CHANGELOG.md
38
+ - LICENSE
39
+ - README.md
108
40
  files:
109
41
  - CHANGELOG.md
110
- - CODE_OF_CONDUCT.md
111
42
  - Gemfile
112
43
  - LICENSE
113
44
  - README.md
114
45
  - Rakefile
115
46
  - lib/page_title_helper.rb
116
- - lib/page_title_helper/version.rb
117
47
  - page_title_helper.gemspec
118
- - test/en.yml
119
- - test/en_wohaapp.yml
120
- - test/multiple_formats_test.rb
121
- - test/page_title_helper_test.rb
122
- - test/test_helper.rb
123
48
  homepage: https://github.com/lwe/page_title_helper
124
49
  licenses:
125
50
  - MIT
126
- metadata: {}
51
+ metadata:
52
+ bug_tracker_uri: https://github.com/lwe/page_title_helper/issues
53
+ changelog_uri: https://github.com/lwe/page_title_helper/blob/master/CHANGELOG.md
54
+ documentation_uri: https://www.rubydoc.info/gems/page_title_helper
55
+ homepage_uri: https://github.com/lwe/page_title_helper
56
+ source_code_uri: https://github.com/lwe/page_title_helper
127
57
  rdoc_options: []
128
58
  require_paths:
129
59
  - lib
@@ -131,19 +61,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
61
  requirements:
132
62
  - - ">="
133
63
  - !ruby/object:Gem::Version
134
- version: 3.2.0
64
+ version: 3.3.0
135
65
  required_rubygems_version: !ruby/object:Gem::Requirement
136
66
  requirements:
137
67
  - - ">="
138
68
  - !ruby/object:Gem::Version
139
69
  version: '0'
140
70
  requirements: []
141
- rubygems_version: 3.6.9
71
+ rubygems_version: 4.0.20
142
72
  specification_version: 4
143
- summary: Simple, internationalized and DRY page titles and headings for Rails.
144
- test_files:
145
- - test/en.yml
146
- - test/en_wohaapp.yml
147
- - test/multiple_formats_test.rb
148
- - test/page_title_helper_test.rb
149
- - test/test_helper.rb
73
+ summary: Simple, internationalized and DRY page titles and headings for Railspec.
74
+ test_files: []
data/CODE_OF_CONDUCT.md DELETED
@@ -1,77 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age,
8
- body size, disability, ethnicity, gender identity and expression, level of
9
- experience, nationality, personal appearance, race, religion, or sexual
10
- identity and orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
-
35
- ## Our Responsibilities
36
-
37
- Project maintainers are responsible for clarifying the standards of acceptable
38
- behavior and are expected to take appropriate and fair corrective action in
39
- response to any instances of unacceptable behavior.
40
-
41
- Project maintainers have the right and responsibility to remove, edit, or
42
- reject comments, commits, code, wiki edits, issues, and other contributions
43
- that are not aligned to this Code of Conduct, or to ban temporarily or
44
- permanently any contributor for other behaviors that they deem inappropriate,
45
- threatening, offensive, or harmful.
46
-
47
- ## Scope
48
-
49
- This Code of Conduct applies both within project spaces and in public spaces
50
- when an individual is representing the project or its community. Examples of
51
- representing a project or community include using an official project e-mail
52
- address, posting via an official social media account, or acting as an
53
- appointed representative at an online or offline event. Representation of a
54
- project may be further defined and clarified by project maintainers.
55
-
56
- ## Enforcement
57
-
58
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
59
- reported by contacting the project team at (lukas dot westermann at gmail dot com).
60
- All complaints will be reviewed and investigated and will result in a response
61
- that is deemed necessary and appropriate to the circumstances. The project team
62
- is obligated to maintain confidentiality with regard to the reporter of an
63
- incident. Further details of specific enforcement policies may be posted
64
- separately.
65
-
66
- Project maintainers who do not follow or enforce the Code of Conduct in good
67
- faith may face temporary or permanent repercussions as determined by other
68
- members of the project's leadership.
69
-
70
- ## Attribution
71
-
72
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
73
- version 1.4, available at
74
- [https://contributor-covenant.org/version/1/4/][version].
75
-
76
- [homepage]: https://contributor-covenant.org
77
- [version]: https://contributor-covenant.org/version/1/4/
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PageTitleHelper
4
- VERSION = '10.0.0'
5
- end
data/test/en.yml DELETED
@@ -1,21 +0,0 @@
1
- en:
2
- contacts:
3
- list:
4
- title: contacts.list.title
5
- page_title: custom contacts title
6
- myhaml:
7
- title: this is haml!
8
- admin:
9
- account:
10
- title: Account administration
11
- show:
12
- title: Account
13
- new:
14
- title: New account
15
- edit:
16
- title: Edit account
17
-
18
- placeholder: "Displaying %{name}"
19
- app:
20
- tagline: Default
21
- other_tagline: Other default
data/test/en_wohaapp.yml DELETED
@@ -1,12 +0,0 @@
1
- en:
2
- app:
3
- name: Wohaapp
4
- pages:
5
- features:
6
- title:
7
- - "Feature comparison"
8
- - !ruby/sym promo
9
- signup:
10
- title:
11
- - "Sign up"
12
- - ":title for :app now!"
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'minitest/autorun'
4
- require 'test_helper'
5
-
6
- class MultipleFormatsTest < ActiveSupport::TestCase
7
- context '#page_title supporting multiple formats through arrays' do
8
- setup do
9
- @view = TestView.new('contacts', 'list')
10
- end
11
-
12
- should 'accept an array passed in the page_title block and use the second argument as format' do
13
- @view.page_title { ['Oh my...!', ':title // :app'] }
14
- assert_equal 'Oh my...! // Page title helper', @view.page_title
15
- end
16
-
17
- should 'still return title as string and not the array' do
18
- assert_equal('Oh my...!', @view.page_title { ['Oh my...!', ':title // :app'] })
19
- end
20
- end
21
-
22
- context '#page_title with format aliases' do
23
- setup do
24
- PageTitleHelper.formats[:myformat] = ':title <-> :app'
25
- @view = TestView.new('contacts', 'list')
26
- end
27
-
28
- should 'have a default alias named :app' do
29
- assert_equal 'Page title helper', @view.page_title(format: :app)
30
- end
31
-
32
- should 'allow custom aliases to be defined and used' do
33
- @view.page_title { 'Test' }
34
- assert_equal 'Test <-> Page title helper', @view.page_title(format: :myformat)
35
- end
36
-
37
- should 'fallback to default format, if array is not big enough (i.e. only contains single element...)' do
38
- assert_equal('Test', @view.page_title { ['Test'] })
39
- assert_equal 'Test - Page title helper', @view.page_title
40
- end
41
-
42
- context 'used with the array block' do
43
- should 'also allow aliases returned in that array thingy' do
44
- assert_equal('Test', @view.page_title { ['Test', :myformat] })
45
- assert_equal 'Test <-> Page title helper', @view.page_title
46
- end
47
-
48
- should 'override locally supplied :format arguments' do
49
- assert_equal('Something', @view.page_title { ['Something', '* * * :title * * *'] })
50
- # yeah, using x-tra ugly titles :)
51
- assert_equal '* * * Something * * *', @view.page_title(format: '-= :title =-')
52
- end
53
- end
54
- end
55
-
56
- context '#page_title, aliases and YAML' do
57
- setup do
58
- I18n.load_path = [File.join(File.dirname(__FILE__), 'en_wohaapp.yml')]
59
- I18n.reload!
60
- PageTitleHelper.formats[:promo] = ':app > :title'
61
- @view = TestView.new
62
- end
63
-
64
- should 'allow to override format through YAML' do
65
- @view.controller! 'pages', 'features'
66
- assert_equal 'Wohaapp > Feature comparison', @view.page_title
67
- end
68
-
69
- should 'handle raw string formats from YAML as well' do
70
- @view.controller! 'pages', 'signup'
71
- assert_equal 'Sign up for Wohaapp now!', @view.page_title
72
- end
73
- end
74
- end
@@ -1,137 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'minitest/autorun'
4
- require 'test_helper'
5
-
6
- class PageTitleHelperTest < ActiveSupport::TestCase
7
- context 'PageTitleHelper' do
8
- setup do
9
- I18n.load_path = [File.join(File.dirname(__FILE__), 'en.yml')]
10
- I18n.reload!
11
-
12
- @view = TestView.new('contacts', 'list')
13
- end
14
-
15
- context '::Interpolations' do
16
- should 'interpolate :app and :title' do
17
- assert_equal 'Page title helper', PageTitleHelper::Interpolations.app({})
18
- assert_equal 'Appname', PageTitleHelper::Interpolations.app(app: 'Appname')
19
- assert_equal 'untitled', PageTitleHelper::Interpolations.title(title: 'untitled')
20
- end
21
-
22
- should 'allow adding custom interpolations' do
23
- # extend Interpolations
24
- PageTitleHelper.interpolates(:app_reverse) { |env| app(env).reverse.downcase }
25
-
26
- assert_equal 'anna', PageTitleHelper::Interpolations.app_reverse(app: 'Anna')
27
- assert_equal 'ppa', PageTitleHelper::Interpolations.interpolate(':app_reverse', app: 'app')
28
- end
29
-
30
- should 'interpolate in correct order, i.e. longest first' do
31
- PageTitleHelper.interpolates(:foobar) { |_env| 'foobar' }
32
- PageTitleHelper.interpolates(:foobar_test) { |_env| 'foobar_test' }
33
- PageTitleHelper.interpolates(:title_foobar) { |_env| 'title_foobar' }
34
-
35
- assert_equal 'title_foobar / foobar_test / foobar / foobar_x',
36
- PageTitleHelper::Interpolations.interpolate(':title_foobar / :foobar_test / :foobar / :foobar_x',
37
- {})
38
- end
39
- end
40
-
41
- context '#page_title (define w/ block)' do
42
- should 'return title from block and render with app name' do
43
- assert_equal('foo', @view.page_title { 'foo' })
44
- assert_equal 'foo - Page title helper', @view.page_title
45
- end
46
-
47
- should 'set custom title using a translation with a placeholder' do
48
- assert_equal('Displaying Bella', @view.page_title { I18n.t(:placeholder, name: 'Bella') })
49
- assert_equal 'Displaying Bella - Page title helper', @view.page_title
50
- end
51
- end
52
-
53
- context '#page_title! (define)' do
54
- should 'set page title' do
55
- assert_equal 'test', @view.page_title!('test')
56
- assert_equal 'test - Page title helper', @view.page_title
57
- end
58
-
59
- should 'set page title and interpret second argument as custom format' do
60
- PageTitleHelper.formats[:bang] = ':title !! :app'
61
- assert_equal 'test', @view.page_title!('test', :bang)
62
- assert_equal 'test !! Page title helper', @view.page_title
63
- end
64
- end
65
-
66
- context '#page_title (rendering)' do
67
- should 'read default title from I18n, based on controller/action' do
68
- assert_equal 'contacts.list.title - Page title helper', @view.page_title
69
- end
70
-
71
- should 'only print app name if format: :app' do
72
- assert_equal 'Page title helper', @view.page_title(format: :app)
73
- end
74
-
75
- should 'print custom app name if :app defined and format: :app' do
76
- assert_equal 'Some app', @view.page_title(app: 'Some app', format: :app)
77
- end
78
-
79
- should 'use custom format, if :format option is defined' do
80
- assert_equal('test', @view.page_title { 'test' })
81
- assert_equal 'Some app :: test', @view.page_title(app: 'Some app', format: ':app :: :title')
82
- assert_equal 'Some app / test', @view.page_title(format: 'Some app / :title')
83
- end
84
-
85
- should 'return just title if format: false is passed' do
86
- assert_equal('untitled', @view.page_title { 'untitled' })
87
- assert_equal 'untitled', @view.page_title(format: false)
88
- end
89
-
90
- should 'return title if format: false and when using the DRY-I18n titles' do
91
- assert_equal 'contacts.list.title', @view.page_title(format: false)
92
- end
93
-
94
- should 'render translated :"app.tagline" if no title is available' do
95
- @view.controller! 'view/does', 'not_exist'
96
- assert_equal 'Default - Page title helper', @view.page_title
97
- end
98
-
99
- should 'render use controller.title as first fallback, if no title exists' do
100
- @view.controller! 'admin/account', 'index'
101
- assert_equal 'Account administration - Page title helper', @view.page_title(default: 'Other default')
102
- end
103
-
104
- should 'not fallback to controller.title if controller.action.title exists' do
105
- @view.controller! 'admin/account', 'show'
106
- assert_equal 'Account - Page title helper', @view.page_title(default: 'Other default')
107
- end
108
-
109
- should 'fallback to controller.new.title if create has no title' do
110
- @view.controller! 'admin/account', 'create'
111
- assert_equal 'New account - Page title helper', @view.page_title(default: 'Other default')
112
- end
113
-
114
- should 'fallback to controller.edit.title if update has no title' do
115
- @view.controller! 'admin/account', 'update'
116
- assert_equal 'Edit account - Page title helper', @view.page_title(default: 'Other default')
117
- end
118
-
119
- should 'render custom "default" string, if title is not available nor controller.title' do
120
- @view.controller! 'view/does', 'not_exist'
121
- assert_equal 'Some default - Page title helper', @view.page_title(default: 'Some default')
122
- end
123
-
124
- should 'render custom default translation, if title is not available nor controller.title' do
125
- @view.controller! 'view/does', 'not_exist'
126
- assert_equal 'Other default - Page title helper', @view.page_title(default: :'app.other_tagline')
127
- end
128
- end
129
-
130
- context 'README.md' do
131
- should 'interpolate :controller' do
132
- PageTitleHelper.interpolates(:controller) { |env| env[:view].controller.controller_name.humanize }
133
- assert_equal 'contacts.list.title - Test', @view.page_title(format: ':title - :controller')
134
- end
135
- end
136
- end
137
- end
data/test/test_helper.rb DELETED
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This line can be dropped once we no longer support Rails 7.0.
4
- require 'logger'
5
- # This line can be dropped once we no longer support Rails 7.1 and 7.2.
6
- require 'uri'
7
- require 'active_support'
8
- require 'action_view'
9
- require 'page_title_helper'
10
-
11
- unless defined?(IRB)
12
- require 'active_support/test_case'
13
- require 'shoulda'
14
- end
15
-
16
- # Use sorted tests. We need to change that after the tests have been converted
17
- # to RSpec.
18
- ActiveSupport.test_order = :sorted
19
-
20
- # fake global Rails module
21
- module Rails
22
- class << self
23
- def root
24
- @root ||= Pathname.new('/this/is/just/for/testing/page_title_helper')
25
- end
26
-
27
- def env
28
- 'test'
29
- end
30
- end
31
- end
32
-
33
- # Mock ActionView a bit to allow easy (fake) template assignment
34
- class TestView < ActionView::Base
35
- attr_reader :controller
36
-
37
- def initialize(controller_path = nil, action = nil)
38
- @controller = ActionView::TestCase::TestController.new
39
- @controller.controller_path = controller_path
40
- params[:action] = action if action
41
- end
42
-
43
- def controller!(controller_path, action)
44
- @controller.controller_path = controller_path
45
- params[:action] = action
46
- end
47
- end