blogit 1.0.0.rc1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -31
  3. data/Rakefile +6 -2
  4. data/app/assets/stylesheets/blogit/themes/default.css +4 -0
  5. data/app/assets/stylesheets/blogit/themes/default.css.map +7 -0
  6. data/app/assets/stylesheets/blogit/themes/default.min.css +2 -0
  7. data/app/assets/stylesheets/blogit/themes/default.min.css.map +7 -0
  8. data/app/assets/stylesheets/blogit/themes/default.sass +2 -0
  9. data/app/assets/stylesheets/blogit/themes/default/base/_colors.sass +1 -0
  10. data/app/assets/stylesheets/blogit/themes/default/base/_typography.sass +1 -0
  11. data/app/assets/stylesheets/blogit/themes/default/blocks/_archives.sass +18 -0
  12. data/app/assets/stylesheets/blogit/themes/default/blocks/_comments.sass +7 -0
  13. data/app/assets/stylesheets/blogit/themes/default/blocks/_forms.sass +9 -0
  14. data/app/assets/stylesheets/blogit/themes/default/blocks/_headers.sass +4 -0
  15. data/app/assets/stylesheets/blogit/themes/default/blocks/_posts.sass +8 -0
  16. data/app/assets/stylesheets/blogit/themes/default/blocks/_related_posts_list.sass +3 -0
  17. data/app/assets/stylesheets/blogit/themes/default/blocks/_share_bars.sass +7 -0
  18. data/app/{views/blogit/posts/_no_comments.html.erb → assets/stylesheets/blogit/themes/default/blocks/_tag_list.sass} +0 -0
  19. data/app/assets/stylesheets/blogit/themes/default/blocks/_tags.sass +4 -0
  20. data/app/controllers/blogit/application_controller.rb +15 -31
  21. data/app/controllers/blogit/comments_controller.rb +48 -30
  22. data/app/controllers/blogit/posts_controller.rb +52 -86
  23. data/app/helpers/blogit/application_helper.rb +59 -69
  24. data/app/helpers/blogit/comments_helper.rb +20 -0
  25. data/app/helpers/blogit/layout_helper.rb +33 -0
  26. data/app/helpers/blogit/posts_helper.rb +36 -34
  27. data/app/models/blogit/post.rb +55 -6
  28. data/app/views/blogit/archive/_list.html.erb +5 -0
  29. data/app/views/blogit/archive/_month.html.erb +9 -0
  30. data/app/views/blogit/archive/_year.html.erb +7 -0
  31. data/app/views/blogit/{posts → comments}/_active_record_comments.html.erb +2 -1
  32. data/app/views/blogit/comments/_comment.html.erb +10 -14
  33. data/app/views/blogit/comments/_comments_count.html.erb +8 -0
  34. data/app/views/blogit/{posts → comments}/_disqus_comments.html.erb +0 -0
  35. data/app/views/blogit/comments/_form.html.erb +25 -18
  36. data/app/views/blogit/comments/_no_comments.html.erb +0 -0
  37. data/app/views/blogit/comments/create.js.erb +2 -2
  38. data/app/views/blogit/posts/_archiveable.html.erb +3 -0
  39. data/app/views/blogit/posts/_blog_post_spacer.html.erb +1 -1
  40. data/app/views/blogit/posts/_blogger_information.html.erb +9 -4
  41. data/app/views/blogit/posts/_meta_tags.html.erb +32 -0
  42. data/app/views/blogit/posts/_post.html.erb +6 -9
  43. data/app/views/blogit/posts/_post_footer.html.erb +1 -0
  44. data/app/views/blogit/posts/_post_head.html.erb +3 -2
  45. data/app/views/blogit/posts/_related.html.erb +7 -16
  46. data/app/views/blogit/posts/_related_post.html.erb +4 -0
  47. data/app/views/blogit/posts/_share_bar.html.erb +5 -6
  48. data/app/views/blogit/posts/_tags.html.erb +8 -0
  49. data/app/views/blogit/posts/index.html.erb +16 -11
  50. data/app/views/blogit/posts/show.html.erb +28 -4
  51. data/app/views/blogit/tags/_tag.html.erb +3 -0
  52. data/config/locales/en.yml +3 -2
  53. data/config/spring.rb +1 -0
  54. data/db/migrate/20150618184415_add_description_to_posts.rb +5 -0
  55. data/lib/blogit.rb +4 -5
  56. data/lib/blogit/archive.rb +8 -0
  57. data/lib/blogit/archive/archive_error.rb +3 -0
  58. data/lib/blogit/archive/archiveable.rb +20 -0
  59. data/lib/blogit/archive/list.rb +52 -0
  60. data/lib/blogit/archive/month.rb +34 -0
  61. data/lib/blogit/archive/year.rb +40 -0
  62. data/lib/blogit/blogs.rb +11 -5
  63. data/lib/blogit/configuration.rb +157 -147
  64. data/lib/blogit/parsers/html_parser.rb +6 -3
  65. data/lib/blogit/parsers/markdown_parser.rb +30 -5
  66. data/lib/blogit/parsers/textile_parser.rb +18 -8
  67. data/lib/blogit/renderers/html_with_albino.rb +1 -1
  68. data/lib/blogit/version.rb +1 -1
  69. data/lib/generators/templates/blogit.rb +23 -57
  70. data/lib/tasks/blogit.rake +42 -0
  71. data/lib/tasks/blogit/css.rake +22 -0
  72. data/lib/tasks/blogit/doc.rake +21 -0
  73. data/lib/tasks/seed_blog_posts.yml +95 -0
  74. data/lib/validators/absence_validator.rb +2 -2
  75. data/spec/blogit_spec.rb +3 -3
  76. data/spec/controllers/blogit/comments_controller_spec.rb +31 -86
  77. data/spec/controllers/blogit/posts_controller_spec.rb +33 -344
  78. data/spec/dummy/Rakefile +1 -1
  79. data/spec/dummy/app/assets/stylesheets/application.sass +7 -0
  80. data/spec/dummy/app/assets/stylesheets/base.sass +1 -0
  81. data/spec/dummy/app/assets/stylesheets/base/_html.sass +15 -0
  82. data/spec/dummy/app/assets/stylesheets/blocks.sass +1 -0
  83. data/spec/dummy/app/assets/stylesheets/blocks/_layout.sass +21 -0
  84. data/spec/dummy/app/views/layouts/application.html.erb +21 -18
  85. data/spec/dummy/app/views/layouts/custom.html.erb +2 -1
  86. data/spec/dummy/config.ru +0 -1
  87. data/spec/dummy/config/application.rb +1 -0
  88. data/spec/dummy/config/database.yml +5 -3
  89. data/spec/dummy/config/environments/production.rb +7 -2
  90. data/spec/dummy/config/environments/test.rb +6 -1
  91. data/spec/dummy/db/development.sqlite3 +0 -0
  92. data/spec/dummy/db/migrate/{20140511174024_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb → 20150619080551_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb} +0 -0
  93. data/spec/dummy/db/migrate/{20140511174025_add_missing_unique_indices.acts_as_taggable_on_engine.rb → 20150619080552_add_missing_unique_indices.acts_as_taggable_on_engine.rb} +0 -0
  94. data/spec/dummy/db/migrate/{20140511174026_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb → 20150619080553_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb} +0 -0
  95. data/spec/dummy/db/migrate/20150619080554_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
  96. data/spec/dummy/db/migrate/20150619080555_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +10 -0
  97. data/spec/dummy/db/schema.rb +9 -7
  98. data/spec/dummy/db/seeds.rb +17 -0
  99. data/spec/dummy/lib/tasks/dummy.rake +29 -0
  100. data/spec/dummy/log/development.log +22286 -1489
  101. data/spec/dummy/log/test.log +4608 -11518
  102. data/spec/factories.rb +10 -5
  103. data/spec/helpers/blogit/application_helper_spec.rb +10 -73
  104. data/spec/helpers/blogit/posts_helper_spec.rb +8 -63
  105. data/spec/injectables/dummy_archiveable.rb +6 -0
  106. data/spec/lib/archive/list_spec.rb +60 -0
  107. data/spec/lib/archive/month_spec.rb +17 -0
  108. data/spec/lib/archive/year_spec.rb +38 -0
  109. data/spec/lib/blogit/parsers/html_parser_spec.rb +1 -1
  110. data/spec/lib/blogit/parsers/markdown_parser_spec.rb +7 -6
  111. data/spec/lib/blogit/parsers/textile_parser_spec.rb +1 -1
  112. data/spec/lib/blogs_spec.rb +2 -2
  113. data/spec/lib/configuration_spec.rb +21 -49
  114. data/spec/models/blogit/comment_spec.rb +19 -19
  115. data/spec/models/blogit/post_spec.rb +63 -28
  116. data/spec/rails_helper.rb +28 -0
  117. data/spec/spec_helper.rb +2 -11
  118. data/spec/support/helpers/css_matchers.rb +42 -0
  119. metadata +193 -124
  120. data/app/assets/stylesheets/blogit/index.css +0 -84
  121. data/app/views/blogit/comments/_admin_links.html.erb +0 -3
  122. data/app/views/blogit/posts/_comments_count.html.erb +0 -5
  123. data/app/views/blogit/posts/_form.html.erb +0 -49
  124. data/app/views/blogit/posts/_post_body.html.erb +0 -1
  125. data/app/views/blogit/posts/_post_links.html.erb +0 -6
  126. data/app/views/blogit/posts/edit.html.erb +0 -3
  127. data/app/views/blogit/posts/new.html.erb +0 -3
  128. data/lib/tasks/blog_tasks.rake +0 -4
  129. data/spec/dummy/app/assets/stylesheets/application.css +0 -21
  130. data/spec/dummy/config/initializers/blogit.rb +0 -88
  131. data/spec/dummy/db/migrate/20140511174028_create_blogit_posts.blogit.rb +0 -16
  132. data/spec/dummy/db/migrate/20140511174029_create_blogit_comments.blogit.rb +0 -16
  133. data/spec/dummy/db/test.sqlite3 +0 -0
  134. data/spec/dummy/tmp/cache/assets/CB5/DD0/sprockets%2F346324d2a51df58457807bee661c449c +0 -0
  135. data/spec/dummy/tmp/cache/assets/CB6/ED0/sprockets%2F4390d06699f3ad4262e342be530f9f91 +0 -0
  136. data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  137. data/spec/dummy/tmp/cache/assets/CE7/230/sprockets%2F6f493a817d97133a8dbf674bcd322670 +0 -0
  138. data/spec/dummy/tmp/cache/assets/CEA/490/sprockets%2F9697d4fb1ed26d80f3c715611c8d4373 +0 -0
  139. data/spec/dummy/tmp/cache/assets/CEE/310/sprockets%2F89642af8492e579dcd7162a0e2b7f155 +0 -0
  140. data/spec/dummy/tmp/cache/assets/D01/8C0/sprockets%2F332d5a9ce3e800c6c4a7a99058023ba2 +0 -0
  141. data/spec/dummy/tmp/cache/assets/D11/CC0/sprockets%2F3a12dfa6665b5318fa99d097203ac7e7 +0 -0
  142. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  143. data/spec/dummy/tmp/cache/assets/D3D/1E0/sprockets%2Ffbaabd57fa2c9d426f0c318156705667 +0 -0
  144. data/spec/dummy/tmp/cache/assets/D3E/920/sprockets%2F3efa8d0fc958c223647cb704183b65ca +0 -0
  145. data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  146. data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  147. data/spec/dummy/tmp/cache/assets/D61/6F0/sprockets%2F02da53eeca228bcef0c49278517111fe +0 -0
  148. data/spec/dummy/tmp/cache/assets/DCA/9B0/sprockets%2Fdf0e8f8a85e5d4056b3fe1cec3b7131a +0 -0
  149. data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  150. data/spec/dummy/tmp/cache/assets/E02/A60/sprockets%2Fb32faeede196f7a933c3a2794e7ed0bd +0 -0
  151. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  152. data/spec/dummy/tmp/cache/assets/development/sprockets/02da53eeca228bcef0c49278517111fe +0 -0
  153. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  154. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  155. data/spec/dummy/tmp/cache/assets/development/sprockets/2ff93f9f5ed9970021c7704ff93237c8 +0 -0
  156. data/spec/dummy/tmp/cache/assets/development/sprockets/332d5a9ce3e800c6c4a7a99058023ba2 +0 -0
  157. data/spec/dummy/tmp/cache/assets/development/sprockets/346324d2a51df58457807bee661c449c +0 -0
  158. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  159. data/spec/dummy/tmp/cache/assets/development/sprockets/3a12dfa6665b5318fa99d097203ac7e7 +0 -0
  160. data/spec/dummy/tmp/cache/assets/development/sprockets/3ed52366904e135bd833590814b6ac6d +0 -0
  161. data/spec/dummy/tmp/cache/assets/development/sprockets/4390d06699f3ad4262e342be530f9f91 +0 -0
  162. data/spec/dummy/tmp/cache/assets/development/sprockets/6f493a817d97133a8dbf674bcd322670 +0 -0
  163. data/spec/dummy/tmp/cache/assets/development/sprockets/89642af8492e579dcd7162a0e2b7f155 +0 -0
  164. data/spec/dummy/tmp/cache/assets/development/sprockets/89dc196c51ae83634b664c0c33052008 +0 -0
  165. data/spec/dummy/tmp/cache/assets/development/sprockets/8dd8236b00c868ba248fe30cd9c14c2a +0 -0
  166. data/spec/dummy/tmp/cache/assets/development/sprockets/9239a04d094a872c1cf77ac391072ea8 +0 -0
  167. data/spec/dummy/tmp/cache/assets/development/sprockets/b3ffb6bd243399012806331ce393ae4f +0 -0
  168. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  169. data/spec/dummy/tmp/cache/assets/development/sprockets/d53accc3e58037ee4005e41221b8846b +0 -0
  170. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  171. data/spec/dummy/tmp/cache/assets/development/sprockets/df0e8f8a85e5d4056b3fe1cec3b7131a +0 -0
  172. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  173. data/spec/routing/post_routing_spec.rb +0 -49
