Skip to content

Commit

Permalink
Add tests for :prefix & :error
Browse files Browse the repository at this point in the history
2 concerns:
    * I think :error is in a funny place, in it's own context and what not.
      I tried finding some other existing context that would work, but none of
      the preexisting contexts didn't really fit. So I made one.
    * The :prefix test currently fails, see issue cloudhead#38. If my expectations are
      wrong, then the test should reflect that. (It currently expects a
      leading slash to be prepended automatically when it isn't.)
  • Loading branch information
nogweii authored and Alexis Sellier committed Apr 11, 2010
1 parent eb87c79 commit e6c61c0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
3 changes: 0 additions & 3 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
TODO
====

- write tests for :error setting
- write tests for :prefix setting
25 changes: 25 additions & 0 deletions test/toto_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@ def readme() "#{self[:name]}'s README" end
should("create a valid summary") { topic.summary.size }.within 75..80
end
end

context "in a subdirectory" do
setup do
conf = Toto::Config.new({})
conf.set(:prefix, "blog")
Toto::Article.new({
:title => "Toto & The Wizard of Oz.",
:body => "#Chapter I\nhello, *stranger*."
}, conf)
end

should("be in the directory") { topic.path }.equals Date.today.strftime("/blog/%Y/%m/%d/toto-and-the-wizard-of-oz/")
end
end

context "using Config#set with a hash" do
Expand All @@ -209,6 +222,18 @@ def readme() "#{self[:name]}'s README" end
should("set the value to a proc") { topic[:to_html] }.respond_to :call
end

context "testing individual configuration parameters" do
context "generate error pages" do
setup do
conf = Toto::Config.new({})
conf.set(:error) {|code| "error code #{code}" }
conf
end

should("create an error page") { topic[:error].call(400) }.equals "error code 400"
end
end

context "extensions to the core Ruby library" do
should("respond to iso8601") { Date.today }.respond_to?(:iso8601)
end
Expand Down

0 comments on commit e6c61c0

Please sign in to comment.