akki 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/features/archives.feature +8 -4
- data/features/articles.feature +4 -0
- data/features/pages.feature +10 -3
- data/features/step_definitions/steps.rb +21 -4
- data/lib/akki/application.rb +7 -6
- data/lib/akki/version.rb +1 -1
- data/spec/application_spec.rb +42 -2
- metadata +16 -24
- data/features/fixtures/views/archives.haml +0 -2
- data/features/fixtures/views/article.haml +0 -1
- data/features/fixtures/views/example-page.haml +0 -1
- data/features/fixtures/views/layout.haml +0 -5
data/features/archives.feature
CHANGED
@@ -19,11 +19,15 @@ Feature: Archives
|
|
19
19
|
title: Article 1
|
20
20
|
date: 2008/04/23
|
21
21
|
"""
|
22
|
-
And I have
|
22
|
+
And I have the page "archives.haml":
|
23
|
+
"""
|
24
|
+
- articles.each do |article|
|
25
|
+
%p= article.title
|
26
|
+
"""
|
23
27
|
When I visit "/archives"
|
24
28
|
Then I should see:
|
25
29
|
"""
|
26
|
-
|
27
|
-
|
28
|
-
|
30
|
+
<p>Article 1</p>
|
31
|
+
<p>Article 2</p>
|
32
|
+
<p>Article 3</p>
|
29
33
|
"""
|
data/features/articles.feature
CHANGED
data/features/pages.feature
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
Feature: Pages
|
2
2
|
In order to display custom pages
|
3
|
-
As a
|
3
|
+
As a blogger
|
4
4
|
I want to display custom pages
|
5
5
|
|
6
|
-
Scenario:
|
7
|
-
Given I have the page "example-page"
|
6
|
+
Scenario: Page
|
7
|
+
Given I have the page "example-page.haml":
|
8
|
+
"""
|
9
|
+
%p This is the example page
|
10
|
+
"""
|
8
11
|
When I visit "/example-page"
|
9
12
|
Then I should see:
|
10
13
|
"""
|
11
14
|
<p>This is the example page</p>
|
12
15
|
"""
|
16
|
+
|
17
|
+
Scenario: Page that doesn't exist
|
18
|
+
When I visit "/page-that-does-not-exist/"
|
19
|
+
Then I should see a 404 html status code
|
@@ -1,11 +1,16 @@
|
|
1
1
|
Before do
|
2
2
|
@articles_path = File.join(File.dirname(__FILE__), '..', '..', 'articles')
|
3
|
+
@views_path = File.join(File.dirname(__FILE__), '..', '..', 'views')
|
4
|
+
@pages_path = File.join(@views_path, 'pages')
|
3
5
|
FileUtils.mkdir_p(@articles_path)
|
4
|
-
|
6
|
+
FileUtils.mkdir_p(@views_path)
|
7
|
+
FileUtils.mkdir_p(@pages_path)
|
8
|
+
Akki::Application.set :reload_templates, true
|
5
9
|
end
|
6
10
|
|
7
11
|
After do
|
8
|
-
FileUtils.rm_rf @articles_path
|
12
|
+
FileUtils.rm_rf @articles_path
|
13
|
+
FileUtils.rm_rf @views_path
|
9
14
|
end
|
10
15
|
|
11
16
|
Given /^I have the article file "([^"]*)"$/ do |article_file, article_contents|
|
@@ -14,7 +19,18 @@ Given /^I have the article file "([^"]*)"$/ do |article_file, article_contents|
|
|
14
19
|
end
|
15
20
|
end
|
16
21
|
|
17
|
-
Given /^
|
22
|
+
Given /^the article view:$/ do |contents|
|
23
|
+
File.open(File.join(@views_path, "article.haml"), 'w') do |file|
|
24
|
+
file.write(contents)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Given /^I have the page "([^"]*)":$/ do |page, contents|
|
29
|
+
File.open(File.join(@pages_path, page), 'w') do |file|
|
30
|
+
file.write(contents)
|
31
|
+
end
|
32
|
+
page_name = File.basename(page, File.extname(page))
|
33
|
+
Akki::Application.set :pages, [page_name.to_sym]
|
18
34
|
end
|
19
35
|
|
20
36
|
Given /^I visit "([^"]*)"$/ do |url|
|
@@ -25,5 +41,6 @@ Then /^I should see:$/ do |content|
|
|
25
41
|
page.source.should include content
|
26
42
|
end
|
27
43
|
|
28
|
-
|
44
|
+
Then /^I should see a (\d+) html status code$/ do |status_code|
|
45
|
+
page.status_code.should == status_code.to_i
|
29
46
|
end
|
data/lib/akki/application.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
-
require 'yaml'
|
3
|
-
require 'ostruct'
|
4
2
|
require 'akki/article'
|
5
3
|
|
6
4
|
module Akki
|
7
5
|
class Application < Sinatra::Base
|
6
|
+
set :root, File.join(File.dirname(__FILE__), '..', '..')
|
7
|
+
|
8
|
+
get '/:page_name/?' do
|
9
|
+
page_name = params[:page_name].to_sym
|
10
|
+
pass unless settings.pages.include? page_name
|
11
|
+
haml :"pages/#{page_name}", :locals => { :articles => Article.all }
|
12
|
+
end
|
8
13
|
|
9
14
|
get "/:year/:month/:day/:slug/?" do
|
10
15
|
year = params[:year].to_i
|
@@ -14,9 +19,5 @@ module Akki
|
|
14
19
|
article = Article::find(year, month, day, slug)
|
15
20
|
haml :article, :locals => { :article => article }
|
16
21
|
end
|
17
|
-
|
18
|
-
get "/:page/?" do
|
19
|
-
haml params[:page].to_sym, :locals => { :articles => Article.all }
|
20
|
-
end
|
21
22
|
end
|
22
23
|
end
|
data/lib/akki/version.rb
CHANGED
data/spec/application_spec.rb
CHANGED
@@ -12,11 +12,19 @@ module Akki
|
|
12
12
|
|
13
13
|
before do
|
14
14
|
@views_path = File.join(File.dirname(__FILE__), '..', 'views')
|
15
|
+
@public_path = File.join(File.dirname(__FILE__), '..', 'public')
|
16
|
+
@pages_path = File.join(@views_path, 'pages')
|
15
17
|
FileUtils.mkdir_p @views_path
|
18
|
+
FileUtils.mkdir_p @public_path
|
19
|
+
FileUtils.mkdir_p @pages_path
|
20
|
+
|
21
|
+
@pages = mock :pages
|
22
|
+
@pages.stub!(:all).and_return []
|
16
23
|
end
|
17
24
|
|
18
25
|
after do
|
19
26
|
FileUtils.rm_rf @views_path
|
27
|
+
FileUtils.rm_rf @public_path
|
20
28
|
end
|
21
29
|
|
22
30
|
def create_view name, contents
|
@@ -25,6 +33,18 @@ module Akki
|
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
36
|
+
def create_public name, contents
|
37
|
+
File.open(File.join(@public_path, name), 'w') do |file|
|
38
|
+
file.write(contents)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_page name, contents
|
43
|
+
File.open(File.join(@pages_path, name), 'w') do |file|
|
44
|
+
file.write(contents)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
28
48
|
describe "GET /23/10/2011/simple-article" do
|
29
49
|
before do
|
30
50
|
@article = mock :article
|
@@ -54,8 +74,9 @@ module Akki
|
|
54
74
|
|
55
75
|
describe "GET /page_name" do
|
56
76
|
it "renders a custom page" do
|
77
|
+
Application.set :pages, [:page_name]
|
57
78
|
Article.stub!(:all).and_return []
|
58
|
-
|
79
|
+
create_page 'page_name.haml', 'this is my page!'
|
59
80
|
get '/page_name'
|
60
81
|
last_response.body.should include 'this is my page!'
|
61
82
|
end
|
@@ -67,11 +88,30 @@ module Akki
|
|
67
88
|
Article.new("article 1", nil, "article 1 content", "article1"),
|
68
89
|
Article.new("article 2", nil, "article 2 content", "article2")
|
69
90
|
])
|
70
|
-
|
91
|
+
|
92
|
+
@pages.stub!(:all).and_return ["archives"]
|
93
|
+
Application.set :pages, [:archives]
|
94
|
+
create_page 'archives.haml', "- articles.each do |a|\n %p= a.title"
|
95
|
+
Application.set :pages => [:archives]
|
71
96
|
get '/archives'
|
72
97
|
last_response.body.should include "article 1"
|
73
98
|
last_response.body.should include "article 2"
|
74
99
|
end
|
75
100
|
end
|
101
|
+
|
102
|
+
describe "GET page-that-does-not-exist" do
|
103
|
+
it "404s" do
|
104
|
+
get '/page-that-does-not-exist'
|
105
|
+
last_response.should be_not_found
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "GET file that exists in public folder" do
|
110
|
+
it "returns the file" do
|
111
|
+
create_public "main.css", "body { }"
|
112
|
+
get '/main.css'
|
113
|
+
last_response.body.should == "body { }"
|
114
|
+
end
|
115
|
+
end
|
76
116
|
end
|
77
117
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: akki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-20 00:00:00.000000000 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sinatra
|
17
|
-
requirement: &
|
17
|
+
requirement: &70187564151800 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70187564151800
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: haml
|
28
|
-
requirement: &
|
28
|
+
requirement: &70187564150840 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70187564150840
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rake
|
39
|
-
requirement: &
|
39
|
+
requirement: &70187564149840 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70187564149840
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rspec
|
50
|
-
requirement: &
|
50
|
+
requirement: &70187564148700 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70187564148700
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: cucumber
|
61
|
-
requirement: &
|
61
|
+
requirement: &70187564147380 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70187564147380
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: capybara
|
72
|
-
requirement: &
|
72
|
+
requirement: &70187564146080 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,7 +77,7 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70187564146080
|
81
81
|
description: ''
|
82
82
|
email:
|
83
83
|
- andrew.vos@gmail.com
|
@@ -94,10 +94,6 @@ files:
|
|
94
94
|
- config.ru
|
95
95
|
- features/archives.feature
|
96
96
|
- features/articles.feature
|
97
|
-
- features/fixtures/views/archives.haml
|
98
|
-
- features/fixtures/views/article.haml
|
99
|
-
- features/fixtures/views/example-page.haml
|
100
|
-
- features/fixtures/views/layout.haml
|
101
97
|
- features/pages.feature
|
102
98
|
- features/step_definitions/env.rb
|
103
99
|
- features/step_definitions/steps.rb
|
@@ -123,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
119
|
version: '0'
|
124
120
|
segments:
|
125
121
|
- 0
|
126
|
-
hash:
|
122
|
+
hash: 4232723760955487062
|
127
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
124
|
none: false
|
129
125
|
requirements:
|
@@ -132,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
128
|
version: '0'
|
133
129
|
segments:
|
134
130
|
- 0
|
135
|
-
hash:
|
131
|
+
hash: 4232723760955487062
|
136
132
|
requirements: []
|
137
133
|
rubyforge_project: akki
|
138
134
|
rubygems_version: 1.6.2
|
@@ -142,10 +138,6 @@ summary: ''
|
|
142
138
|
test_files:
|
143
139
|
- features/archives.feature
|
144
140
|
- features/articles.feature
|
145
|
-
- features/fixtures/views/archives.haml
|
146
|
-
- features/fixtures/views/article.haml
|
147
|
-
- features/fixtures/views/example-page.haml
|
148
|
-
- features/fixtures/views/layout.haml
|
149
141
|
- features/pages.feature
|
150
142
|
- features/step_definitions/env.rb
|
151
143
|
- features/step_definitions/steps.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
%div.article= article.render
|
@@ -1 +0,0 @@
|
|
1
|
-
%p This is the example page
|