@@ -4,19 +4,24 @@ FactoryGirl.define do
4
4
  # = Gem Factories =
5
5
  # =================
6
6
  factory :post, class: Blogit::Post do
7
- title "Tis is a blog post title"
8
- body "This is the body of the blog post - you'll see it's a lot bigger than the title"
7
+ title "This is a blog post title"
8
+ description "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."
9
+ body "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.\
10
+
11
+ 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.\
12
+
13
+ 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."
9
14
  state "draft"
10
15
  association :blogger, :factory => :user
11
- factory :published_post do
16
+ trait :active do
12
17
  state "published"
13
18
  end
14
19
  end
15
20
 
16
21
  factory :comment, class: Blogit::Comment do
17
22
  name "Gavin"
18
- email "gavin@gavinmorrice.com"
19
- website "http://gavinmorrice.com"
23
+ email "bodacious@katanacode.com"
24
+ website "http://katanacode.com"
20
25
  body "I once saw a child the size of a tangerine!"
21
26
  post
22
27
  end
@@ -1,94 +1,31 @@
1
- require "spec_helper"
1
+ require "rails_helper"
2
2
 
3
3
  describe Blogit::ApplicationHelper do
4
4
 
5
- describe :blog_tag do
6
- it "should create a tag element and give it a 'blog_post... prefixed class" do
7
- helper.blog_tag(:div, "hello", id: "blog_div", class: "other_class").should == %{<div class="other_class blog_post_div" id="blog_div">hello</div>}
8
- helper.blog_tag(:li, "hello", id: "blog_li").should == %{<li class="blog_post_li" id="blog_li">hello</li>}
9
- end
10
-
11
- it "should create a comment tag element when the comment type options is set" do
12
- helper.blog_tag(:div, "hello", id: "blog_div", type: "comment", class: "other_class").should == %{<div class="other_class blog_comment_div" id="blog_div">hello</div>}
13
- helper.blog_tag(:li, "hello", id: "blog_li", type: "status").should == %{<li class="blog_status_li" id="blog_li">hello</li>}
14
- end
15
- end
16
-
17
5
  describe "format_content" do
