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
@@ -1,15 +1,15 @@
1
- require "spec_helper"
1
+ require "rails_helper"
2
2
 
3
3
  describe Blogit::Configuration do
4
4
 
5
5
  let(:blog_configuration) { @blog_configuration = Blogit::Configuration.new }
6
6
 
7
7
  it "should set :include_comments to :active_record" do
8
- blog_configuration.include_comments.should == :active_record
8
+ expect(blog_configuration.include_comments).to eq(:active_record)
9
9
  end
10
10
 
11
11
  it "should set :disqus_shortname to blank" do
12
- blog_configuration.disqus_shortname.should == ""
12
+ expect(blog_configuration.disqus_shortname).to be_nil
13
13
  end
14
14
 
15
15
  it "should print a warning to the console if disqus_shortname is set but include_comments is not disqus" do
@@ -18,71 +18,46 @@ describe Blogit::Configuration do
18
18
  blog_configuration.disqus_shortname = "bodacious"
19
19
  end
20
20
 
21
- it "should print a warning to the console if twitter_username is set but include_share_bar is false" do
22
- blog_configuration.expects(:warn)
23
- blog_configuration.include_share_bar = false
24
- blog_configuration.twitter_username = "bodacious"
25
- end
26
-
27
21
  it "should set :include_share_bar to false" do
28
- blog_configuration.include_share_bar.should == false
22
+ expect(blog_configuration.include_share_bar).to eq(true)
29
23
  end
30
24
 
31
25
  it "should set :twitter_username to blank" do
32
- blog_configuration.twitter_username.should == ""
26
+ expect(blog_configuration.twitter_username).to be_nil
33
27
  end
34
28
 
35
29
  it "should set :current_blogger_method to :current_user" do
36
- blog_configuration.current_blogger_method.should eql(:current_user)
30
+ expect(blog_configuration.current_blogger_method).to eql(:current_user)
37
31
  end
38
32
 
39
33
  it "should set :blogger_display_name_method to :username" do
40
- blog_configuration.blogger_display_name_method.should eql(:username)
34
+ expect(blog_configuration.blogger_display_name_method).to eql(:username)
41
35
  end
42
36
 
43
37
  it "should set :posts_per_page to 5" do
44
- blog_configuration.posts_per_page.should eql(5)
38
+ expect(blog_configuration.posts_per_page).to eql(5)
45
39
  end
46
40
 
47
- it "should set :authentication_method to :login_required" do
48
- blog_configuration.authentication_method.should == :login_required
49
- end
50
41
 
51
42
  it "should set datetime format to :short" do
52
- blog_configuration.datetime_format.should == :short
53
- end
54
-
55
- it "should set author_edits_only to false" do
56
- blog_configuration.author_edits_only.should be_false
43
+ expect(blog_configuration.datetime_format).to eq(:short)
57
44
  end
58
45
 
59
46
  it "should set ajax comments to true" do
60
- blog_configuration.ajax_comments.should be_true
61
- end
62
-
63
- it "should set include admin actions to true" do
64
- blog_configuration.include_admin_actions.should be_true
65
- end
66
-
67
- it "should set include admin links to true" do
68
- blog_configuration.include_admin_links.should be_true
69
- end
70
-
71
- it "should set page caching to false by default" do
72
- blog_configuration.cache_pages.should be_false
47
+ expect(blog_configuration.ajax_comments).to be_truthy
73
48
  end
74
49
 
75
50
  it "should set default_parser to :markdown" do
76
- blog_configuration.default_parser.should eql(:markdown)
51
+ expect(blog_configuration.default_parser).to eql(:markdown)
77
52
  end
78
53
 
79
54
  it "should return default_parser as class with default_parser_class" do
80
55
  blog_configuration.default_parser = :textile
81
- blog_configuration.default_parser_class.should eql(Blogit::Parsers::TextileParser)
56
+ expect(blog_configuration.default_parser_class).to eql(Blogit::Parsers::TextileParser)
82
57
  end
83
58
 
84
59
  it "should set redcarpet default options" do
85
- blog_configuration.redcarpet_options.should ==
60
+ expect(blog_configuration.redcarpet_options).to eq(
86
61
  {
87
62
  hard_wrap: true,
88
63
  filter_html: true,
@@ -91,38 +66,35 @@ describe Blogit::Configuration do
91
66
  fenced_code_blocks: true,
92
67
  gh_blockcode: true
93
68
  }
94
- end
95
-
96
- it "should set the Pingr mode to :test unless Rails env is production" do
97
- Pingr.mode.should eql(:test)
69
+ )
98
70
  end
99
71
 
100
72
  it "should set highlight_code_syntax to true" do
101
- blog_configuration.highlight_code_syntax.should be_true
73
+ expect(blog_configuration.highlight_code_syntax).to be_truthy
102
74
  end
