h2ocube_rails_helper 0.0.16 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -2
  3. data/Gemfile +0 -3
  4. data/README.md +0 -1
  5. data/Rakefile +7 -7
  6. data/h2ocube_rails_helper.gemspec +9 -1
  7. data/h2ocube_rails_helper.sublime-project +15 -0
  8. data/lib/h2ocube_rails_helper.rb +93 -89
  9. data/spec/fake_app/models.rb +14 -0
  10. data/spec/fake_app/rails_app.rb +33 -0
  11. data/spec/helpers/render_canonical_spec.rb +16 -0
  12. data/spec/helpers/render_description_spec.rb +37 -0
  13. data/spec/helpers/render_ga_spec.rb +38 -0
  14. data/{test/render_html_class_test.rb → spec/helpers/render_html_class_spec.rb} +44 -45
  15. data/spec/helpers/render_keywords_spec.rb +39 -0
  16. data/spec/helpers/render_title_spec.rb +56 -0
  17. data/spec/spec_helper.rb +24 -0
  18. metadata +120 -57
  19. data/test/dummy/Rakefile +0 -7
  20. data/test/dummy/app/controllers/application_controller.rb +0 -3
  21. data/test/dummy/app/helpers/application_helper.rb +0 -2
  22. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  23. data/test/dummy/config.ru +0 -4
  24. data/test/dummy/config/application.rb +0 -20
  25. data/test/dummy/config/boot.rb +0 -10
  26. data/test/dummy/config/database.yml +0 -22
  27. data/test/dummy/config/environment.rb +0 -5
  28. data/test/dummy/config/environments/development.rb +0 -23
  29. data/test/dummy/config/environments/production.rb +0 -49
  30. data/test/dummy/config/environments/test.rb +0 -24
  31. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  32. data/test/dummy/config/initializers/inflections.rb +0 -10
  33. data/test/dummy/config/initializers/mime_types.rb +0 -5
  34. data/test/dummy/config/initializers/secret_token.rb +0 -7
  35. data/test/dummy/config/initializers/session_store.rb +0 -8
  36. data/test/dummy/config/locales/en.yml +0 -5
  37. data/test/dummy/config/routes.rb +0 -58
  38. data/test/dummy/script/rails +0 -6
  39. data/test/render_canonical_test.rb +0 -16
  40. data/test/render_description_test.rb +0 -37
  41. data/test/render_ga_test.rb +0 -37
  42. data/test/render_keywords_test.rb +0 -41
  43. data/test/render_title_test.rb +0 -56
  44. data/test/test_helper.rb +0 -7
@@ -1,43 +1,65 @@
1
- require 'test_helper'
1
+ require 'spec_helper'
2
2
 
3
- class RenderHtmlClass < ActionView::TestCase
4
- test 'simple params' do
3
+ describe 'render_html_class' do
4
+ def params
5
+ @params || {}
6
+ end
7
+
8
+ def params= data
9
+ @params = data
10
+ end
11
+
12
+ class Request
13
+ def env
14
+ @env || {}
15
+ end
16
+
17
+ def env= data
18
+ @env = data
19
+ end
20
+ end
21
+
22
+ def request
23
+ @request ||= Request.new
24
+ end
25
+
26
+ it 'simple params' do
5
27
  self.params = {
6
28
  controller: 'controller',
7
29
  action: 'action'
8
30
  }
9
31
  cls = render_html_class.split ' '
10
- assert cls.include?('controller')
11
- assert cls.include?('action')
12
- assert cls.include?('controller_action')
32
+ cls.should include('controller')
33
+ cls.should include('action')
34
+ cls.should include('controller_action')
13
35
  end
14
36
 
15
- test 'module controller' do
37
+ it 'module controller' do
16
38
  self.params = {
17
39
  controller: 'module/controller',
18
40
  action: 'action'
19
41
  }
20
42
  cls = render_html_class.split ' '
21
- assert cls.include?('module_controller')
22
- assert cls.include?('controller')
23
- assert cls.include?('action')
24
- assert cls.include?('module_controller_action')
43
+ cls.should include('module_controller')
44
+ cls.should include('controller')
45
+ cls.should include('action')
46
+ cls.should include('module_controller_action')
25
47
  end
26
48
 
27
- test 'addition html class' do
49
+ it 'addition html class' do
28
50
  self.params = {
29
51
  controller: 'controller',
30
52
  action: 'action',
31
53
  html_class: 'addition'
32
54
  }
33
55
  cls = render_html_class.split ' '
34
- assert cls.include?('controller')
35
- assert cls.include?('action')
36
- assert cls.include?('controller_action')
37
- assert cls.include?('addition')
56
+ cls.should include('controller')
57
+ cls.should include('action')
58
+ cls.should include('controller_action')
59
+ cls.should include('addition')
38
60
  end