18
6
  it "should convert markdown text to html if conf is :markdown" do
19
7
  Blogit.configure { |c| c.default_parser = :markdown }
20
- helper.format_content("## Hello\n\nWorld").should match(/<h2>Hello<\/h2>\n\n<p>World<\/p>/)
8
+ expect(helper.format_content("## Hello\n\nWorld")).to match(/<h2>Hello<\/h2>\n\n<p>World<\/p>/)
21
9
  end
22
10
 
23
11
  it "should convert textile text to html if conf is :textile" do
24
12
  Blogit.configure { |c| c.default_parser = :textile }
25
- helper.format_content("h1. Hello\n\nWorld").should == "<h1>Hello</h1>\n<p>World</p>"
13
+ expect(helper.format_content("h1. Hello\n\nWorld")).to eq("<h1>Hello</h1>\n<p>World</p>")
26
14
  end
27
15
 
28
- it "should convert html text to html if conf is :html" do
16
+ it "should leave html text as html if conf is :html" do
29
17
  Blogit.configure { |c| c.default_parser = :html }
30
- helper.format_content("<h1>Hello</h1>\n\n<p>World</p>").should == "<h1>Hello</h1>\n\n<p>World</p>"
18
+ string = "<h1>Hello</h1>\n\n<p>World</p>"
19
+ expect(helper.format_content(string)).to eq(string)
31
20
  end