103
75
 
104
76
  it "should set rss_feed_title to 'Rails engine name Blog Posts'" do
105
- blog_configuration.rss_feed_title.should eql "#{Rails.application.engine_name.titleize} Blog Posts"
77
+ expect(blog_configuration.rss_feed_title).to eql "Dummy Application Blog Posts"
106
78
  end
107
79
 
108
80
  it "should set rss_feed_description to 'Rails engine name Blog Posts'" do
109
- blog_configuration.rss_feed_description.should eql "#{Rails.application.engine_name.titleize} Blog Posts"
81
+ expect(blog_configuration.rss_feed_description).to eql "Latest from Dummy Application"
110
82
  end
111
83
 
112
84
  it "should set layout to nil by default" do
113
- blog_configuration.layout.should be_nil
85
+ expect(blog_configuration.layout).to be_nil
114
86
  end
115
87
 
116
88
  it "should allow layout to be set to a string" do
117
- lambda { blog_configuration.layout = "custom" }.should_not raise_error
89
+ expect { blog_configuration.layout = "custom" }.not_to raise_error
118
90
  end
119
91
 
120
92
  it 'should set active_states default options' do
121
- blog_configuration.active_states.should eql([:published])
93
+ expect(blog_configuration.active_states).to eql([:published])
122
94
  end
123
95
 
124
96
  it 'should set hidden_states default options' do
125
- blog_configuration.hidden_states.should eql([:draft, :archive])
97
+ expect(blog_configuration.hidden_states).to eql([:draft, :archive])
126
98
  end
127
99
 
128
100
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  describe Comment do
4
4
 
@@ -9,54 +9,54 @@ describe Comment do
9
9
  # nickname is a honey-pot
10
10
  it "has a value for nickname" do
11
11
  comment.nickname = "Gavin"
12
- comment.should_not be_valid
13
- comment.should have(1).error_on(:nickname)
12
+ expect(comment).not_to be_valid
13
+ expect(comment.errors[:nickname].size).to eq(1)
14
14
  end
15
15
 
16
16
  it "doesn't have a value for name" do
17
17
  comment.name = ""
18
- comment.should_not be_valid
19
- comment.should have(1).error_on(:name)
18
+ expect(comment).not_to be_valid
19
+ expect(comment.errors[:name].size).to eq(1)
20
20
  end
21
21
 
22
22
  it "doesn't have a value for email" do
23
23
  comment.email = ""
24
- comment.should_not be_valid
25
- comment.should have(1).error_on(:email)
24
+ expect(comment).not_to be_valid
25
+ expect(comment.errors[:email].size).to eql(1)
26
26
  end
27
27
 
28
28
  it "doesn't have a valid email" do
29
29
  comment.email = "notvalid.com"
30
- comment.should_not be_valid
31
- comment.should have(1).error_on(:email)
30
+ expect(comment).not_to be_valid
31
+ expect(comment.errors[:email].size).to eql(1)
32
32
 
33
33
  # has a space
34
34
  comment.email = "something else"
35
- comment.should_not be_valid
36
- comment.should have(1).error_on(:email)
35
+ expect(comment).not_to be_valid
36
+ expect(comment.errors[:email].size).to eql(1)
37
37
 
38
38
  # Has two @s
39
39
  comment.email = "gavin@gavin@notvalid.com"
40
- comment.should_not be_valid
41
- comment.should have(1).error_on(:email)
40
+ expect(comment).not_to be_valid
41
+ expect(comment.errors[:email].size).to eq(1)
42
42
  end
43
43
 
44
44
  it "doesn't have a value for body" do
45
45
  comment.body = ""
46
- comment.should_not be_valid
47
- comment.should have(1).error_on(:body)
46
+ expect(comment).not_to be_valid
47
+ expect(comment.errors[:body].size).to eq(1)
48
48
  end
49
49
 
50
50
  it "doesn't have at least 4 characters in the body" do
51
51
  comment.body = "abc"
52
- comment.should_not be_valid
53
- comment.should have(1).error_on(:body)
52
+ expect(comment).not_to be_valid
53
+ expect(comment.errors[:body].size).to eq(1)
54
54
  end
55
55
 
56
56
  it "doesn't have a valid website url" do
57
57
  comment.website = "not valid"
58
- comment.should_not be_valid
59
- comment.should have(1).error_on(:website)
58
+ expect(comment).not_to be_valid
59
+ expect(comment.errors[:website].size).to eq(1)
60
60
  end
61
61
 
62
62
  end
@@ -1,15 +1,16 @@
1
- require "spec_helper"
1
+ require "rails_helper"
2
2
 
3
3
  describe Blogit::Post do
4
4
 
5
5
  context "should not be valid" do
