mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add names for most common special characters
These names will be used instead of an underscore. This helps with naming.
This commit is contained in:
parent
95ec999bba
commit
284e10482a
1 changed files with 36 additions and 2 deletions
|
@ -2,12 +2,46 @@ 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)
|
||||
{% safe_name = what.id.stringify.gsub(/\W+/, "_") %}
|
||||
{% safe_name = what.id.stringify.chars.map { |c| SPECIAL_CHAR_MAPPING[c] || c }.join("").gsub(/\W+/, "_") %}
|
||||
{% module_name = (type.id + safe_name.camelcase).id %}
|
||||
{% context_module = CONTEXT_MODULE %}
|
||||
{% parent_given_vars = GIVEN_VARIABLES %}
|
||||
|
@ -37,7 +71,7 @@ module Spectator
|
|||
end
|
||||
|
||||
macro it(description, &block)
|
||||
{% safe_name = description.id.stringify.gsub(/\W+/, "_") %}
|
||||
{% safe_name = description.id.stringify.chars.map { |c| SPECIAL_CHAR_MAPPING[c] || c }.join("").gsub(/\W+/, "_") %}
|
||||
{% class_name = (safe_name.camelcase + "Example").id %}
|
||||
{% given_vars = GIVEN_VARIABLES %}
|
||||
{% var_names = given_vars.map { |v| v[0] } %}
|
||||
|
|
Loading…
Reference in a new issue