32
21
  end
33
22
 
34
- describe :actions do
23
+ describe "actions" do
35
24
  it "should create a div with class 'actions'" do
36
- helper.actions do
25
+ expect(helper.actions do
37
26
  "hello"
38
- end.should == %{<div class="actions">hello</div>}
27
+ end).to eq(%{<div class="actions">hello</div>})
39
28
  end
40
29
  end
41
30
 
42
- describe "main app's named routes" do
43
- # rspec generates a helper by mixin in the tested helper and the application
44
- # helper. But this is not what is being done by rails inside an engine.
45
- # This mockery is more like the real thing
46
- class MainAppApplicationHelperBench
47
- def dummy_thing_path
48
- "/dummy_thing"
49
- end
50
- def dummy_thing_url
51
- "http://host/dummy_thing"
52
- end
53
- def secret
54
- end
55
- end
56
- class BlogitApplicationHelperBench
57
- include Blogit::ApplicationHelper
58
-
59
- def main_app
60
- MainAppApplicationHelperBench.new
61
- end
62
- end
63
-
64
- let(:raw_helper) { BlogitApplicationHelperBench.new }
65
-
66
- it "should not know named routes of the main app if not configured" do
67
- Blogit.configure {|c| c.inline_main_app_named_routes = false }
68
-
69
- lambda { raw_helper.dummy_thing_path }.should raise_error(NoMethodError)
70
- lambda { raw_helper.dummy_thing_url }.should raise_error(NoMethodError)
71
- end
72
-
73
- it "should know named routes of the main app" do
74
- Blogit.configure {|c| c.inline_main_app_named_routes = true }
75
-
76
- raw_helper.dummy_thing_path.should == "/dummy_thing"
77
- raw_helper.dummy_thing_url.should == "http://host/dummy_thing"
78
- end
79
-
80
- it "should not know anything but named routes of the main app" do
81
- Blogit.configure {|c| c.inline_main_app_named_routes = true }
82
-
83
- lambda { raw_helper.secret }.should raise_error(NoMethodError)
84
- end
85
-
86
- it "should not know other routes" do
87
- Blogit.configure {|c| c.inline_main_app_named_routes = true }
88
-
89
- lambda { raw_helper.junk_path }.should raise_error(NoMethodError)
90
- lambda { raw_helper.junk_url }.should raise_error(NoMethodError)
91
- end
92
-
93
- end
94
- end
31
+ end
@@ -1,9 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
- require "spec_helper"
2
+ require "rails_helper"
3
3
 