6
6
 
7
7
  context "if blogger" do
8
+
9
+ let(:blog_post) { Blogit::Post.new }
8
10
 
9
11
  it "is nil" do
10
- @blog_post = Blogit::Post.new
11
- @blog_post.should_not be_valid
12
- @blog_post.should have(1).error_on(:blogger_id)
12
+ expect(blog_post).not_to be_valid
13
+ expect(blog_post.errors[:blogger_id].size).to eq(1)
13
14
  end
14
15
 
15
16
  end
@@ -20,8 +21,8 @@ describe Blogit::Post do
20
21
  end
21
22
 
22
23
  after do
23
- @blog_post.should_not be_valid
24
- @blog_post.errors[:title].should_not be_blank
24
+ expect(@blog_post).not_to be_valid
25
+ expect(@blog_post.errors[:title]).not_to be_blank
25
26
  end
26
27
 
27
28
  it "is less than 10 characters" do
@@ -40,8 +41,8 @@ describe Blogit::Post do
40
41
  end
41
42
 
42
43
  after do
43
- @blog_post.should_not be_valid
44
- @blog_post.errors[:body].should_not be_blank
44
+ expect(@blog_post).not_to be_valid
45
+ expect(@blog_post.errors[:body]).not_to be_blank
45
46
  end
46
47
 
47
48
  it "is blank" do
@@ -59,8 +60,8 @@ describe Blogit::Post do
59
60
  before(:each) { @blog_post = Blogit::Post.new(state: nil) }
60
61
 
61
62
  it "is nil" do
62
- @blog_post.should_not be_valid
63
- @blog_post.should have(1).error_on(:state)
63
+ expect(@blog_post).not_to be_valid
64
+ expect(@blog_post.errors[:state].size).to eq(1)
64
65
  end
65
66
 
66
67
  end
@@ -68,7 +69,7 @@ describe Blogit::Post do
68
69
  end
69
70
 
70
71
  it "sets the first value of Blogit::configuration.hidden_states as default" do
71
- Blogit::Post.new.state.should eql(Blogit::configuration.hidden_states[0].to_s)
72
+ expect(Blogit::Post.new.state).to eql(Blogit::configuration.hidden_states[0].to_s)
72
73
  end
73
74
 
74
75
  context "with Blogit.configuration.comments == active_record" do
@@ -79,7 +80,7 @@ describe Blogit::Post do
79
80
  end
80
81
  User.blogs
81
82
  @blog_post = Blogit::Post.new
82
- lambda { @blog_post.comments }.should_not raise_exception
83
+ expect { @blog_post.comments }.not_to raise_exception
83
84
  end
84
85
 
85
86
  end
@@ -94,21 +95,21 @@ describe Blogit::Post do
94
95
 
95
96
  it "should return the display name of the blogger if set" do
96
97
  @post = user.blog_posts.build
97
- @post.blogger_display_name.should == "Jeronimo"
98
+ expect(@post.blogger_display_name).to eq("Jeronimo")
98
99
  Blogit.configuration.blogger_display_name_method = :password
99
- @post.blogger_display_name.should == "password"
100
+ expect(@post.blogger_display_name).to eq("password")
100
101
  end
101
102
 
102
103
  it "should return an empty string if blogger doesn't exist" do
103
104
  Blogit.configuration.blogger_display_name_method = :username
104
105
  @post = Blogit::Post.new
105
- @post.blogger_display_name.should == ""
106
+ expect(@post.blogger_display_name).to eq("")
106
107
  end
107
108
 
108
109
  it "should raise an exception if blogger display_name method doesn't exist" do
109
110
  Blogit.configuration.blogger_display_name_method = :display_name
110
111
  @post = user.blog_posts.build
111
- lambda { @post.blogger_display_name }.should raise_exception(Blogit::ConfigurationError)
112
+ expect { @post.blogger_display_name }.to raise_exception(Blogit::ConfigurationError)
112
113
  end
113
114
 
114
115
  end
@@ -119,32 +120,33 @@ describe Blogit::Post do
119
120
 
120
121
  before :all do
121
122
  Blogit::Post.destroy_all
122
- 15.times { |i| create :post, created_at: i.days.ago }
123
+ 15.times { |i| create(:post, :active, created_at: i.days.ago) }
123
124
  end
124
125
 
125
126
  it "should order posts by created_at DESC" do
126
- Blogit::Post.for_index.first.should == Blogit::Post.order("created_at DESC").first
127
+ expect(Blogit::Post.for_index.first).to eq(Blogit::Post.order("created_at DESC").first)
127
128
  end
128
129
 
129
130
  it "should paginate posts in blocks of 5" do
130
- Blogit::Post.for_index.count.should == 5
131
+ expect(Blogit::Post.for_index.count).to eq(5)
131
132
  end
