Added initial test coverage

This commit is contained in:
Grégory Karékinian 2013-02-12 11:31:38 +01:00
parent fb9b6f8150
commit e18fba9456
6 changed files with 83 additions and 1 deletions

View File

@ -9,6 +9,7 @@ require 'rake/minify'
require 'time'
require 'yaml'
require 'octopress'
require 'rake/testtask'
### Configuring Octopress:
### Under _config/ you will find:
@ -525,3 +526,7 @@ task :list do
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}"
puts "(type rake -T for more detail)\n\n"
end
Rake::TestTask.new do |t|
t.pattern = "spec/**/*_spec.rb"
end

View File

@ -2,8 +2,10 @@ require 'yaml'
module Octopress
module Configuration
CONFIG_DIR = File.join(File.dirname(__FILE__), '../', '../' '_config')
def self.config_dir(*subdirs)
File.absolute_path(File.join(File.dirname(__FILE__), '../', '../' '_config', *subdirs))
File.absolute_path(File.join(CONFIG_DIR, *subdirs))
end
# Static: Reads the configuration of the specified file

View File

@ -0,0 +1,11 @@
---
# ------------------------------- #
# Classic Theme Configuration #
# ------------------------------- #
url: http://yoursite.com
title: My Octopress Blog
subtitle: A blogging framework for hackers.
author: Your Name
simple_search: http://google.com/search
description:

View File

@ -0,0 +1,11 @@
---
# ------------------------------- #
# Classic Theme Configuration #
# ------------------------------- #
url: http://yoursite.com
title: My Octopress Blog
subtitle: A blogging framework for hackers.
author: Your Name
simple_search: http://google.com/search
description:

11
spec/fixtures/override/site.yml vendored Normal file
View File

@ -0,0 +1,11 @@
---
# ------------------------------- #
# Classic Theme Configuration #
# ------------------------------- #
url: http://myownsite.com
title: My Octopress custom Blog
subtitle: "How did this get here? I'm not good with computers"
author: John Doe
simple_search: http://google.com/search
description:

View File

@ -0,0 +1,42 @@
require 'minitest/autorun'
require_relative '../../lib/octopress'
describe Octopress::Configuration do
describe '.read_configuration' do
subject do
Octopress::Configuration.read_configuration
end
describe "when no override" do
before do
Octopress::Configuration::CONFIG_DIR = File.join(File.dirname(__FILE__), '../', 'fixtures', 'no_override')
end
it "returns the default config with keys as symbols" do
expected_config = { :url => "http://yoursite.com",
:title => "My Octopress Blog",
:subtitle => "A blogging framework for hackers.",
:author => "Your Name",
:simple_search => "http://google.com/search",
:description => nil }
subject.must_equal expected_config
end
end
describe "when override" do
before do
Octopress::Configuration::CONFIG_DIR = File.join(File.dirname(__FILE__), '../', 'fixtures', 'override')
end
it "returns the default config with keys as symbols" do
expected_config = { :url => "http://myownsite.com",
:title => "My Octopress custom Blog",
:subtitle => "How did this get here? I'm not good with computers",
:author => "John Doe",
:simple_search => "http://google.com/search",
:description => nil }
subject.must_equal expected_config
end
end
end
end