hackety_sling 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  script: "bundle exec rake"
2
2
  rvm:
3
3
  - 1.9.2
4
+ - 1.9.3
data/README.md CHANGED
@@ -24,7 +24,7 @@ class MySuperBlog < Sinatra::Base
24
24
 
25
25
 
26
26
  # Optional
27
- set :hackety_sling_posts_on_index
27
+ set :hackety_sling_posts_on_index, 2
28
28
 
29
29
  get '/other-sinatra-page/' do
30
30
  erubis :other_sinatra_page
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module HacketySling
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
5
5
  end
@@ -16,13 +16,13 @@ module Sinatra
16
16
  erb :index
17
17
  end
18
18
 
19
- app.get '/archive/' do
19
+ app.get '/archive/?' do
20
20
  @posts = Post.order_by(:date => :asc).all
21
21
  erb :post_list
22
22
  end
23
23
 
24
24
  %w(tags author).each do |attribute|
25
- app.get "/#{attribute}/:value/" do |value|
25
+ app.get "/#{attribute}/:value/?" do |value|
26
26
  @posts = Post.order_by(:date => :desc)
27
27
  @posts = @posts.where(attribute.to_sym.include => value).all
28
28
  erb :posts
@@ -30,18 +30,18 @@ module Sinatra
30
30
  end
31
31
 
32
32
  Post.all.each do |post|
33
- app.get post.permalink do
33
+ app.get "#{post.permalink}?" do
34
34
  @post = post
35
35
  erb :post
36
36
  end
37
37
  base_name = post.file_name_without_extension.sub(/^\d{4}-\d{2}-\d{2}-/, '')
38
- app.get "/#{base_name}/" do
38
+ app.get "/#{base_name}/?" do
39
39
  redirect post.permalink, 301
40
40
  end
41
41
  end
42
42
 
43
43
  ymd = [:year, :month, :day]
44
- app.get %r{^/(\d{4}/)(\d{2}/)?(\d{2}/)?$} do
44
+ app.get %r{^/(\d{4}/?)(\d{2}/?)?(\d{2}/?)?$} do
45
45
  selector_hash = {}
46
46
  params[:captures].each_with_index do |date_part, index|
47
47
  selector_hash[ymd[index]] = date_part.to_i unless date_part.nil?
@@ -23,95 +23,72 @@ describe TestApp do
23
23
  end
24
24
 
25
25
  describe 'when requesting the index path' do
26
- it 'should request the 2 most current posts by default' do
26
+ it 'displays the 2 most current posts by default' do
27
27
  get '/'
28
28
  assert last_response.ok?
29
- refute last_response.body.include? @post_titles[0]
30
- refute last_response.body.include? @post_titles[1]
31
- assert last_response.body.include? @post_titles[2]
32
- assert last_response.body.include? @post_titles[3]
29
+ assert_equal ['Test post 4', 'Test post 3'], post_titles
33
30
  end
34
31
 
35
- it 'the number of posts should be configurable' do
32
+ it 'the number of posts is configurable' do
36
33
  app.set :hackety_sling_posts_on_index, 3
37
34
  get '/'
35
+ app.set :hackety_sling_posts_on_index, 2 # set back to original value
38
36
  assert last_response.ok?
39
- refute last_response.body.include? @post_titles[0]
40
- assert last_response.body.include? @post_titles[1]
41
- assert last_response.body.include? @post_titles[2]
42
- assert last_response.body.include? @post_titles[3]
37
+ assert_equal ['Test post 4', 'Test post 3', 'Test post 2'], post_titles
43
38
  end
44
39
  end
45
40
 
46
41
  describe 'when requesting posts by time' do
47
- it 'should show all posts of one year' do
42
+ it 'shows all posts of one year' do
48
43
  get '/2010/'
49
44
  assert last_response.ok?
50
- assert last_response.body.include? @post_titles[0]
51
- assert last_response.body.include? @post_titles[1]
52
- assert last_response.body.include? @post_titles[2]
53
- refute last_response.body.include? @post_titles[3]
45
+ assert_equal ['Test post 3', 'Test post 2', 'Test post 1'], post_titles
54
46
  end
55
47
 
56
- it 'should show all posts of one month' do
48
+ it 'shows all posts of one month' do
57
49
  get '/2010/11/'
58
50
  assert last_response.ok?
59
- refute last_response.body.include? @post_titles[0]
60
- refute last_response.body.include? @post_titles[1]
61
- assert last_response.body.include? @post_titles[2]
62
- refute last_response.body.include? @post_titles[3]
51
+ assert_equal ['Test post 3'], post_titles
63
52
  end
64
53
 
65
- it 'should show all posts of one day' do
54
+ it 'shows all posts of one day' do
66
55
  get '/2010/08/10/'
67
56
  assert last_response.ok?
68
- refute last_response.body.include? @post_titles[0]
69
- assert last_response.body.include? @post_titles[1]
70
- refute last_response.body.include? @post_titles[2]
71
- refute last_response.body.include? @post_titles[3]
57
+ assert_equal ['Test post 2'], post_titles
72
58
  end
73
59
  end
74
60
 
75
61
  describe 'when requesting a certain blog post' do
