mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Hide special character mapping
This commit is contained in:
parent
625a331745
commit
10fc6c6a35
2 changed files with 36 additions and 36 deletions
|
@ -2,5 +2,38 @@ module Spectator
|
|||
module ContextDefinitions
|
||||
ALL = {} of Path => Object
|
||||
MAPPING = {} of String => Context
|
||||
|
||||
SPECIAL_CHARS = {
|
||||
'~' => "Tilde",
|
||||
'`' => "Tick",
|
||||
'!' => "Bang",
|
||||
'@' => "At",
|
||||
'#' => "Hash",
|
||||
'$' => "Dollar",
|
||||
'%' => "Percent",
|
||||
'^' => "Carret",
|
||||
'&' => "And",
|
||||
'*' => "Star",
|
||||
'(' => "LParen",
|
||||
')' => "RParen",
|
||||
'+' => "Plus",
|
||||
'=' => "Eq",
|
||||
'{' => "LBrace",
|
||||
'}' => "RBrace",
|
||||
'[' => "LBracket",
|
||||
']' => "RBracket",
|
||||
':' => "Colon",
|
||||
';' => "SColon",
|
||||
'<' => "Lt",
|
||||
'>' => "Gt",
|
||||
',' => "Comma",
|
||||
'.' => "Dot",
|
||||
'?' => "Question",
|
||||
'/' => "Slash",
|
||||
'"' => "DQuote",
|
||||
'|' => "Or",
|
||||
'\\' => "BSlash",
|
||||
'\'' => "SQuote"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,46 +3,13 @@ require "./example_group"
|
|||
module Spectator
|
||||
module DSL
|
||||
|
||||
SPECIAL_CHAR_MAPPING = {
|
||||
'~' => "Tilde",
|
||||
'`' => "Tick",
|
||||
'!' => "Bang",
|
||||
'@' => "At",
|
||||
'#' => "Hash",
|
||||
'$' => "Dollar",
|
||||
'%' => "Percent",
|
||||
'^' => "Carret",
|
||||
'&' => "And",
|
||||
'*' => "Star",
|
||||
'(' => "LParen",
|
||||
')' => "RParen",
|
||||
'+' => "Plus",
|
||||
'=' => "Eq",
|
||||
'{' => "LBrace",
|
||||
'}' => "RBrace",
|
||||
'[' => "LBracket",
|
||||
']' => "RBracket",
|
||||
':' => "Colon",
|
||||
';' => "SColon",
|
||||
'<' => "Lt",
|
||||
'>' => "Gt",
|
||||
',' => "Comma",
|
||||
'.' => "Dot",
|
||||
'?' => "Question",
|
||||
'/' => "Slash",
|
||||
'"' => "DQuote",
|
||||
'|' => "Or",
|
||||
'\\' => "BSlash",
|
||||
'\'' => "SQuote"
|
||||
}
|
||||
|
||||
macro describe(what, type = "Describe", &block)
|
||||
context({{what}}, {{type}}) {{block}}
|
||||
end
|
||||
|
||||
macro context(what, type = "Context", &block)
|
||||
{% parent_module = @type %}
|
||||
{% safe_name = what.id.stringify.chars.map { |c| SPECIAL_CHAR_MAPPING[c] || c }.join("").gsub(/\W+/, "_") %}
|
||||
{% safe_name = what.id.stringify.chars.map { |c| ::Spectator::ContextDefinitions::SPECIAL_CHARS[c] || c }.join("").gsub(/\W+/, "_") %}
|
||||
{% module_name = (type.id + safe_name.camelcase).id %}
|
||||
{% absolute_module_name = [parent_module, module_name].join("::").id %}
|
||||
{% what_arg = what.is_a?(StringLiteral) ? what : what.stringify %}
|
||||
|
@ -163,7 +130,7 @@ module Spectator
|
|||
|
||||
macro it(description, &block)
|
||||
{% parent_module = @type %}
|
||||
{% safe_name = description.id.stringify.chars.map { |c| SPECIAL_CHAR_MAPPING[c] || c }.join("").gsub(/\W+/, "_") %}
|
||||
{% safe_name = description.id.stringify.chars.map { |c| ::Spectator::ContextDefinitions::SPECIAL_CHARS[c] || c }.join("").gsub(/\W+/, "_") %}
|
||||
{% class_name = (safe_name.camelcase + "Example").id %}
|
||||
{% given_vars = ::Spectator::ContextDefinitions::ALL[parent_module.id][:given] %}
|
||||
{% var_names = given_vars.map { |v| v[:name] } %}
|
||||
|
|
Loading…
Reference in a new issue