39
61
 
40
- test 'mobile' do
62
+ it 'mobile' do
41
63
  self.params = {
42
64
  controller: 'controller',
43
65
  action: 'action'
@@ -45,33 +67,10 @@ class RenderHtmlClass < ActionView::TestCase
45
67
  self.request.user_agent = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/1A542a Safari/419.3'
46
68
  cls = render_html_class.split ' '
47
69
 
48
- assert cls.include?('controller')
49
- assert cls.include?('action')
50
- assert cls.include?('controller_action')
51
- assert cls.include?('mobile')
52
- assert cls.include?('iphone')
70
+ cls.should include('controller')
71
+ cls.should include('action')
72
+ cls.should include('controller_action')
73
+ cls.should include('mobile')
74
+ cls.should include('iphone')
53
75
  end
54
-
55
- def params
56
- @params || {}
57
- end
58
-
59
- def params= data
60
- @params = data
61
- end
62
-
63
- class Request
64
- def env
65
- @env || {}
66
- end
67
-
68
- def env= data
69
- @env = data
70
- end
71
- end
72
-
73
- def request
74
- @request ||= Request.new
75
- end
76
-
77
76
  end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ class HelperSettings
4
+ def self.keywords
5
+ 'keywords'
6
+ end
7
+ end
8
+
9
+ class Item
10
+ def keywords
11
+ 'item,item_keywords'
12
+ end
13
+ end
14
+
15
+ describe 'render_keywords' do
16
+ it 'simple' do
17
+ render_keywords.should == '<meta name="keywords" content="keywords" />'
18
+ end
19
+
20
+ it '@keywords' do
21
+ @keywords = '@keywords'
22
+ render_keywords.should == '<meta name="keywords" content="@keywords" />'
23
+ @keywords = ['@keywords', ' ', '', nil]
24
+ render_keywords.should == '<meta name="keywords" content="@keywords" />'
25
+ [' ', '', nil].each do |key|
26
+ @keywords = key
27
+ render_keywords.should == ''
28
+ end
29
+ end
30
+
31
+ it '@item' do
32
+ @item = Item.new
33
+ render_keywords.should == '<meta name="keywords" content="item,item_keywords" />'
34
+ end
35
+
36
+ it 'opts' do
37
+ render_keywords(keywords: 'opts,a,b,c').should == '<meta name="keywords" content="opts,a,b,c" />'
38
+ end
39
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ include H2ocubeRailsHelper::ActionViewExtension
4
+
5
+ class HelperSettings
6
+ def self.title
7
+ 'title'
8
+ end
9
+ end
10
+
11
+ class ResourceModelName
12
+ def human
13
+ 'Class Name'
14
+ end
15
+ end
16
+
17
+ class Resource
18
+ def title
19
+ 'Resource Name'
20
+ end
21
+
22
+ def self.model_name
23
+ ResourceModelName.new
24
+ end
25
+ end
26
+
27
+ describe 'render_title' do
28
+ it 'simple' do
29
+ render_title.should == '<title>title</title>'
30
+ end
31
+
32
+ it '@title' do
33
+ @title = '@title'
34
+ render_title.should == '<title>@title - title</title>'
35
+ @title = ['@title', ' ', '', nil]
36
+ render_title.should == '<title>@title - title</title>'
37
+ end
38
+
39
+ it 'resource' do
40
+ self.class_eval do
41
+ def resource
42
+ Resource.new
43
+ end
44
+ end
45
+ render_title.should == '<title>Resource Name - Class Name - title</title>'
46
+ end
47
+
48
+ it '@_title' do
49
+ @_title = '@_title'
50
+ render_title.should == '<title>@_title</title>'
51
+ end
52
+
53
+ it 'opts' do
54
+ render_title(title: 'opts').should == '<title>opts</title>'
55
+ end
56
+ end
@@ -0,0 +1,24 @@
1
+ ENV['RAILS_ENV'] = "test"
2
+
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+
6
+ begin
7
+ require 'rails'
8
+ rescue LoadError
9
+ end
10
+
11
+ require 'bundler/setup'
12
+ Bundler.require
13
+
14
+ require 'capybara/rspec'
15
+ require 'fake_app/rails_app'
16
+ require 'rspec/rails'
17
+
18
+
19
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
20
+
21
+ RSpec.configure do |config|
22
+ config.mock_with :rr
23
+ config.filter_run_excluding :generator_spec => true if !ENV['GENERATOR_SPEC']
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h2ocube_rails_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-21 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: settingslogic
@@ -38,6 +38,104 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tzinfo
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: capybara
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "<"
116
+ - !ruby/object:Gem::Version
117
+ version: 4.0.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "<"
123
+ - !ruby/object:Gem::Version
124
+ version: 4.0.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: sqlite3
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
41
139
  description: Just an helper collection
42
140
  email:
43
141
  - ben@h2ocube.com
@@ -52,37 +150,20 @@ files:
52
150
  - README.md
53
151
  - Rakefile
54
152
  - h2ocube_rails_helper.gemspec
153
+ - h2ocube_rails_helper.sublime-project
55
154
  - lib/generators/h2ocube_rails_helper_generator.rb
56
155
  - lib/generators/source/helper.yml.erb
57
156
  - lib/generators/source/helper_settings.rb.erb
58
157
  - lib/h2ocube_rails_helper.rb
59
- - test/dummy/Rakefile
60
- - test/dummy/app/controllers/application_controller.rb
61
- - test/dummy/app/helpers/application_helper.rb
62
- - test/dummy/app/views/layouts/application.html.erb
63
- - test/dummy/config.ru
64
- - test/dummy/config/application.rb
65
- - test/dummy/config/boot.rb
66
- - test/dummy/config/database.yml
67
- - test/dummy/config/environment.rb
68
- - test/dummy/config/environments/development.rb
69
- - test/dummy/config/environments/production.rb
70
- - test/dummy/config/environments/test.rb
71
- - test/dummy/config/initializers/backtrace_silencers.rb
72
- - test/dummy/config/initializers/inflections.rb
73
- - test/dummy/config/initializers/mime_types.rb
74
- - test/dummy/config/initializers/secret_token.rb
75
- - test/dummy/config/initializers/session_store.rb
76
- - test/dummy/config/locales/en.yml
77
- - test/dummy/config/routes.rb
78
- - test/dummy/script/rails
79
- - test/render_canonical_test.rb
80
- - test/render_description_test.rb
81
- - test/render_ga_test.rb
82
- - test/render_html_class_test.rb
83
- - test/render_keywords_test.rb
84
- - test/render_title_test.rb
85
- - test/test_helper.rb
158
+ - spec/fake_app/models.rb
159
+ - spec/fake_app/rails_app.rb
160
+ - spec/helpers/render_canonical_spec.rb
161
+ - spec/helpers/render_description_spec.rb
162
+ - spec/helpers/render_ga_spec.rb
163
+ - spec/helpers/render_html_class_spec.rb
164
+ - spec/helpers/render_keywords_spec.rb
165
+ - spec/helpers/render_title_spec.rb
166
+ - spec/spec_helper.rb
86
167
  homepage: https://github.com/h2ocube/h2ocube_rails_helper
87
168
  licenses:
88
169
  - MIT
@@ -103,35 +184,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
184
  version: '0'
104
185
  requirements: []
105
186
  rubyforge_project:
106
- rubygems_version: 2.2.1
187
+ rubygems_version: 2.2.2
107
188
  signing_key:
108
189
  specification_version: 4
109
190
  summary: Just an helper collection
110
191
  test_files:
111
- - test/dummy/Rakefile
112
- - test/dummy/app/controllers/application_controller.rb
113
- - test/dummy/app/helpers/application_helper.rb
114
- - test/dummy/app/views/layouts/application.html.erb
115
- - test/dummy/config.ru
116
- - test/dummy/config/application.rb
117
- - test/dummy/config/boot.rb
118
- - test/dummy/config/database.yml
119
- - test/dummy/config/environment.rb
120
- - test/dummy/config/environments/development.rb
121
- - test/dummy/config/environments/production.rb
122
- - test/dummy/config/environments/test.rb
123
- - test/dummy/config/initializers/backtrace_silencers.rb
124
- - test/dummy/config/initializers/inflections.rb
125
- - test/dummy/config/initializers/mime_types.rb
126
- - test/dummy/config/initializers/secret_token.rb
127
- - test/dummy/config/initializers/session_store.rb
128
- - test/dummy/config/locales/en.yml
129
- - test/dummy/config/routes.rb
130
- - test/dummy/script/rails
131
- - test/render_canonical_test.rb
132
- - test/render_description_test.rb
133
- - test/render_ga_test.rb
134
- - test/render_html_class_test.rb
135
- - test/render_keywords_test.rb
136
- - test/render_title_test.rb
137
- - test/test_helper.rb
192
+ - spec/fake_app/models.rb
193
+ - spec/fake_app/rails_app.rb
194
+ - spec/helpers/render_canonical_spec.rb
195
+ - spec/helpers/render_description_spec.rb
196
+ - spec/helpers/render_ga_spec.rb
197
+ - spec/helpers/render_html_class_spec.rb
198
+ - spec/helpers/render_keywords_spec.rb
199
+ - spec/helpers/render_title_spec.rb
200
+ - spec/spec_helper.rb