faqmarkdown 0.0.1
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 +7 -0
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Appraisals +13 -0
- data/Gemfile +10 -0
- data/Rakefile +11 -0
- data/app/controllers/application_controller.rb +2 -0
- data/app/controllers/faqs_controller.rb +66 -0
- data/app/helpers/faq_helper.rb +23 -0
- data/app/models/faq.rb +170 -0
- data/app/views/faqs/_faq.html.haml +16 -0
- data/app/views/faqs/_feed_link.html.haml +2 -0
- data/app/views/faqs/feed.xml.builder +29 -0
- data/app/views/faqs/index.html.haml +8 -0
- data/app/views/faqs/show.html.haml +3 -0
- data/app/views/layouts/faqmarkdown.html.haml +16 -0
- data/config.ru +8 -0
- data/faqmarkdown.gemspec +37 -0
- data/gemfiles/rails3_0.gemfile +13 -0
- data/gemfiles/rails3_1.gemfile +14 -0
- data/gemfiles/rails3_2.gemfile +14 -0
- data/lib/faqmarkdown/config.rb +24 -0
- data/lib/faqmarkdown/engine.rb +12 -0
- data/lib/faqmarkdown/railtie.rb +20 -0
- data/lib/faqmarkdown/routes.rb +30 -0
- data/lib/faqmarkdown/util.rb +12 -0
- data/lib/faqmarkdown/version.rb +3 -0
- data/lib/faqmarkdown.rb +5 -0
- data/lib/generators/faqmarkdown/faq_generator.rb +42 -0
- data/lib/generators/faqmarkdown/install_generator.rb +19 -0
- data/lib/generators/faqmarkdown/override_generator.rb +48 -0
- data/lib/generators/faqmarkdown/templates/example-faq.markdown +67 -0
- data/lib/generators/faqmarkdown/usage/faq.txt +14 -0
- data/lib/generators/faqmarkdown/usage/install.txt +10 -0
- data/lib/generators/faqmarkdown/usage/override.txt +9 -0
- data/readme.md +191 -0
- data/spec/helpers/faq_helper_spec.rb +49 -0
- data/spec/integrations/faqs_spec.rb +209 -0
- data/spec/internal/.gitignore +2 -0
- data/spec/internal/app/faqs/2011-04-01-first-faq.markdown +5 -0
- data/spec/internal/app/faqs/2011-04-28-image.markdown +5 -0
- data/spec/internal/app/faqs/2011-04-28-summary.markdown +10 -0
- data/spec/internal/app/faqs/2011-05-01-full-metadata.markdown +20 -0
- data/spec/internal/app/faqs/2015-02-13-custom-title.markdown +5 -0
- data/spec/internal/app/views/layouts/application.html.erb +12 -0
- data/spec/internal/app/views/layouts/custom_layout.html.erb +14 -0
- data/spec/internal/config/database.yml +3 -0
- data/spec/internal/config/environments/test.rb +9 -0
- data/spec/internal/config/routes.rb +3 -0
- data/spec/internal/db/combustion_test.sqlite +0 -0
- data/spec/internal/db/schema.rb +3 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/lib/generators/faqmarkdown/faq_generator_spec.rb +99 -0
- data/spec/models/faqs_spec.rb +103 -0
- data/spec/requests/assets_spec.rb +16 -0
- data/spec/requests/views_spec.rb +34 -0
- data/spec/routing/faqs_routing_spec.rb +80 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/support/data/faqs/2011-04-01-first-faq.markdown +3 -0
- data/spec/support/data/faqs/2011-04-28-image.markdown +9 -0
- data/spec/support/data/faqs/2011-04-28-summary.markdown +10 -0
- data/spec/support/data/faqs/2011-05-01-full-metadata.markdown +13 -0
- data/spec/support/data/faqs/2011-05-02-md-file-extension.md +1 -0
- data/spec/support/data/faqs/2011-05-02-mdown-file-extension.mdown +1 -0
- data/spec/support/data/faqs/2011-05-02-mkd-file-extension.mkd +1 -0
- data/spec/support/data/faqs/2012-02-13-102030-custom-title-and-timestamp.markdown +5 -0
- data/spec/support/data/faqs/2015-02-13-custom-title.markdown +5 -0
- data/spec/support/data/faqs/missing-date-from-filename.markdown +1 -0
- data/spec/support/rails_app/.gitignore +4 -0
- data/spec/support/rails_app/app/controllers/application_controller.rb +3 -0
- data/spec/support/rails_app/app/faqs/2011-04-01-first-faq.markdown +5 -0
- data/spec/support/rails_app/app/faqs/2011-04-28-image.markdown +5 -0
- data/spec/support/rails_app/app/faqs/2011-04-28-summary.markdown +10 -0
- data/spec/support/rails_app/app/faqs/2011-05-01-full-metadata.markdown +20 -0
- data/spec/support/rails_app/app/faqs/2015-02-13-custom-title.markdown +5 -0
- data/spec/support/rails_app/app/views/layouts/application.html.erb +12 -0
- data/spec/support/rails_app/app/views/layouts/custom_layout.html.erb +14 -0
- data/spec/support/rails_app/config/application.rb +42 -0
- data/spec/support/rails_app/config/boot.rb +10 -0
- data/spec/support/rails_app/config/database.yml +22 -0
- data/spec/support/rails_app/config/environment.rb +5 -0
- data/spec/support/rails_app/config/environments/test.rb +9 -0
- data/spec/support/rails_app/config/initializers/secret_token.rb +7 -0
- data/spec/support/rails_app/config/routes.rb +3 -0
- data/spec/support/rails_app/config.ru +4 -0
- data/spec/support/rails_app/db/seeds.rb +7 -0
- data/spec/support/rails_app/doc/README_FOR_APP +2 -0
- data/vendor/assets/stylesheets/faqmarkdown/faqmarkdown.css +69 -0
- metadata +354 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Rails.application.class.configure do
|
|
2
|
+
config.cache_classes = true
|
|
3
|
+
config.whiny_nils = true
|
|
4
|
+
config.consider_all_requests_local = true
|
|
5
|
+
config.action_controller.perform_caching = false
|
|
6
|
+
config.action_dispatch.show_exceptions = false
|
|
7
|
+
config.action_mailer.delivery_method = :test
|
|
8
|
+
config.active_support.deprecation = :stderr
|
|
9
|
+
end
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.log
|
|
File without changes
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Faqmarkdown
|
|
4
|
+
describe FaqGenerator do
|
|
5
|
+
include GeneratorSpec::TestCase
|
|
6
|
+
destination File.expand_path('../../../../../tmp', __FILE__)
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
prepare_destination
|
|
10
|
+
|
|
11
|
+
Faq.stub(:directory) { File.expand_path('tmp/app/faqs') }
|
|
12
|
+
Faq.class_variable_set('@@faqs', nil)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context 'with the slug parameter' do
|
|
16
|
+
it 'creates a file for the slug and the current date' do
|
|
17
|
+
Timecop.freeze(Time.utc(2012, 1, 1, 10, 20, 30)) do
|
|
18
|
+
run_generator %w(test-faq)
|
|
19
|
+
|
|
20
|
+
Dir.glob('tmp/app/faqs/*').should == ['tmp/app/faqs/2012-01-01-102030-test-faq.markdown']
|
|
21
|
+
|
|
22
|
+
Faq.all.count.should == 1
|
|
23
|
+
|
|
24
|
+
faq = Faq.first
|
|
25
|
+
faq.slug.should == 'test-faq'
|
|
26
|
+
faq.date.should == Date.parse('2012-01-01')
|
|
27
|
+
faq.title.should == 'Test faq'
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context 'with the slug parameter including an underscore' do
|
|
33
|
+
it 'creates the correct file and sets the right values' do
|
|
34
|
+
Timecop.freeze(Time.utc(2012, 1, 1, 10, 20, 30)) do
|
|
35
|
+
run_generator %w(test-faq_with_underscores)
|
|
36
|
+
|
|
37
|
+
Dir.glob('tmp/app/faqs/*').should == ['tmp/app/faqs/2012-01-01-102030-test-faq_with_underscores.markdown']
|
|
38
|
+
|
|
39
|
+
Faq.all.count.should == 1
|
|
40
|
+
|
|
41
|
+
faq = Faq.first
|
|
42
|
+
faq.slug.should == 'test-faq_with_underscores'
|
|
43
|
+
faq.date.should == Date.parse('2012-01-01')
|
|
44
|
+
faq.title.should == 'Test faq_with_underscores'
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context 'with the slug and date parameters' do
|
|
50
|
+
it 'creates a file for the slug and the given date' do
|
|
51
|
+
run_generator %w(other-faq --date=2012-01-02)
|
|
52
|
+
|
|
53
|
+
Dir.glob('tmp/app/faqs/*').should == ['tmp/app/faqs/2012-01-02-000000-other-faq.markdown']
|
|
54
|
+
|
|
55
|
+
Faq.all.count.should == 1
|
|
56
|
+
|
|
57
|
+
faq = Faq.first
|
|
58
|
+
faq.slug.should == 'other-faq'
|
|
59
|
+
faq.date.should == Date.parse('2012-01-02')
|
|
60
|
+
faq.title.should == 'Other faq'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context 'with the slug, date and time parameters' do
|
|
65
|
+
it 'creates a file for the slug and the given date' do
|
|
66
|
+
run_generator %w(other-faq --date=2012-01-02-102030)
|
|
67
|
+
|
|
68
|
+
Dir.glob('tmp/app/faqs/*').should == ['tmp/app/faqs/2012-01-02-102030-other-faq.markdown']
|
|
69
|
+
|
|
70
|
+
Faq.all.count.should == 1
|
|
71
|
+
|
|
72
|
+
faq = Faq.first
|
|
73
|
+
faq.slug.should == 'other-faq'
|
|
74
|
+
faq.date.should == Time.utc(2012, 01, 02, 10, 20, 30).to_date
|
|
75
|
+
faq.title.should == 'Other faq'
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context 'with invalid slug' do
|
|
80
|
+
it 'raises a system exit exception' do
|
|
81
|
+
lambda { run_generator %w(!test-faq) }.should raise_error(SystemExit)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'does not create the file' do
|
|
85
|
+
Dir['app/faqs/*'].should be_empty
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
context 'with invalid date' do
|
|
90
|
+
it 'raises a system exit exception' do
|
|
91
|
+
lambda { run_generator %w(test-faq --date=2012-02) }.should raise_error(SystemExit)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'does not create the file' do
|
|
95
|
+
Dir['app/faqs/*'].should be_empty
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Faq do
|
|
4
|
+
def test_faq(file_name)
|
|
5
|
+
Faq.new(File.dirname(__FILE__) + "/../support/data/faqs/#{file_name}")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it 'should not initialise with bad filename' do
|
|
9
|
+
lambda { test_faq 'missing-date-from-filename.markdown' }.should raise_error
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context 'with missing file' do
|
|
13
|
+
subject { test_faq '2000-01-01-no-such-file.markdown' }
|
|
14
|
+
it 'should error when trying to read content' do
|
|
15
|
+
lambda { subject.content }.should raise_error
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should return the correct directory' do
|
|
20
|
+
Faq.directory.should == Rails.root.join('app', 'faqs')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context 'with first faq' do
|
|
24
|
+
subject { test_faq '2011-04-01-first-faq.markdown' }
|
|
25
|
+
its(:slug) { should == 'first-faq' }
|
|
26
|
+
its(:date) { should == Date.parse('2011-04-01') }
|
|
27
|
+
its(:title) { should == 'First Faq' }
|
|
28
|
+
its(:content) { should =~ /\ALorem ipsum/ }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context 'with custom title faq' do
|
|
32
|
+
subject { test_faq '2015-02-13-custom-title.markdown' }
|
|
33
|
+
its(:slug) { should == 'custom-title' }
|
|
34
|
+
its(:date) { should == Date.parse('2015-02-13') }
|
|
35
|
+
its(:title) { should == 'This is a custom title' }
|
|
36
|
+
its(:content) { should == "Content goes here.\n" }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context 'with a custom title that also and including timestamp' do
|
|
40
|
+
subject { test_faq '2012-02-13-102030-custom-title-and-timestamp.markdown' }
|
|
41
|
+
its(:slug) { should == 'custom-title-and-timestamp' }
|
|
42
|
+
its(:date) { should == Time.utc(2012, 02, 13, 10, 20, 30).to_date }
|
|
43
|
+
its(:title) { should == 'This is a custom title' }
|
|
44
|
+
its(:content) { should == "Content goes here.\n" }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context 'with a slug containing underscores' do
|
|
48
|
+
subject { test_faq '2012-02-12-102030-slug_containing_underscores.markdown' }
|
|
49
|
+
its(:slug) { should == 'slug_containing_underscores' }
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context 'with author' do
|
|
53
|
+
subject { test_faq '2011-05-01-full-metadata.markdown' }
|
|
54
|
+
its(:author) { should == 'John Smith' }
|
|
55
|
+
its(:email) { should == 'john.smith@example.com' }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context "with categories" do
|
|
59
|
+
subject { test_faq '2011-05-01-full-metadata.markdown' }
|
|
60
|
+
its(:categories) { should == ['full', 'metadata']}
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context "search per category" do
|
|
64
|
+
it "should return one Faq per search by category 'full'" do
|
|
65
|
+
faqs = Faq.find_by_category('full')
|
|
66
|
+
faqs.class.should == Array
|
|
67
|
+
faqs.first.categories.include?('full').should be_true
|
|
68
|
+
faqs.first.categories.include?('foobar').should be_false
|
|
69
|
+
faqs.first.categories.should == ['full', 'metadata']
|
|
70
|
+
faqs.first.class.should == Faq
|
|
71
|
+
faqs.first.author.should == 'John Smith'
|
|
72
|
+
faqs.first.email.should == 'john.smith@example.com'
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
context "all categories" do
|
|
77
|
+
it "should list all categories" do
|
|
78
|
+
categories = Faq.categories_all
|
|
79
|
+
categories.class.should == Array
|
|
80
|
+
categories.should == ["full", "metadata"]
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context 'with custom summary faq' do
|
|
86
|
+
subject { test_faq '2011-04-28-summary.markdown' }
|
|
87
|
+
its(:summary) { should == 'This is a custom & test summary.' }
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
context 'with alternate markdown file extension' do
|
|
91
|
+
it 'should accept *.md files' do
|
|
92
|
+
lambda { test_faq('2011-05-02-md-file-extension.md').content }.should_not raise_error
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'should accept *.mkd files' do
|
|
96
|
+
lambda { test_faq('2011-05-02-mkd-file-extension.mkd').content }.should_not raise_error
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'should accept *.mdown files' do
|
|
100
|
+
lambda { test_faq('2011-05-02-mdown-file-extension.mdown').content }.should_not raise_error
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'stylesheet', :type => :request do
|
|
4
|
+
include RSpec::Rails::HelperExampleGroup
|
|
5
|
+
|
|
6
|
+
def stylesheet_path
|
|
7
|
+
html = helper.stylesheet_link_tag 'faqmarkdown/faqmarkdown'
|
|
8
|
+
Nokogiri::HTML.fragment(html).at('link')[:href]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'should be served' do
|
|
12
|
+
visit stylesheet_path
|
|
13
|
+
page.source.should match /font-family:/
|
|
14
|
+
page.source.should match /}\s*\z/
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'views', :type => :request do
|
|
4
|
+
context 'without application index view' do
|
|
5
|
+
it 'should use internal view' do
|
|
6
|
+
visit '/faqs'
|
|
7
|
+
page.should have_css 'section#faqs'
|
|
8
|
+
page.should_not have_content 'test application view'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context 'with application index view' do
|
|
13
|
+
let(:view_path) { Rails.root + 'app/views/faqs/index.html.haml' }
|
|
14
|
+
|
|
15
|
+
before do
|
|
16
|
+
ApplicationController.view_paths.each(&:clear_cache)
|
|
17
|
+
FileUtils.mkdir_p File.dirname(view_path)
|
|
18
|
+
File.open view_path, 'w' do |io|
|
|
19
|
+
io.puts 'This is a test application view.'
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
after do
|
|
24
|
+
File.unlink view_path
|
|
25
|
+
ApplicationController.view_paths.each(&:clear_cache)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'should not use internal view' do
|
|
29
|
+
visit '/faqs'
|
|
30
|
+
page.should have_content 'test application view'
|
|
31
|
+
page.should_not have_css 'section#faqs'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe FaqsController do
|
|
4
|
+
describe 'default routes' do
|
|
5
|
+
it '/faqs to faqs#index' do
|
|
6
|
+
path = faqs_path
|
|
7
|
+
path.should == '/faqs'
|
|
8
|
+
{ :get => path }.should route_to :controller => 'faqs', :action => 'index'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it '/faqs/2012 to faqs#index with year' do
|
|
12
|
+
path = faqs_path(:year => '2012')
|
|
13
|
+
path.should == '/faqs/2012'
|
|
14
|
+
{ :get => path }.should route_to :controller => 'faqs', :action => 'index', :year => '2012'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it '/faqs/2012/01 to faqs#index with year and month' do
|
|
18
|
+
path = faqs_path(:year => '2012', :month => '01')
|
|
19
|
+
path.should == '/faqs/2012/01'
|
|
20
|
+
{ :get => path }.should route_to :controller => 'faqs', :action => 'index', :year => '2012', :month => '01'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it '/faqs/2012/01/01 to faqs#index with year, month and day' do
|
|
24
|
+
path = faqs_path(:year => '2012', :month => '01', :day => '01')
|
|
25
|
+
path.should == '/faqs/2012/01/01'
|
|
26
|
+
{ :get => path }.should route_to :controller => 'faqs', :action => 'index', :year => '2012', :month => '01', :day => '01'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it '/faqs/2012/01/01/test-faq to faqs#show with permalink a format of day' do
|
|
30
|
+
path = faq_path(:id => '2012/01/01/test-faq')
|
|
31
|
+
path.should == '/faqs/2012/01/01/test-faq'
|
|
32
|
+
{ :get => path }.should route_to :controller => 'faqs', :action => 'show', :id => '2012/01/01/test-faq'
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe 'custom routes' do
|
|
37
|
+
before { Rails.application.routes.clear! }
|
|
38
|
+
after { Rails.application.reload_routes! }
|
|
39
|
+
|
|
40
|
+
it '/faq to faqs#index' do
|
|
41
|
+
Rails.application.routes.draw { faqmarkdown :as => :faq }
|
|
42
|
+
|
|
43
|
+
path = faqs_path
|
|
44
|
+
path.should == '/faq'
|
|
45
|
+
{ :get => path }.should route_to :controller => 'faqs', :action => 'index'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it '/faq/test-faq to faqs#show with a permalink format of slug' do
|
|
49
|
+
Rails.application.routes.draw { faqmarkdown :as => :faq, :permalink_format => :slug }
|
|
50
|
+
|
|
51
|
+
path = faq_path(:id => 'test-faq')
|
|
52
|
+
path.should == '/faq/test-faq'
|
|
53
|
+
{ :get => path }.should route_to :controller => 'faqs', :action => 'show', :id => 'test-faq'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it '/faq/2012/test-faq to faqs#show with a permalink format of year' do
|
|
57
|
+
Rails.application.routes.draw { faqmarkdown :as => :faq, :permalink_format => :year }
|
|
58
|
+
|
|
59
|
+
path = faq_path(:id => '2012/test-faq')
|
|
60
|
+
path.should == '/faq/2012/test-faq'
|
|
61
|
+
{ :get => path }.should route_to :controller => 'faqs', :action => 'show', :id => '2012/test-faq'
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it '/faq/2012/01/test-faq to faqs#show with permalink a format of month' do
|
|
65
|
+
Rails.application.routes.draw { faqmarkdown :as => :faq, :permalink_format => :month }
|
|
66
|
+
|
|
67
|
+
path = faq_path(:id => '2012/01/test-faq')
|
|
68
|
+
path.should == '/faq/2012/01/test-faq'
|
|
69
|
+
{ :get => path }.should route_to :controller => 'faqs', :action => 'show', :id => '2012/01/test-faq'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it '/faq/2012/01/01/test-faq to faqs#show with permalink a format of day' do
|
|
73
|
+
Rails.application.routes.draw { faqmarkdown :as => :faq, :permalink_format => :day }
|
|
74
|
+
|
|
75
|
+
path = faq_path(:id => '2012/01/01/test-faq')
|
|
76
|
+
path.should == '/faq/2012/01/01/test-faq'
|
|
77
|
+
{ :get => path }.should route_to :controller => 'faqs', :action => 'show', :id => '2012/01/01/test-faq'
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'bundler'
|
|
5
|
+
Bundler.setup :default, :development
|
|
6
|
+
|
|
7
|
+
require 'faqmarkdown'
|
|
8
|
+
|
|
9
|
+
require 'rails/version'
|
|
10
|
+
if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 0
|
|
11
|
+
require 'support/rails_app/config/environment'
|
|
12
|
+
else
|
|
13
|
+
require 'combustion'
|
|
14
|
+
Combustion.initialize!
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
require 'capybara/rspec'
|
|
18
|
+
require 'rspec/rails'
|
|
19
|
+
require 'capybara/rails'
|
|
20
|
+
|
|
21
|
+
require 'timecop'
|
|
22
|
+
require 'generator_spec/test_case'
|
|
23
|
+
Dir[File.expand_path('lib/generators/faqmarkdown/*.rb')].each { |f| require f }
|
|
24
|
+
|
|
25
|
+
require 'delorean'
|
|
26
|
+
|
|
27
|
+
RSpec.configure do |config|
|
|
28
|
+
config.mock_with :rspec
|
|
29
|
+
config.include Delorean
|
|
30
|
+
config.order = :random
|
|
31
|
+
|
|
32
|
+
config.after do
|
|
33
|
+
Timecop.return
|
|
34
|
+
FileUtils.rm_rf('spec/tmp/app/faqs/.')
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
ActiveSupport::Deprecation.debug = true
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
2
|
+
|
|
3
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Faq with full metadata
|
|
3
|
+
author: John Smith
|
|
4
|
+
email: john.smith@example.com
|
|
5
|
+
summary: This is another custom & test summary.
|
|
6
|
+
categories:
|
|
7
|
+
- full
|
|
8
|
+
- metadata
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
First paragraph of content.
|
|
12
|
+
<!--more-->
|
|
13
|
+
Second paragraph of content.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This faq is missing the date from the filename.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
2
|
+
|
|
3
|
+
<!--more-->
|
|
4
|
+
|
|
5
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Faq with full metadata
|
|
3
|
+
author: John Smith
|
|
4
|
+
email: john.smith@example.com
|
|
5
|
+
summary: This is another custom & test summary.
|
|
6
|
+
categories:
|
|
7
|
+
- full
|
|
8
|
+
- metadata
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
First paragraph of content.
|
|
12
|
+
|
|
13
|
+
<!--more-->
|
|
14
|
+
|
|
15
|
+
Second paragraph of content.
|
|
16
|
+
|
|
17
|
+
First line of code.
|
|
18
|
+
Second line of code.
|
|
19
|
+
|
|
20
|
+
<%= content_tag :p, "Paragraph created by Rails helper" %>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'rails/all'
|
|
4
|
+
|
|
5
|
+
# If you have a Gemfile, require the gems listed there, including any gems
|
|
6
|
+
# you've limited to :test, :development, or :production.
|
|
7
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
|
8
|
+
|
|
9
|
+
module RailsApp
|
|
10
|
+
class Application < Rails::Application
|
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
12
|
+
# Application configuration should go into files in config/initializers
|
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
14
|
+
|
|
15
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
|
16
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
|
17
|
+
|
|
18
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
|
19
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
|
20
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
|
21
|
+
|
|
22
|
+
# Activate observers that should always be running.
|
|
23
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
|
24
|
+
|
|
25
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
26
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
27
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
28
|
+
|
|
29
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
30
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
31
|
+
# config.i18n.default_locale = :de
|
|
32
|
+
|
|
33
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
|
34
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
|
35
|
+
|
|
36
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
|
37
|
+
config.encoding = "utf-8"
|
|
38
|
+
|
|
39
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
|
40
|
+
config.filter_parameters += [:password]
|
|
41
|
+
end
|
|
42
|
+
end
|