Skip to content
Browse files

moving stuff around

  • Loading branch information...
1 parent 619fa9f commit 94db2688d414baf594d626ce35dc1f5aef25c647 @svenfuchs committed Mar 17, 2010
Showing with 310 additions and 204 deletions.
  1. +2 −0 .bundle/config
  2. +5 −0 Gemfile
  3. +1 −0 lib/slick.rb
  4. +2 −1 lib/slick/builder.rb
  5. +46 −0 lib/slick/builder/base.rb
  6. +13 −0 lib/slick/builder/blog.rb
  7. +1 −14 lib/slick/builder/content.rb
  8. +21 −20 lib/slick/builder/section.rb
  9. +0 −17 lib/slick/model.rb
  10. +35 −25 lib/slick/model/base.rb
  11. +0 −5 lib/slick/model/blog.rb
  12. +15 −2 lib/slick/model/content.rb
  13. +0 −6 lib/slick/model/page.rb
  14. +20 −18 lib/slick/model/section.rb
  15. +2 −1 lib/slick/views/blog/show.html.erb
  16. +2 −0 lib/slick/views/layouts/application.html.erb
  17. +3 −0 lib/slick/views/layouts/page.html.erb
  18. +1 −0 lib/slick/views/page/show.html.erb
  19. +4 −1 public/2010/3/15/ripper2_ruby__modify_and_recompile_your_ruby_code.html
  20. +4 −1 public/2010/3/15/using_ruby_1_9_ripper.html
  21. +4 −0 public/articles.html
  22. +4 −0 public/articles/articles_child.html
  23. +0 −1 public/articles_page.html
  24. +4 −0 public/contact.html
  25. +2 −0 public/index.html
  26. +4 −0 public/projects.html
  27. +4 −0 public/projects/i18n.html
  28. +22 −9 test/builder_test.rb
  29. 0 test/fixtures/home/{_posts → }/2009-07-05-ripper2ruby-modify-and-recompile-your-ruby-code.markdown
  30. 0 test/fixtures/home/{_posts → }/2009-07-05-using-ruby-1-9-ripper.markdown
  31. +2 −2 test/fixtures/home/articles.html
  32. +2 −2 test/fixtures/home/articles/child.html
  33. +1 −1 test/fixtures/home/projects/i18.html
  34. +10 −9 test/model/base_test.rb
  35. +12 −0 test/model/content_test.rb
  36. +54 −4 test/model/section_test.rb
  37. +0 −57 test/model_test.rb
  38. +6 −2 test/test_helper.rb
  39. +2 −6 test/view_test.rb
