documentation specs, beginning cleaner conversion

This commit is contained in:
Andy Meneely
2020-03-13 10:38:34 -04:00
parent 750cb40267
commit 76ef45cfa4
13 changed files with 154 additions and 50 deletions
+14
View File
@@ -0,0 +1,14 @@
require 'spec_helper'
require 'active_support'
require 'active_support/core_ext/string/inflections'
def documented_options(dsl_method)
rst = doc_dsl_rst dsl_method.to_s.underscore
options_rst = rst[/Options.+^+(.+)^+/m]
includes = options_rst.scan(/\.\. include:: \/args\/(.+)\.rst/).flatten
includes.each do |key|
options_rst.gsub!(".. include:: /args/#{key}.rst", doc_args_rst(key))
end
opts = options_rst.lines.select { |line| line.match? /^[a-z]/ }
opts.map { |o| o.strip.to_sym }
end
+18
View File
@@ -0,0 +1,18 @@
require 'spec_helper'
require_relative 'docs_helper'
describe 'docs spec helper' do
it 'gets all documented options for background' do
options = documented_options(:Background)
expect(options.sort).to eq(%i(color range))
end
it 'gets all documented options for grid' do
expected = %i(x y width height fill_color stroke_color stroke_width
stroke_strategy dash cap range layout)
options = documented_options(:Grid)
expect(options.sort).to eq(expected.sort)
end
end
+15
View File
@@ -0,0 +1,15 @@
require_relative 'docs_helper'
describe Squib::DSL do
context 'methods' do
Squib::DSL.constants.each do |m|
it "accepted params for #{m} are in the docs" do
accepted_params = Squib::DSL.const_get(m).accepted_params
expect(accepted_params).to eq(documented_options(m))
end
end
end
end
+8
View File
@@ -0,0 +1,8 @@
require 'spec_helper'
describe Squib::Deck do
context '#background' do
end
end
+6 -2
View File
@@ -62,8 +62,12 @@ def project_template(file)
"#{File.expand_path(File.dirname(__FILE__))}/../lib/squib/project_template/#{file}"
end
def doc(file)
"#{File.expand_path(File.dirname(__FILE__))}/../docs/#{file}"
def doc_dsl_rst(name)
File.read("#{File.expand_path(File.dirname(__FILE__))}/../docs/dsl/#{name}.rst")
end
def doc_args_rst(name)
File.read("#{File.expand_path(File.dirname(__FILE__))}/../docs/args/#{name}.rst")
end
def conf(file)