4
4
  describe Blogit::PostsHelper do
5
5
 
6
- describe :comments_for do
6
+ describe "comments_for_post" do
7
7
  let(:post) { FactoryGirl.create :post }
8
8
 
9
9
  it "should be empty if comments are not configured" do
@@ -11,7 +11,7 @@ describe Blogit::PostsHelper do
11
11
  config.include_comments = :no
12
12
  end
13
13
 
14
- helper.comments_for(post).should == ""
14
+ expect(helper.comments_for_post(post)).to eq("")
15
15
  end
16
16
 
17
17
  it "should be full html when comments use active record" do
@@ -21,12 +21,12 @@ describe Blogit::PostsHelper do
21
21
 
22
22
  comment = Blogit::Comment.new
23
23
  Blogit::Comment.expects(:new).returns(comment)
24
- helper.expects(:render).with(partial: "blogit/posts/active_record_comments", locals: {post: post, comment: comment})
25
- helper.comments_for(post)
24
+ helper.expects(:render).with(partial: "blogit/comments/active_record_comments", locals: {post: post, comment: comment})
25
+ helper.comments_for_post(post)
26
26
  end
27
27
  end
28
28
 
29
- describe :share_bar_for do
29
+ describe "share_bar_for" do
30
30
  let(:post) { FactoryGirl.create :post }