76
- it 'should show the blog post' do
62
+ it 'shows the blog post' do
77
63
  get '/2010/11/13/test-post-3/'
78
64
  assert last_response.ok?
79
- refute last_response.body.include? @post_titles[0]
80
- refute last_response.body.include? @post_titles[1]
81
- assert last_response.body.include? @post_titles[2]
82
- refute last_response.body.include? @post_titles[3]
65
+ assert_equal ['Test post 3'], post_titles
83
66
  end
84
67
 
85
- it 'should redirect to the url with date if only the slug was given' do
68
+ it 'redirects to the url with date if only the slug was given' do
86
69
  get '/test-post-2/'
87
70
  assert_redirected_to '/2010/08/10/test-post-2/', 301
88
71
  end
89
72
  end
90
73
 
91
74
  describe 'when requesting posts by tag' do
92
- it 'should show all posts with a certain tag' do
75
+ it 'shows all posts with a certain tag' do
93
76
  get '/tags/ruby/'
94
77
  assert last_response.ok?
95
- assert last_response.body.include? @post_titles[0]
96
- assert last_response.body.include? @post_titles[1]
97
- refute last_response.body.include? @post_titles[2]
98
- refute last_response.body.include? @post_titles[3]
78
+ assert_equal ['Test post 2', 'Test post 1'], post_titles
99
79
  end
100
80
  end
101
81
 
102
82
  describe 'when requesting posts by author' do
103
- it 'should show all posts with a certain author' do
83
+ it 'shows all posts with a certain author' do
104
84
  get '/author/ralph/'
105
85
  assert last_response.ok?
106
- refute last_response.body.include? @post_titles[0]
107
- refute last_response.body.include? @post_titles[1]
108
- assert last_response.body.include? @post_titles[2]
109
- refute last_response.body.include? @post_titles[3]
86
+ assert_equal ['Test post 3'], post_titles
110
87
  end
111
88
  end
112
89
 
113
90
  describe 'when requesting the archive page' do
114
- it 'should respond to the archive path' do
91
+ it 'responds to the archive path' do
115
92
  get '/archive/'
116
93
  assert last_response.ok?
117
94
  @post_titles.each do |post_title|
@@ -121,7 +98,7 @@ describe TestApp do
121
98
  end
122
99
 
123
100
  describe 'the atom feed' do
124
- it 'should be generated ok' do
101
+ it 'is generated ok' do
125
102
  get '/atom.xml'
126
103
  assert last_response.ok?
127
104
  end
@@ -138,5 +115,8 @@ describe TestApp do
138
115
  assert status == last_response.status, status_msg
139
116
  assert (path == redirect_url || url(path) == redirect_url), location_msg
140
117
  end
141
- end
142
118
 
119
+ def post_titles
120
+ last_response.body.scan(/Test post \d/)
121
+ end
122
+ end
data/test/post_test.rb CHANGED
@@ -9,11 +9,11 @@ require 'sinatra/hackety_sling/post'
9
9
  include Sinatra::HacketySling
10
10
 
11
11
  describe Post do
12
- it 'should return the correct date permalink' do
12
+ it 'returns the correct date permalink' do
13
13
  assert_equal '/2010/08/09/', Post.order_by(:title => :asc).first.date_permalink
14
14
  end
15
15
 
16
- it 'should return the correct permalink' do
16
+ it 'returns the correct permalink' do
17
17
  assert_equal '/2010/08/09/test-post-1/', Post.order_by(:title => :asc).first.permalink
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hackety_sling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-20 00:00:00.000000000Z
12
+ date: 2011-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: document_mapper
16
- requirement: &70301858857940 !ruby/object:Gem::Requirement
16
+ requirement: &70227312894320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70301858857940
24
+ version_requirements: *70227312894320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: erubis
27
- requirement: &70301858857080 !ruby/object:Gem::Requirement
27
+ requirement: &70227312871760 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70301858857080
35
+ version_requirements: *70227312871760
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sinatra
38
- requirement: &70301858855940 !ruby/object:Gem::Requirement
38
+ requirement: &70227312868620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70301858855940
46
+ version_requirements: *70227312868620
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: ratom
49
- requirement: &70301858854820 !ruby/object:Gem::Requirement
49
+ requirement: &70227312865820 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70301858854820
57
+ version_requirements: *70227312865820
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rack-test
60
- requirement: &70301858852940 !ruby/object:Gem::Requirement
60
+ requirement: &70227312864580 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70301858852940
68
+ version_requirements: *70227312864580
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: RedCloth
71
- requirement: &70301858851920 !ruby/object:Gem::Requirement
71
+ requirement: &70227312863460 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70301858851920
79
+ version_requirements: *70227312863460
80
80
  description: A simple blog engine based on Sinatra and document_mapper
81
81
  email:
82
82
  - ralph@rvdh.de
@@ -118,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  segments:
120
120
  - 0
121
- hash: -4069875926690539564
121
+ hash: -3764646363990707626
122
122
  required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  none: false
124
124
  requirements:
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  segments:
129
129
  - 0
130
- hash: -4069875926690539564
130
+ hash: -3764646363990707626
131
131
  requirements: []
132
132
  rubyforge_project:
133
133
  rubygems_version: 1.8.10