test/toto_test.rb in toto-0.2.8 vs test/toto_test.rb in toto-0.3.0

- old
+ new

@@ -77,10 +77,34 @@ asserts("content type is set properly") { topic.content_type }.equals "application/xml" asserts("body should be valid xml") { topic.body }.includes_html("feed > entry" => /.+/) asserts("summary shouldn't be empty") { topic.body }.includes_html("summary" => /.{10,}/) end + context "GET to a repo name" do + setup do + class Toto::Repo + def readme() "#{self[:name]}'s README" end + end + end + + context "when the repo is in the :repos array" do + setup do + @config[:github] = {:user => "cloudhead", :repos => ['the-repo']} + @toto.get('/the-repo') + end + should("return the-repo's README") { topic.body }.includes("the-repo's README") + end + + context "when the repo is not in the :repos array" do + setup do + @config[:github] = {:user => "cloudhead", :repos => []} + @toto.get('/the-repo') + end + should("return a 404") { topic.status }.equals 404 + end + end + context "creating an article" do setup do @config[:markdown] = true @config[:date] = lambda {|t| "the time is #{t.strftime("%Y/%m/%d %H:%M")}" } @config[:summary] = {:length => 50} @@ -142,9 +166,20 @@ end should("create a valid summary") { topic.summary.size }.within 75..80 end end + end + + context "using Config#set with a hash" do + setup do + conf = Toto::Config.new({}) + conf.set(:summary, {:delim => /%/}) + conf + end + + should("set summary[:delim] to /%/") { topic[:summary][:delim].source }.equals "%" + should("leave the :max intact") { topic[:summary][:max] }.equals 150 end end