31
31
 
32
32
  it "should be empty if not configured" do
@@ -34,7 +34,7 @@ describe Blogit::PostsHelper do
34
34
  config.include_share_bar = false
35
35
  end
36
36
 
37
- helper.share_bar_for(post).should == ""
37
+ expect(helper.share_bar_for_post(post)).to eq("")
38
38
  end
39
39
 
40
40
  it "should render a share bar if configured" do
@@ -43,62 +43,7 @@ describe Blogit::PostsHelper do
43
43
  end
44
44
 
45
45
  helper.expects(:render).with(partial: "blogit/posts/share_bar", locals: {post: post}).returns(share_bar_html='<div id="share-bar">...</div>')
46
- helper.share_bar_for(post).should == share_bar_html
47
- end
48
- end
49
-
50
- describe :blog_post_archive do
51
-
52
- before :each do
53
- Post.delete_all
54
- end
55
- after :each do
56
- Post.delete_all
57
- end
58
-
59
- # TODO: Clean up this horrible spec
60
- it "should create an ul tag tree with years, monthes and articles" do
61
- july_2012_1 = FactoryGirl.create(:post, title: "Great Post 2", created_at: Time.new(2012,7,14))
62
- july_2012_2 = FactoryGirl.create(:post, title: "Great Post 3", created_at: Time.new(2012,7,28))
63
- dec_2011 = FactoryGirl.create(:post, title: "Great post 1", created_at: Time.new(2011, 12, 25))
64
- sept_2012 = FactoryGirl.create(:post, title: "Great Post 4", created_at: Time.new(2012,9, 3))
65
-
66
- year_css = "archive-years"
67
- month_css = "archive-month"
68
- post_css = "archive-post"
69
-
70
- archive_html = helper.blog_posts_archive_tag(year_css, month_css, post_css) {|post| post.title }
71
-
72
- archive_html.should == ["<ul class=\"#{year_css}\">",
73
- "<li><a data-blogit-click-to-toggle-children>2012</a>",
74
- "<ul class=\"#{month_css}\">",
75
- "<li><a data-blogit-click-to-toggle-children>September</a>",
76
- "<ul class=\"#{post_css}\">",
77
- "<li>#{link_to(sept_2012.title, blogit.post_path(sept_2012))}</li>",
78
- "</ul>",
79
- "</li>",
80
- "<li><a data-blogit-click-to-toggle-children>July</a>",
81
- "<ul class=\"#{post_css}\">",
82
- "<li>#{link_to(july_2012_2.title, blogit.post_path(july_2012_2))}</li>",
83
- "<li>#{link_to(july_2012_1.title, blogit.post_path(july_2012_1))}</li>",
84
- "</ul>",
85
- "</li>",
86
- "</ul>",
87
- "</li>",
88
- "<li><a data-blogit-click-to-toggle-children>2011</a>",
89
- "<ul class=\"#{month_css}\">",
90
- "<li><a data-blogit-click-to-toggle-children>December</a>",
91
- "<ul class=\"#{post_css}\">",
92
- "<li>#{link_to(dec_2011.title, blogit.post_path(dec_2011))}</li>",
93
- "</ul>",
94
- "</li>",
95
- "</ul>",
96
- "</li>",
97
- "</ul>"].join
98
- end
99
-
100
- it "should be a safe html string" do
101
- helper.blog_posts_archive_tag('y','m','p').should be_html_safe
46
+ expect(helper.share_bar_for_post(post)).to eq(share_bar_html)
102
47
  end