View
2 .bundle/config
@@ -0,0 +1,2 @@
+---
+BUNDLE_WITHOUT: ""
View
5 Gemfile
@@ -0,0 +1,5 @@
+source 'http://gemcutter.org'
+
+gem "rails", :git => "git://github.com/rails/rails.git"
+# gem "rails", '>=3.0.0beta1'
+
View
1 lib/slick.rb
@@ -1,3 +1,4 @@
+require 'active_support/core_ext/object/singleton_class'
require 'action_view'
module Slick
View
3 lib/slick/builder.rb
@@ -1,12 +1,13 @@
module Slick::Builder
+ autoload :Base, 'slick/builder/base'
autoload :Blog, 'slick/builder/blog'
autoload :Content, 'slick/builder/content'
autoload :Page, 'slick/builder/page'
autoload :Section, 'slick/builder/section'
class << self
def create(parent, object, data)
- const_get(object.class.name.split('::').last).new(data, parent)
+ const_get(object.type.camelize).new(data, parent)
end
end
end
View
46 lib/slick/builder/base.rb
@@ -0,0 +1,46 @@
+require 'fileutils'
+require 'abstract_controller'
+
+module Slick::Builder
+ class Base
+ class << self
+ def controller_path
+ name.split('::').last.underscore
+ end
+ end
+
+ include AbstractController::Layouts
+
+ self.view_paths = [File.expand_path('../../views', __FILE__)]
+ self.layout 'application'
+
+ protected
+
+ def document_root
+ @@document_root ||= File.expand_path('../../../../public', __FILE__)
+ end
+
+ def render(template, target)
+ write(target, super(:template => template, :layout => layout, :locals => data))
+ end
+
+ def write(file_name, html)
+ path = [document_root, path, file_name].compact.join('/')
+ FileUtils.mkdir_p(File.dirname(path))
+ File.open(path, 'w+') { |f| f.write(html) }
+ end
+
+ public
+
+ # TODO can this be made smarter in AbstractController::Layouts? doesn't even seem to be used anywhere?
+ def config
+ {}
+ end
+
+ # TODO can this be made smarter in AbstractController::Layouts? just pass it through for now
+ def response_body=(body)
+ body
+ end
+ end
+end
+
View
13 lib/slick/builder/blog.rb
@@ -1,5 +1,18 @@
module Slick::Builder
class Blog < Section
+ def build
+ super
+ build_contents
+ end
+
+ protected
+
+ def build_contents
+ section.contents.each do |content|
+ data.merge!(:content => content)
+ render("#{section.type}/show", "#{content.permalink}.html")
+ end
+ end
end
end
View
15 lib/slick/builder/content.rb
@@ -1,20 +1,7 @@
require 'fileutils'
module Slick::Builder
- class Content
- def view
- @@view ||= ActionView::Base.new([File.expand_path('../../views', __FILE__)])
- end
-
- def document_root
- @@document_root ||= File.expand_path('../../../../public', __FILE__)
- end
-
- def write(file_name, html)
- path = [document_root, path, file_name].compact.join('/')
- FileUtils.mkdir_p(File.dirname(path))
- File.open(path, 'w+') { |f| f.write(html) }
- end
+ class Content < Base
end
end
View
41 lib/slick/builder/section.rb
@@ -1,5 +1,5 @@
module Slick::Builder
- class Section < Content
+ class Section < Base
attr_reader :data, :site, :section, :parent
def initialize(data, parent = nil)
@@ -8,31 +8,32 @@ def initialize(data, parent = nil)
@site, @section = data.values_at(:site, :section)
end
- def root?
- parent.nil?
+ def build
+ build_index
+ build_children
end
- def path # TODO should be in the model, we don't have routing, so keep it simple
- root? ? 'index' : [parent.root? ? nil : parent.path, section.slug].compact.join('/')
- end
+ protected
- def build
- render_index
- section.contents.each { |content| render_content(content) }
- section.children.each { |child| Slick::Builder.create(self, child, data.merge(:section => child)).build }
- end
+ def build_index
+ render("#{section.type}/index", "#{path}.html")
+ end
- def render_index
- write("#{path}.html", render('index', data))
- end
+ def build_children
+ section.children.each { |child| Slick::Builder.create(self, child, data.merge(:section => child)).build }
+ end
- def render_content(content)
- write("#{content.permalink}.html", render('show', data.merge(:content => content)))
- end
+ def root?
+ parent.nil?
+ end
- def render(template, locals)
- view.render(:file => "#{section.type}/#{template}", :locals => locals)
- end
+ def path # TODO should be in the model, we don't have routing, so keep it simple
+ root? ? 'index' : [parent.root? ? nil : parent.path, section.slug].compact.join('/')
+ end
+
+ def layout
+ section.layout || :default
+ end
end
end
View
17 lib/slick/model.rb
@@ -7,21 +7,4 @@ module Slick::Model
autoload :Page, 'slick/model/page'
autoload :Section, 'slick/model/section'
autoload :Site, 'slick/model/site'
-
- TYPES = {
- '_articles' => Page,
- '_posts' => Blog
- }
-
- class << self
- def build(path)
- determine_type(path).new(path)
- end
-
- def determine_type(path)
- subdirs = Dir["#{path}/_*"].map { |path| File.basename(path) }
- subdirs.each { |subdir| type = TYPES[subdir] and return type }
- Page
- end
- end
end
View
60 lib/slick/model/base.rb
@@ -1,29 +1,37 @@
require 'pathname'
+require 'active_support/core_ext/module/delegation'
module Slick::Model
- class Base < Pathname
+ class Base
YAML_PREAMBLE = /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
+ attr_reader :path
attr_writer :attributes
+ delegate :basename, :extname, :file?, :directory?, :ctime, :mtime, :to => :path
+
+ def initialize(path)
+ @path = Pathname.new(path.to_s)
+ end
+
def attributes
@attributes ||= read
end
def type
- self.class.name.split('::').last.underscore
+ attributes[:type] || 'page'
end
- def slug # TODO
- title.underscore.gsub(/[\W]/, '_')
+ def layout
+ attributes[:layout]
end
- def title_from_path
- title = File.basename(self.to_s).gsub(extname, '').titleize
+ def slug # TODO
+ title.underscore.gsub(/[\W]/, '_')
end
def dirname
- directory? ? self : Pathname.new(self.to_s.gsub(extname, ''))
+ directory? ? path : Pathname.new(path.to_s.gsub(extname, ''))
end
alias :created_at :ctime
@@ -33,21 +41,6 @@ def published_at
attributes.key?(:published_at) ? attributes[:published_at] : ctime
end
- def read
- attributes = { :title => title_from_path }
- attributes.merge!(parse(::File.read(self.to_s).strip)) if file?
- attributes
- end
-
- def parse(content)
- parse_yaml_preamble(content).merge(:content => content)
- end
-
- def parse_yaml_preamble(content)
- content.gsub!(YAML_PREAMBLE, '')
- $1 ? YAML.load($1).symbolize_keys : {}
- end
-
def respond_to?(name)
attributes.key?(name)
end
@@ -56,8 +49,25 @@ def method_missing(name, *args, &block)
respond_to?(name) ? attributes[name] : super
end
- def inspect
- super.gsub(/>/, " #{attributes.inspect}")
- end
+ protected
+
+ def read
+ { :title => title_from_path }.tap do |attributes|
+ attributes.merge!(parse(::File.read(path.to_s).strip)) if file?
+ end
+ end
+
+ def title_from_path
+ title = File.basename(path.to_s).gsub(extname, '').titleize
+ end
+
+ def parse(content)
+ parse_yaml_preamble(content).merge(:content => content)
+ end
+
+ def parse_yaml_preamble(content)
+ content.gsub!(YAML_PREAMBLE, '')
+ $1 ? YAML.load($1).symbolize_keys : {}
+ end
end
end
View
5 lib/slick/model/blog.rb
@@ -1,5 +0,0 @@
-module Slick::Model
- class Blog < Section
- end
-end
-
View
17 lib/slick/model/content.rb
@@ -4,12 +4,25 @@
module Slick::Model
class Content < Base
+ PUBLISHED_AT_PATTERN = %r((?:^|\/)([\d]{4}[-_][\d]{2}[-_][\d]{2}))
+
def permalink # TODO
date = published_at
slug = title.underscore.gsub(/[\W]/, '_')
[date.year, date.month, date.day, slug].join('/')
end
- end
-end
+ protected
+ def read
+ attributes = super
+ attributes.merge(:published_at => published_at_from_filename) unless attributes.key?(:published_at)
+ attributes
+ end
+
+ def published_at_from_filename
+ basename.to_s =~ PUBLISHED_AT_PATTERN
+ Date.parse($1) rescue nil
+ end
+ end
+end
View
6 lib/slick/model/page.rb
@@ -1,6 +0,0 @@
-module Slick::Model
- class Page < Section
- end
-end
-
-
View
38 lib/slick/model/section.rb
@@ -1,35 +1,37 @@
module Slick::Model
class Section < Base
- attr_reader :children, :contents
-
def initialize(path)
super
end
- def type_dir?
- type_dir && File.directory?(type_dir)
+ def contents
+ @contents ||= type == 'blog' ? content_paths.map { |path| Content.new(path) } : []
end
- def type_dir
- (subdir = TYPES.invert[self.class]) ? dirname + subdir : nil
+ def children
+ @children ||= child_paths.map { |path| Section.new(path) }
end
- def contents
- @contents ||= Dir["#{type_dir}/**/*"].map { |path| Content.new(path) } if type_dir?
+ def read
+ super.merge(:type => determine_type)
end
- def children
- @children ||= child_paths.map { |path| Slick::Model.build(path) }
- end
+ protected
- def child_paths
- paths = Dir["#{dirname}/[^_]*"].sort.reverse
- paths.empty? ? [] : paths.inject([paths.shift]) do |paths, path|
- # i.e. skip articles/ if we already have articles.html
- paths.unshift path unless paths.first == path + File.extname(paths.first)
- paths
+ def content_paths
+ @content_paths ||= Dir["#{dirname.to_s}/*"].select { |path| path =~ Content::PUBLISHED_AT_PATTERN }
+ end
+
+ def child_paths
+ (Dir["#{dirname}/[^_]*"].sort.reverse - content_paths).inject([]) do |paths, path|
+ paths.unshift(path) unless paths.first && paths.first == path + File.extname(paths.first)
+ paths
+ end.compact
+ end
+
+ def determine_type
+ Dir["#{dirname.to_s}/*"].any? { |path| path =~ Content::PUBLISHED_AT_PATTERN } ? 'blog' : 'page'
end
- end
end
end
View
3 lib/slick/views/blog/show.html.erb
@@ -1 +1,2 @@
-<%= content.title %>
+Post: <%= content.title %>
+
View
2 lib/slick/views/layouts/application.html.erb
@@ -0,0 +1,2 @@
+application layout:
+<%= yield %>
View
3 lib/slick/views/layouts/page.html.erb
@@ -0,0 +1,3 @@
+page layout:
+<%= yield %>
+
View
1 lib/slick/views/page/show.html.erb
@@ -0,0 +1 @@
+Article: <%= content.title %>
View
5 public/2010/3/15/ripper2_ruby__modify_and_recompile_your_ruby_code.html
@@ -1 +1,4 @@
-Ripper2Ruby: modify and recompile your Ruby code
+application layout:
+Post: Ripper2Ruby: modify and recompile your Ruby code
+
+
View
5 public/2010/3/15/using_ruby_1_9_ripper.html
@@ -1 +1,4 @@
-Using Ruby 1.9 Ripper
+application layout:
+Post: Using Ruby 1.9 Ripper
+
+
View
4 public/articles.html
@@ -0,0 +1,4 @@
+page layout:
+Page: Articles
+
+
View
4 public/articles/articles_child.html
@@ -0,0 +1,4 @@
+page layout:
+Page: Articles Child
+
+
View
1 public/articles_page.html
@@ -1 +0,0 @@
-Page: Articles Page
View
4 public/contact.html
@@ -0,0 +1,4 @@
+page layout:
+Page: Contact
+
+
View
2 public/index.html
@@ -1 +1,3 @@
+application layout:
Home
+
View
4 public/projects.html
@@ -0,0 +1,4 @@
+page layout:
+Page: Projects
+
+
View
4 public/projects/i18n.html
@@ -0,0 +1,4 @@
+page layout:
+Page: I18n
+
+
View
31 test/builder_test.rb
@@ -1,36 +1,49 @@
require File.expand_path('../test_helper', __FILE__)
+require 'fileutils'
class BuilderTest < Test::Unit::TestCase
def setup
- @section = Slick::Model.build(HOME_DIR)
+ @section = Slick::Model::Section.new(HOME_DIR)
+ FileUtils.mkdir_p(PUBLIC_DIR)
+ end
+
+ def teardown
+ # FileUtils.rm_r(PUBLIC_DIR) rescue Errno::ENOENT
end
test 'path for a root section is index' do
root = Slick::Builder::Blog.new(:section => @section)
- assert_equal 'index', root.path
+ assert_equal 'index', root.send(:path)
end
test 'path for a nested section is its section slug' do
root = Slick::Builder::Blog.new(:section => @section)
nested = Slick::Builder::Blog.new({ :section => @section.children.last }, root)
- assert_equal 'projects', nested.path
+ assert_equal 'projects', nested.send(:path)
end
test "path for a nested nested section is its parent's section slug and sectin slug" do
root = Slick::Builder::Blog.new(:section => @section)
nested = Slick::Builder::Blog.new({ :section => @section.children.last }, root)
nested_nested = Slick::Builder::Blog.new({ :section => @section.children.last }, nested)
- assert_equal 'projects/projects', nested_nested.path
+ assert_equal 'projects/projects', nested_nested.send(:path)
end
test 'path for a root section article is its article slug' do
root = Slick::Builder::Blog.new(:section => @section.children.last)
nested = Slick::Builder::Blog.new({ :section => @section.children.last }, root)
- assert_equal 'projects', nested.path
+ assert_equal 'projects', nested.send(:path)
end
- # test 'foo' do
- # root = Slick::Builder::Blog.new(:section => @section)
- # root.build
- # end
+ test 'foo' do
+ root = Slick::Builder::Blog.new(:section => @section)
+ root.build
+ assert File.exists?(PUBLIC_DIR + '/index.html')
+ assert File.exists?(PUBLIC_DIR + '/articles.html')
+ assert File.exists?(PUBLIC_DIR + '/articles/articles_child.html')
+ # assert File.exists?(PUBLIC_DIR + '/articles/article_1.html')
+ assert File.exists?(PUBLIC_DIR + '/projects.html')
+ assert File.exists?(PUBLIC_DIR + '/projects/i18n.html')
+ assert File.exists?(PUBLIC_DIR + '/contact.html')
+ end
end
View
0 ...ify-and-recompile-your-ruby-code.markdown → ...ify-and-recompile-your-ruby-code.markdown
File renamed without changes.
View
0 ...2009-07-05-using-ruby-1-9-ripper.markdown → ...2009-07-05-using-ruby-1-9-ripper.markdown
File renamed without changes.
View
4 test/fixtures/home/articles.html
@@ -1,5 +1,5 @@
---
-title: "Articles Page"
+title: "Articles"
layout: page
---
-Articles Page Content
+Articles Content
View
4 test/fixtures/home/articles/child.html
@@ -1,5 +1,5 @@
---
-title: "Articles Child Page"
+title: "Articles Child"
---
-Articles Child Page Content
+Articles Child Content
View
2 test/fixtures/home/projects/i18.html
@@ -1,5 +1,5 @@
---
-title: "Project I18n"
+title: "I18n"
---
Project I18n Content
View
19 test/model/base_test.rb
@@ -2,26 +2,27 @@
class ModelBaseTest < Test::Unit::TestCase
def model(path)
- Slick::Model::Base.new(HOME_DIR + path)
- end
-
- def articles
- model('/articles.html')
+ Slick::Model::Base.new(path)
end
test "slug is the underscored title (so it can be used in urls)" do
- assert_equal 'articles_page', articles.slug
+ model = self.model(HOME_DIR + '/articles_page_foo_bar')
+ model.attributes[:title] = 'Articles Page foo Bar'
+ assert_equal 'articles_page_foo_bar', model.slug
end
test "title_from_path is the titleized filename's basename" do
- assert_equal 'Articles', articles.title_from_path
+ model = self.model(HOME_DIR + '/articles_page_foo_bar')
+ assert_equal 'Articles Page Foo Bar', model.send(:title_from_path)
end
test "read adds the file's yaml preamble to the attributes" do
- assert_equal 'page', articles.layout
+ model = self.model(HOME_DIR + '/articles.html')
+ assert_equal 'page', model.layout
end
test "read stores the file's main content to the content attribute" do
- assert_equal 'Articles Page Content', articles.content
+ model = self.model(HOME_DIR + '/articles.html')
+ assert_equal 'Articles Content', model.content
end
end
View
12 test/model/content_test.rb
@@ -0,0 +1,12 @@
+require File.expand_path('../../test_helper', __FILE__)
+
+class ModelContentTest < Test::Unit::TestCase
+ def content
+ end
+
+ test "published_at_from_file_name parses a date from the file's basename" do
+ content = Slick::Model::Content.new(HOME_DIR + '/_posts/2009-07-05-foo.html')
+ date = content.send(:published_at_from_filename)
+ assert_equal '2009-07-05', date.to_s
+ end
+end
View
58 test/model/section_test.rb
@@ -1,11 +1,61 @@
require File.expand_path('../../test_helper', __FILE__)
class ModelSectionTest < Test::Unit::TestCase
- include Slick
+ include Slick::Model
+
+ test 'determine_type returns Page for a page file' do
+ assert_equal 'page', Section.new(HOME_DIR + '/contact.html').send(:determine_type)
+ end
+
+ test 'determine_type returns Page for a page directory' do
+ assert_equal 'page', Section.new(HOME_DIR + '/projects').send(:determine_type)
+ end
+
+ test 'determine_type returns Blog for a blog directory' do
+ assert_equal 'blog', Section.new(HOME_DIR).send(:determine_type)
+ end
+
+ test 'building a Page from a page file' do
+ model = Section.new(HOME_DIR + '/contact.html')
+ assert_equal 'page', model.type
+ assert_equal 'page', model.layout
+ assert_equal 'http://github.com/svenfuchs', model.content
+ end
+
+ test 'building a Page from a page directory' do
+ model = Section.new(HOME_DIR + '/projects')
+ assert_equal 'page', model.type
+ assert_equal 'Projects', model.title
+
+ assert_equal 1, model.children.size
+ assert_equal 'I18n', model.children.first.title
+ end
+
+ test 'building a Page from a page directory and file' do
+ model = Section.new(HOME_DIR + '/articles.html')
+ assert_equal 'page', model.type
+ assert_equal 'Articles', model.title
+
+ assert_equal 1, model.children.size
+ assert_equal 'Articles Child', model.children.first.title
+ end
+
+ test 'building a Blog from the home directory' do
+ model = Section.new(HOME_DIR)
+ assert_equal 'blog', model.type
+
+ assert_equal 2, model.contents.size
+ assert_equal 'Ripper2Ruby: modify and recompile your Ruby code', model.contents.first.title
+
+ assert_equal 3, model.children.size
+ assert_equal 'Articles', model.children.first.title
+ assert_equal 1, model.children.first.children.size
+ end
test 'child_paths does not contain both a section dir and a section file but skips the section dir' do
- assert Model.build(HOME_DIR).child_paths.include?(HOME_DIR + '/articles.html')
- assert Model.build(HOME_DIR).child_paths.include?(HOME_DIR + '/projects')
- assert !Model.build(HOME_DIR).child_paths.include?(HOME_DIR + '/articles')
+ paths = Section.new(HOME_DIR).send(:child_paths)
+ assert paths.include?(HOME_DIR + '/projects')
+ assert paths.include?(HOME_DIR + '/articles.html')
+ assert !paths.include?(HOME_DIR + '/articles')
end
end
View
57 test/model_test.rb
@@ -1,57 +0,0 @@
-require File.expand_path('../test_helper', __FILE__)
-
-class ModelTest < Test::Unit::TestCase
- include Slick
-
- test 'determine_type returns Page for a page file' do
- assert_equal Model::Page, Model.determine_type(HOME_DIR + '/contact.html')
- end
-
- test 'determine_type returns Page for a page directory' do
- assert_equal Model::Page, Model.determine_type(HOME_DIR + '/projects')
- end
-
- test 'determine_type returns Blog for a blog directory' do
- assert_equal Model::Blog, Model.determine_type(HOME_DIR)
- end
-
- test 'building a Page from a page file' do
- model = Model.build(HOME_DIR + '/contact.html')
- assert_equal 'page', model.type
- assert_equal 'page', model.layout
- assert_equal 'http://github.com/svenfuchs', model.content
- end
-
- test 'building a Page from a page directory' do
- model = Model.build(HOME_DIR + '/projects')
- assert_equal 'page', model.type
- assert_equal 'Projects', model.title
-
- assert_equal 1, model.children.size
- assert_equal 'Project I18n', model.children.first.title
- end
-
- test 'building a Page from a page directory and file' do
- model = Model.build(HOME_DIR + '/articles.html')
- assert_equal 'page', model.type
- assert_equal 'Articles Page', model.title
-
- assert_equal 1, model.contents.size
- assert_equal 'Article 1', model.contents.first.title
-
- assert_equal 1, model.children.size
- assert_equal 'Articles Child Page', model.children.first.title
- end
-
- test 'building a Blog from the home directory' do
- model = Model.build(HOME_DIR)
- assert_equal 'blog', model.type
-
- assert_equal 2, model.contents.size
- assert_equal 'Ripper2Ruby: modify and recompile your Ruby code', model.contents.first.title
-
- assert_equal 3, model.children.size
- assert_equal 'Articles Page', model.children.first.title
- assert_equal 1, model.children.first.children.size
- end
-end
View
8 test/test_helper.rb
@@ -1,9 +1,13 @@
$: << File.expand_path('../../lib', __FILE__)
+require 'bundler'
+Bundler.setup
+
require 'test/unit'
require 'pp'
require 'slick'
require File.expand_path('../test_declarative.rb', __FILE__)
-HOME_DIR = File.expand_path('../fixtures/home', __FILE__)
-VIEWS_DIR = File.expand_path('../../lib/slick/views', __FILE__)
+HOME_DIR = File.expand_path('../fixtures/home', __FILE__)
+VIEWS_DIR = File.expand_path('../../lib/slick/views', __FILE__)
+PUBLIC_DIR = File.expand_path('../../public', __FILE__) # TODO move to config
View
8 test/view_test.rb
@@ -2,12 +2,8 @@
class ViewTest < Test::Unit::TestCase
test 'simple render' do
- section = Slick::Model::Blog.new('path/to/foo')
- section.attributes = {
- :title => 'da blog',
- # :children => [{ :title => 'a page'}],
- # :contents => [{ :title => 'a post' }]
- }
+ section = Slick::Model::Section.new('path/to/foo')
+ section.attributes = { :title => 'da blog' }
html = ActionView::Base.new([VIEWS_DIR]).render(:file => 'blog/index', :locals => { :section => section })
assert_match /#{section.title}/, html
end

0 comments on commit 94db268

Please sign in to comment.
Something went wrong with that request. Please try again.