132
133
 
133
134
  it "should accept page no as an argument" do
134
- Blogit::Post.for_index(2).should == Blogit::Post.order("created_at DESC").offset(5).limit(5)
135
+ expect(Blogit::Post.for_index(2)).to eq(Blogit::Post.active.
136
+ order("created_at DESC").offset(5).limit(5))
135
137
  end
136
138
 
137
139
  it "should change the no of posts per page if paginates_per is set" do
138
140
  Blogit::Post.paginates_per 3
139
- Blogit::Post.for_index.count.should eql(3)
141
+ expect(Blogit::Post.for_index.count).to eql(3)
140
142
  end
141
143
 
142
144
  end
143
145
 
144
146
  describe :active do
145
147
  it 'should include only posts in active states blogit.config.active_states' do
146
- published_post = create(:published_post)
147
- Blogit::Post.active.should include (published_post)
148
+ published_post = create(:post, :active)
149
+ expect(Blogit::Post.active).to include (published_post)
148
150
  end
149
151
  end
150
152
  end
@@ -157,7 +159,7 @@ describe Blogit::Post do
157
159
  end
158
160
  User.blogs
159
161
  @blog_post = Blogit::Post.new
160
- lambda { @blog_post.comments }.should raise_exception(RuntimeError)
162
+ expect { @blog_post.comments }.to raise_exception(RuntimeError)
161
163
  end
162
164
 
163
165
  end
@@ -166,26 +168,59 @@ describe Blogit::Post do
166
168
  it "should not truncate a short body" do
167
169
  post = Blogit::Post.new(body: "short body")
168
170
 
169
- post.short_body.should == post.body
171
+ expect(post.short_body).to eq(post.body)
170
172
  end
171
173
 
172
174
  it "should not truncate a long body" do
173
175
  post = Blogit::Post.new(body: "t\n"*300)
174
176
 
175
- post.short_body.should == "t\n"*198 + "t..."
177
+ expect(post.short_body).to eq("t\n"*198 + "t...")
176
178
  end
177
179
 
178
180
  it "should not cut the body in the middle of an image declaration" do
179
181
  body = "some text\n"*35 + '"!http://www.images.com/blogit/P6876.thumb.jpg(Look at this)!\":http://www.images.com/blogit/P6976.jpb'
180
182
  post = Blogit::Post.new(body: body)
181
183
 
182
- post.short_body.should_not include('"!http://www.images.com')
184
+ expect(post.short_body).not_to include('"!http://www.images.com')
183
185
  end
184
186
  end
187
+
188
+ describe "blogger_twitter_username" do
189
+
190
+ let(:post) { build(:post) }
191
+
192
+ context "when the blogger responds to :twitter_username" do
193
+
194
+ before do
195
+ class << post.blogger
196
+ def twitter_username
197
+ "@gavin_morrice"
198
+ end
199
+ end
200
+ end
201
+
202
+ it "returns the blogger's twitter username" do
203
+ expect(post.blogger_twitter_username).to eql("@gavin_morrice")
204
+ end
205
+
206
+ end
207
+
208
+ context "when the blogger doesn't respond to :twitter_username" do
209
+
210
+ before do
211
+ Blogit.configuration.twitter_username = '@katana_code'
212
+ end
185
213
 
214
+ it "returns nil" do
215
+ expect(post.blogger_twitter_username).to be_nil
216
+ end
217
+
218
+ end
219
+ end
220
+
186
221
  describe 'AVAILABLE_STATUS' do
187
222
  it "returns all the statues in Blogit::configuration" do
188
- Blogit::Post::AVAILABLE_STATUS.should == (Blogit.configuration.hidden_states + Blogit.configuration.active_states)
223
+ expect(Blogit::Post::AVAILABLE_STATUS).to eq(Blogit.configuration.hidden_states + Blogit.configuration.active_states)
189
224
  end
190
225
 
191
226
  end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
4
+ ENV['RAILS_ENV'] ||= 'test'
5
+ ENV["DB"] ||= "sqlite"
6
+
7
+ require File.expand_path('../dummy/config/environment', __FILE__)
8
+
9
+ require 'rspec/rails'
10
+
11
+ require 'factory_girl'
12
+ require 'factories'
13
+
14
+ require 'support/authentication'
15
+ require 'support/helpers/css_matchers'
16
+
17
+ silence_stream STDOUT do
18
+ load "#{Rails.root}/db/schema.rb"
19
+ end if ENV["DB"] == "sqlite"
20
+
21
+
22
+ include Blogit
23
+
24
+ RSpec.configure do |config|
25
+ config.infer_spec_type_from_file_location!
26
+ config.include FactoryGirl::Syntax::Methods
27
+ end
28
+