103
48
 
104
49
  end
@@ -0,0 +1,6 @@
1
+ class DummyArchiveable
2
+ attr_reader :published_at
3
+ def initialize(published_at = Time.now)
4
+ @published_at = published_at
5
+ end
6
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'blogit/archive'
3
+ require 'injectables/dummy_archiveable'
4
+
5
+ describe Blogit::Archive::List do
6
+
7
+ describe :to_partial_path do
8
+
9
+ let(:list) { Blogit::Archive::List.new([]) }
10
+
11
+ it "returns the class name as a path to partial" do
12
+ expect(list.to_partial_path).to eql("blogit/archive/list")
13
+ end
14
+
15
+ end
16
+
17
+ describe :years do
18
+
19
+ context "when archiveables is empty" do
20
+
21
+ let(:list) { Blogit::Archive::List.new([]) }
22
+
23
+ it "returns an empty array" do
24
+ expect(list.years).to be_empty
25
+ end
26
+
27
+ end
28
+
29
+ context "when archiveables contains valid archiveables" do
30
+
31
+ let(:list) {
32
+ Blogit::Archive::List.new([
33
+ DummyArchiveable.new(2.years.ago),
34
+ DummyArchiveable.new(2.years.ago),
35
+ DummyArchiveable.new(2.weeks.ago)
36
+ ])
37
+ }
38
+
39
+ it "returns an empty array" do
40
+ expect(list.years.size).to eql(2)
41
+ end
42
+
43
+ end
44
+
45
+ context "when archiveables doesn't contain valid archiveables" do
46
+
47
+ let(:list) {
48
+ Blogit::Archive::List.new([Object.new, Object.new])
49
+ }
50
+
51
+ it "raises an exception" do
52
+ expect { list.years }.to raise_error(Blogit::Archive::ArchiveError)
53
+ end
54
+
55
+ end
56
+
57
+
58
+ end
59
+
60
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'blogit/archive'
3
+ require 'injectables/dummy_archiveable'
4
+
5
+ describe Blogit::Archive::Month do
6
+
7
+ describe :to_partial_path do
8
+
9
+ let(:list) { Blogit::Archive::Month.new("June", []) }
10
+
11
+ it "returns the class name as a path to partial" do
12
+ expect(list.to_partial_path).to eql("blogit/archive/month")
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+ require 'blogit/archive'
3
+ require 'injectables/dummy_archiveable'
4
+
5
+ describe Blogit::Archive::Year do
6
+
7
+ describe :to_partial_path do
8
+
9
+ let(:list) { Blogit::Archive::Year.new(2015, []) }
10
+
11
+ it "returns the class name as a path to partial" do
12
+ expect(list.to_partial_path).to eql("blogit/archive/year")
13
+ end
14
+
15
+ end
16
+
17
+ describe :months do
18
+
19
+
20
+ context "when archiveables contains valid archiveables" do
21
+
22
+ let(:list) {
23
+ Blogit::Archive::Year.new("2015", [
24
+ DummyArchiveable.new(2.months.ago),
25
+ DummyArchiveable.new(2.months.ago),
26
+ DummyArchiveable.new(2.weeks.ago)
27
+ ])
28
+ }
29
+
30
+ it "returns an empty array" do
31
+ expect(list.months.size).to eql(2)
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -6,7 +6,7 @@ describe Blogit::Parsers::HtmlParser do
6
6
  let(:desired_output) { "<h2>Some textile</h2>\n<p>A paragraph</p>" }
