Sha256: 34e0cb27b49ebdd5092ba8c56d21207f91ce131a1cb4c3d4b37db281a4a72187

Contents?: true

Size: 1.94 KB

Versions: 6

Compression:

Stored size: 1.94 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'jeckyl/errors'
require 'jeckyl'
require File.expand_path(File.dirname(__FILE__) + '/../test/test_configurator')

conf_path = File.expand_path(File.dirname(__FILE__) + '/../test/conf.d')

report_path = File.expand_path(File.dirname(__FILE__) + '/../test/reports')

describe "Jeckyl Config Checker" do

  # general tests

  it "should checkout a simple config" do
    conf_file = conf_path + '/jeckyl'
    rep_file = report_path + '/ok.txt'
    conf_ok = TestJeckyl.check_config(conf_file, rep_file)
    conf_ok.should be_true
    message = File.read(rep_file).chomp
    message.should == "No errors found in: #{conf_file}"
  end


  it "should complain if the config file does not exist" do
    conf_file = conf_path + "/never/likely/to/be/there"
    rep_file = report_path + '/not_ok.txt'
    conf_ok = TestJeckyl.check_config(conf_file, rep_file)
    conf_ok.should be_false
    message = File.read(rep_file).chomp
    message.should == "No such config file: #{conf_file}"
  end

  it "should return false if the config file has a syntax error" do
    conf_file = conf_path + "/syntax_error"
    rep_file = report_path + '/not_ok.txt'
    conf_ok = TestJeckyl.check_config(conf_file, rep_file)
    conf_ok.should be_false
    message = File.read(rep_file).chomp
    message.should match(/^compile error/)
  end

  it "should return false if the config file has an error" do
    conf_file = conf_path + "/not_a_bool"
    rep_file = report_path + '/not_ok.txt'
    conf_ok = TestJeckyl.check_config(conf_file, rep_file)
    conf_ok.should be_false
    message = File.read(rep_file).chomp
    message.should match(/^\[debug\]:/)
  end

  it "should fail if it cannot write to the report file" do
    conf_file = conf_path + "/jeckyl"
    rep_file = report_path + '/no_such_directory/ok.txt'
    lambda{conf_ok = TestJeckyl.check_config(conf_file, rep_file)}.should raise_error(Jeckyl::ReportFileError)
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jeckyl-0.3.7 spec/check_config_spec.rb
jeckyl-0.2.7 spec/check_config_spec.rb
jeckyl-0.2.5 spec/check_config_spec.rb
jeckyl-0.2.4 spec/check_config_spec.rb
jeckyl-0.2.3 spec/check_config_spec.rb
jeckyl-0.2.1 spec/check_config_spec.rb