metanol 0.0.8 → 0.0.9

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.
@@ -1,194 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class TestsController < ApplicationController; end
4
-
5
- describe TestsController do
6
-
7
- context "render only main meta tags" do
8
- controller do
9
- def index
10
- meta :title, "Users List"
11
- meta :description, "Description for a users list"
12
- og_meta title: "OpenGraph Title", description: "OpenGraph Description"
13
- render :inline => <<-ERB
14
- <%= metanol_main_tags %>
15
- ERB
16
- end
17
- end
18
-
19
- before { get :index }
20
-
21
- it { response.should_not have_selector('meta[content="OpenGraph Title"]', property: 'og:title') }
22
- it { response.should_not have_selector('meta[content="OpenGraph Description"]', property: 'og:description') }
23
- it { response.should have_selector('title', content: 'Users List') }
24
- it { response.should have_selector('meta[content="Description for a users list"]', name: 'description') }
25
- end
26
-
27
- context "render only open graph meta tags" do
28
- controller do
29
- def index
30
- meta :title, "Users List"
31
- meta :description, "Description for a users list"
32
- og_meta title: "OpenGraph Title", description: "OpenGraph Description"
33
- render :inline => <<-ERB
34
- <%= metanol_og_tags %>
35
- ERB
36
- end
37
- end
38
-
39
- before { get :index }
40
-
41
- it { response.should have_selector('meta[content="OpenGraph Title"]', property: 'og:title') }
42
- it { response.should have_selector('meta[content="OpenGraph Description"]', property: 'og:description') }
43
- it { response.should_not have_selector('title', content: 'Users List') }
44
- it { response.should_not have_selector('meta[content="Description for a users list"]', name: 'description') }
45
- end
46
-
47
- context "render all meta tags" do
48
- controller do
49
- def index
50
- meta :title, "Users List"
51
- meta :description, "Description for a users list"
52
- og_meta title: "OpenGraph Title", description: "OpenGraph Description"
53
- md_meta description: "MicroData Description"
54
- render :inline => <<-ERB
55
- <%= metanol_tags %>
56
- ERB
57
- end
58
- end
59
-
60
- before { get :index }
61
-
62
- it { response.should have_selector('meta[content="OpenGraph Title"]', property: 'og:title') }
63
- it { response.should have_selector('meta[content="OpenGraph Description"]', property: 'og:description') }
64
- it { response.should have_selector('title', content: 'Users List') }
65
- it { response.should have_selector('meta[content="Description for a users list"]', name: 'description') }
66
- it { response.should have_selector('meta[content="MicroData Description"]', itemprop: 'description') }
67
- end
68
-
69
- context "raise exception for unsupported metas" do
70
- controller do
71
- def index
72
- meta :title, "Users List"
73
- wm_meta fake: "Fake value"
74
- render :inline => <<-ERB
75
- <%= metanol_tags %>
76
- ERB
77
- end
78
- end
79
-
80
- it { expect { get :index }.to raise_error(NameError, "The meta tag 'fake' isn't supported.") }
81
- end
82
-
83
- context "filter whitespaces" do
84
- controller do
85
- def index
86
- meta :description, "Description \t\nfor \ta \tusers \r\nlist", :whitespaces
87
- render :inline => <<-ERB
88
- <%= metanol_main_tags %>
89
- ERB
90
- end
91
- end
92
-
93
- before { get :index }
94
-
95
- it('success') { response.should have_selector('meta[content="Description for a users list"]', name: 'description') }
96
- end
97
-
98
- context "filter HTML tags" do
99
- controller do
100
- def index
101
- meta({description: "<div>Description <br/>for <b>a users</b> <br>list</div>", keywords: "key,word"}, :html)
102
- render :inline => <<-ERB
103
- <%= metanol_main_tags %>
104
- ERB
105
- end
106
- end
107
-
108
- before { get :index }
109
-
110
- it('success') { response.should have_selector('meta[content="Description for a users list"]', name: 'description') }
111
- end
112
-
113
- context "filter HTML tags and whitespaces" do
114
- controller do
115
- def index
116
- meta(:description, "<div>\tDescription \r\n<br/>for \t<b>a users</b> \r\n<br>list</div>", :html, :whitespaces)
117
- render :inline => <<-ERB
118
- <%= metanol_main_tags %>
119
- ERB
120
- end
121
- end
122
-
123
- before { get :index }
124
-
125
- it('success') { response.should have_selector('meta[content=" Description for a users list"]', name: 'description') }
126
- end
127
-
128
- context "filter spaces - leave only 1 space between words" do
129
- controller do
130
- def index
131
- meta :description, "Description for a users list", :overspaces
132
- render :inline => <<-ERB
133
- <%= metanol_main_tags %>
134
- ERB
135
- end
136
- end
137
-
138
- before { get :index }
139
-
140
- it('success') { response.should have_selector('meta[content="Description for a users list"]', name: 'description') }
141
- end
142
-
143
- context "clean up a value from whitespaces, html tags etc (run all filters)" do
144
- controller do
145
- def index
146
- meta(:description, "<div>\tDescription \r\n<br/>for \t<b>a users</b> \r\n<br>list</div>", :clean)
147
- render :inline => <<-ERB
148
- <%= metanol_main_tags %>
149
- ERB
150
- end
151
- end
152
-
153
- before { get :index }
154
-
155
- it { response.should have_selector('meta[content=" Description for a users list"]', name: 'description') }
156
- end
157
-
158
- context "returns meta values in a controller and in a view" do
159
- controller do
160
- def index
161
- meta :title, 'Users List'
162
- wm_meta :alexa, 'alexa code'
163
- og_meta title: 'OpenGraph Title'
164
- md_meta description: 'MicroData Desc'
165
-
166
- @meta = get_meta :title
167
- @wm_meta = get_wm_meta :alexa
168
- @og_meta = get_og_meta :title
169
- @md_meta = get_md_meta :description
170
- @og_no_meta = get_og_meta :bad_meta_name
171
-
172
- render :inline => <<-ERB
173
- <span>Main meta is <%= get_meta :title %></span>
174
- <span>OpenGraph meta is <%= get_og_meta :title %></span>
175
- <span>Webmaster meta is <%= get_wm_meta :alexa %></span>
176
- <span>MicroData meta is <%= get_md_meta :description %></span>
177
- ERB
178
- end
179
- end
180
-
181
- before { get :index }
182
-
183
- it { response.should have_selector('span', content: 'Main meta is Users List') }
184
- it { response.should have_selector('span', content: 'OpenGraph meta is OpenGraph Title') }
185
- it { response.should have_selector('span', content: 'Webmaster meta is alexa code') }
186
- it { response.should have_selector('span', content: 'MicroData meta is MicroData Desc') }
187
- it { assigns(:meta).should == 'Users List' }
188
- it { assigns(:wm_meta).should == 'alexa code' }
189
- it { assigns(:og_meta).should == 'OpenGraph Title' }
190
- it { assigns(:md_meta).should == 'MicroData Desc' }
191
- it { assigns(:og_no_meta).should == nil }
192
- end
193
-
194
- end
data/spec/spec_helper.rb DELETED
@@ -1,22 +0,0 @@
1
- require 'rails'
2
- require 'rspec/autorun'
3
- require 'metanol'
4
-
5
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
6
- require 'rspec/rails'
7
-
8
- RSpec.configure do |config|
9
-
10
- # If true, the base class of anonymous controllers will be inferred
11
- # automatically. This will be the default behavior in future versions of
12
- # rspec-rails.
13
- config.infer_base_class_for_anonymous_controllers = true
14
-
15
- # Run specs in random order to surface order dependencies. If you find an
16
- # order dependency and want to debug it, you can fix the order by providing
17
- # the seed, which is printed after each run.
18
- # --seed 1234
19
- config.order = "random"
20
-
21
- config.include Rails.application.routes.url_helpers
22
- end
@@ -1,59 +0,0 @@
1
- require 'action_controller/railtie'
2
- require 'action_view/railtie'
3
- require 'active_record'
4
-
5
- ActiveRecord::Base.configurations = {'test' => {:adapter => 'sqlite3', :database => ':memory:'}}
6
- ActiveRecord::Base.establish_connection('test')
7
-
8
- app = Class.new(Rails::Application)
9
- app.config.secret_token = 'f974ebb750a8e200c85f7a749d589fa2'
10
- app.config.session_store :cookie_store, :key => '_myapp_session'
11
- app.config.active_support.deprecation = :log
12
- app.config.eager_load = false
13
- app.config.root = File.dirname(__FILE__)
14
- Rails.backtrace_cleaner.remove_silencers!
15
- app.initialize!
16
-
17
- app.routes.draw do
18
- resources :tests
19
- resources :home do
20
- collection do
21
- get :get_title
22
- end
23
- end
24
- end
25
-
26
- class ApplicationController < ActionController::Base; end
27
-
28
- class ParentController < ApplicationController
29
- wm_meta :alexa, 'alexa code'
30
- wm_meta :yandex, 'yandex code'
31
- wm_meta bing: 'bing code', google: 'google code'
32
- end
33
-
34
- class HomeController < ParentController
35
- og_meta :type, 'website'
36
- og_meta :locale, 'uk_UA'
37
-
38
- def new
39
- render :inline => <<-ERB
40
- <%= metanol_wm_tags %>
41
- ERB
42
- end
43
-
44
- def index
45
- meta :title, 'Index Page'
46
- og_meta title: 'OpenGraph Title', description: 'OpenGraph Description'
47
- render :inline => <<-ERB
48
- <%= metanol_tags %>
49
- ERB
50
- end
51
-
52
- def get_title
53
- render :inline => <<-ERB
54
- <%= metanol_main_tags %>
55
- ERB
56
- end
57
- end
58
-
59
- Object.const_set(:ApplicationHelper, Module.new)