7
7
 
8
8
  it "should return an html string of content passed when calling parsed" do
9
- parser.parsed.should == desired_output
9
+ expect(parser.parsed).to eq(desired_output)
10
10
  end
11
11
 
12
12
  end
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require "rails_helper"
2
2
 
3
3
  describe Blogit::Parsers::MarkdownParser do
4
4
 
@@ -6,7 +6,7 @@ describe Blogit::Parsers::MarkdownParser do
6
6
  let(:desired_output) { Regexp.new("<h2>Some textile</h2>\n\n<p>A paragraph</p>\n") }
7
7
 
8
8
  it "should return an html string of content passed when calling parsed" do
9
- parser.parsed.should =~ desired_output
9
+ expect(parser.parsed).to match(desired_output)
10
10
  end
11
11
 
12
12
  describe "code highlighting" do
@@ -16,7 +16,7 @@ describe Blogit::Parsers::MarkdownParser do
16
16
  }
17
17
 
18
18
  it "requires pymentize to run" do
19
- system("pygmentize > /dev/null").should equal(true), "It seems that pygmentize is not installed on your system"
19
+ expect(system("pygmentize > /dev/null")).to equal(true), "It seems that pygmentize is not installed on your system"
20
20
  end
21
21
 
22
22
  context "when highlight_code_syntax is true" do
@@ -28,13 +28,14 @@ describe Blogit::Parsers::MarkdownParser do
28
28
  it "should raise an exception if pygments isn't installed" do
29
29
  original_path = ENV['PATH']
30
30
  ENV['PATH'] = ""
31
- expect { parser.parsed }.to raise_error
31
+ expect { parser.parsed }.to raise_error(RuntimeError)
32
32
  ENV["PATH"] = original_path
33
33
  end
34
34
 
35
35
  it "should highlight code syntax" do
36
- parser.parsed.should =~
36
+ expect(parser.parsed).to match(
37
37
  Regexp.new("<h2>Header</h2>\n<div class=\"highlight\"><pre><span class=\"nb\">puts</span> <span class=\"s1\">&#39;hello world&#39;</span>\n</pre>\n</div>\n")
38
+ )
38
39
  end
39
40
 
40
41
  end
@@ -53,7 +54,7 @@ describe Blogit::Parsers::MarkdownParser do
53
54
  end
54
55
 
55
56
  it "shoud not highlight code" do
56
- parser.parsed.should == "<h2>Header</h2>\n\n<pre><code class=\"ruby\">puts &#39;hello world&#39;\n</code></pre>\n"
57
+ expect(parser.parsed).to eq("<h2>Header</h2>\n\n<pre><code class=\"ruby\">puts &#39;hello world&#39;\n</code></pre>\n")
57
58
  end
58
59
 
59
60
  end
@@ -6,7 +6,7 @@ describe Blogit::Parsers::TextileParser do
6
6
  let(:desired_output) { "<h2>Some textile</h2>\n<p>A paragraph</p>" }
7
7
 
8
8
  it "should return an html string of content passed when calling parsed" do
9
- parser.parsed.should == desired_output
9
+ expect(parser.parsed).to eq(desired_output)
10
10
  end
11
11
 
12
12
  end
@@ -3,12 +3,12 @@ require "spec_helper"
3
3
  describe Blogit::Blogs do
4
4
 
5
5
  it "should be included in ActiveRecord::Base" do
6
- ActiveRecord::Base.included_modules.should include(Blogit::Blogs)
6
+ expect(ActiveRecord::Base.included_modules).to include(Blogit::Blogs)
7
7
  end
8
8
 
9
9
  describe :blogs do
10
10
  it "should be a class macro to AR Base" do
11
- ActiveRecord::Base.methods.should include(:blogs)
11
+ expect(ActiveRecord::Base.methods).to include(:blogs)
12
12
  end
13
13
 
14
14
  end