Skip to content

Commit

Permalink
Use standard lib methods (#500)
Browse files Browse the repository at this point in the history
* Refactor GeneratorHelp#to_capitalized

* Remove GeneratorHelp#to_snake

Because:
It could be replace by String#underscore

* Replace GeneratorHelp#to_snake with String#underscore

* Replace uncaught #to_snake with #underscore

* Fix wrong replacement

* Restore GeneratorHelp#to_snake

Because:
space-age exercise still need it to pass the spec

* Revert space-age test_template changes

Because:
The spec failed after switched to String#underscore

* Remove snake_case from space-age

* Remove to_snake

---------

Co-authored-by: Ryan Hartlage <[email protected]>
  • Loading branch information
ls1955 and ryanplusplus authored Sep 30, 2023
1 parent 210e635 commit 0355eec
Show file tree
Hide file tree
Showing 51 changed files with 75 additions and 94 deletions.
21 changes: 1 addition & 20 deletions bin/generator_help.cr
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,8 @@ class GeneratorHelp
end
end

def to_snake(input)
result = ""
input.each_char do |x|
result += x.upcase == x ? "_#{x.downcase}" : x
end
result
end

def to_capitalized(input)
result = ""
input = input.capitalize
capitalized = false
input.each_char do |x|
if x == '-'
capitalized = true
else
result += capitalized ? x.upcase : x
capitalized = false
end
end
result
input.tr("-", "_").camelcase
end

def status
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/acronym/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require "../src/*"
describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%- @json["cases"].as_a.each do |cases| %>
<%= status()%> "<%-= cases["description"] %>" do
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>("<%= cases["input"]["phrase"].to_s %>").should eq("<%= cases["expected"].to_s %>")
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>("<%= cases["input"]["phrase"].to_s %>").should eq("<%= cases["expected"].to_s %>")
end
<% end %>
end
4 changes: 2 additions & 2 deletions exercises/practice/all-your-base/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
output_base = <%= cases["input"]["outputBase"] %>
<%- if cases["expected"].as_h? -%>
expect_raises(ArgumentError) do
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>(input_base, digits, output_base)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>(input_base, digits, output_base)
end
<%- else -%>
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>(input_base, digits, output_base).should eq(<%= cases["expected"] %> of Int32)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>(input_base, digits, output_base).should eq(<%= cases["expected"] %> of Int32)
<% end %>
end
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/allergies/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%- cases["cases"].as_a.each do |sub_case| %>
<%= status()%> "<%-= sub_case["description"] %>" do
<%- if sub_case["input"]["item"]? -%>
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(sub_case["property"].to_s)%>("<%= sub_case["input"]["item"] %>", <%= sub_case["input"]["score"] %>).should eq(<%= sub_case["expected"] %>)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= sub_case["property"].to_s.underscore %>("<%= sub_case["input"]["item"] %>", <%= sub_case["input"]["score"] %>).should eq(<%= sub_case["expected"] %>)
<%- else -%>
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(sub_case["property"].to_s)%>(<%= sub_case["input"]["score"] %>).should eq(<%= sub_case["expected"]? %> of String)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= sub_case["property"].to_s.underscore %>(<%= sub_case["input"]["score"] %>).should eq(<%= sub_case["expected"]? %> of String)
<% end %>
end
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/atbash-cipher/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%- @json["cases"].as_a.each do |cases| %>
<%- cases["cases"].as_a.each do |sub_case| %>
<%= status()%> "<%-= sub_case["description"] %>" do
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(sub_case["property"].to_s)%>("<%= sub_case["input"]["phrase"] %>").should eq("<%= sub_case["expected"]%>")
<%= to_capitalized(@json["exercise"].to_s) %>.<%= sub_case["property"].to_s.underscore %>("<%= sub_case["input"]["phrase"] %>").should eq("<%= sub_case["expected"]%>")
end
<% end %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/bank-account/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do

1000.times { Fiber.yield }
<%- elsif operations["operation"].to_s == "open" || operations["operation"].to_s == "close" -%>
bank_account.<%= to_snake(operations["operation"].to_s) %>
bank_account.<%= operations["operation"].to_s.underscore %>
<%- elsif operations["operation"].to_s == "deposit" || operations["operation"].to_s == "withdraw" -%>
bank_account.<%= to_snake(operations["operation"].to_s)%>(<%= operations["amount"] %>)
bank_account.<%= operations["operation"].to_s.underscore %>(<%= operations["amount"] %>)
<%- elsif operations["operation"].to_s == "balance" -%>
<% if cases["expected"].as_h? %>
expect_raises(ArgumentError) do
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/binary-search/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
value = <%= cases["input"]["value"] %>
<%- if cases["expected"].as_h? %>
expect_raises(ArgumentError) do
binary.<%= to_snake(cases["property"].to_s)%>(value)
binary.<%= cases["property"].to_s.underscore %>(value)
end
<%- else %>
binary.<%= to_snake(cases["property"].to_s)%>(value).should eq(<%= cases["expected"]%>)
binary.<%= cases["property"].to_s.underscore %>(value).should eq(<%= cases["expected"]%>)
<%- end %>
end
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/collatz-conjecture/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%= status()%> "<%-= cases["description"] %>" do
<%- if cases["expected"].as_h? %>
expect_raises(ArgumentError) do
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>(<%= cases["input"]["number"] %>)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>(<%= cases["input"]["number"] %>)
end
<%- else %>
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>(<%= cases["input"]["number"] %>).should eq(<%= cases["expected"]%>)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>(<%= cases["input"]["number"] %>).should eq(<%= cases["expected"]%>)
<%- end %>
end
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/darts/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require "../src/*"
describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%- @json["cases"].as_a.each do |cases| %>
<%= status()%> "<%-= cases["description"] %>" do
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>(<%= cases["input"]["x"].to_s.to_f %>, <%= cases["input"]["y"].to_s.to_f %>).should eq(<%= cases["expected"]%>)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>(<%= cases["input"]["x"].to_s.to_f %>, <%= cases["input"]["y"].to_s.to_f %>).should eq(<%= cases["expected"]%>)
end
<% end %>
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%- @json["cases"].as_a.each do |cases| %>
<%- cases["cases"].as_a.each do |sub_case| %>
<%= status()%> "<%-= sub_case["description"] %>" do
Squares.<%= to_snake(sub_case["property"].to_s)%>(<%= sub_case["input"]["number"] %>).should eq(<%= sub_case["expected"]%>)
Squares.<%= sub_case["property"].to_s.underscore %>(<%= sub_case["input"]["number"] %>).should eq(<%= sub_case["expected"]%>)
end
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/dominoes/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require "../src/*"
describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%- @json["cases"].as_a.each do |cases| %>
<%= status()%> "<%-= cases["description"] %>" do
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s) %>(<%= cases["input"]["dominoes"].inspect.gsub("[]", "[] of Array(Int32)") %>).should eq(<%= cases["expected"] %>)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>(<%= cases["input"]["dominoes"].inspect.gsub("[]", "[] of Array(Int32)") %>).should eq(<%= cases["expected"] %>)
end
<% end %>
end
2 changes: 1 addition & 1 deletion exercises/practice/etl/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%= status()%> "<%-= cases["description"] %>" do
input = <%= cases["input"]["legacy"].as_h%>
expected = <%= cases["expected"].as_h%>
<%= @json["exercise"].to_s.upcase %>.<%= to_snake(cases["property"].to_s)%>(input).should eq(expected)
<%= @json["exercise"].to_s.upcase %>.<%= cases["property"].to_s.underscore %>(input).should eq(expected)
end
<% end %>
end
4 changes: 2 additions & 2 deletions exercises/practice/flatten-array/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%- @json["cases"].as_a.each do |cases| %>
<%= status()%> "<%-= cases["description"] %>" do
<%- if cases["input"]["array"].to_s == "[[[]]]" %>
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>(Array(Array(Int32)).new).should eq(<%= cases["expected"].as_a %> of Int32)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>(Array(Array(Int32)).new).should eq(<%= cases["expected"].as_a %> of Int32)
<%- else %>
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>(<%= cases["input"]["array"].to_s == "[]" ? "[] of Int32 | Nil" : cases["input"]["array"].as_a %>).should eq(<%= cases["expected"].to_s == "[]" ? "[] of Int32" : cases["expected"].as_a %>)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>(<%= cases["input"]["array"].to_s == "[]" ? "[] of Int32 | Nil" : cases["input"]["array"].as_a %>).should eq(<%= cases["expected"].to_s == "[]" ? "[] of Int32" : cases["expected"].as_a %>)
<%- end %>
end
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/forth/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
result.should eq(<%= sub_case["expected"]? %>)
<%- elsif sub_case["expected"].as_h? -%>
expect_raises(ArgumentError) do
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(sub_case["property"].to_s)%>("<%= sub_case["input"]["instructions"].as_a.join("") %>")
<%= to_capitalized(@json["exercise"].to_s) %>.<%= sub_case["property"].to_s.underscore %>("<%= sub_case["input"]["instructions"].as_a.join("") %>")
end
<%- else -%>
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(sub_case["property"].to_s)%>("<%= sub_case["input"]["instructions"].as_a.join("") %>").should eq(<%= sub_case["expected"]? %> of Int32)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= sub_case["property"].to_s.underscore %>("<%= sub_case["input"]["instructions"].as_a.join("") %>").should eq(<%= sub_case["expected"]? %> of Int32)
<% end %>
end
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/hamming/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%= status()%> "<%-= cases["description"] %>" do
<%- if cases["expected"].as_h? %>
expect_raises(ArgumentError) do
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>("<%= cases["input"]["strand1"] %>", "<%= cases["input"]["strand2"] %>")
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>("<%= cases["input"]["strand1"] %>", "<%= cases["input"]["strand2"] %>")
end
<%- else %>
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>("<%= cases["input"]["strand1"] %>", "<%= cases["input"]["strand2"] %>").should eq(<%= cases["expected"] %>)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>("<%= cases["input"]["strand1"] %>", "<%= cases["input"]["strand2"] %>").should eq(<%= cases["expected"] %>)
<%- end %>
end
<% end %>
Expand Down
8 changes: 4 additions & 4 deletions exercises/practice/high-scores/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<% if subcases["property"].to_s.includes?("After") %>
high_scores = <%= to_capitalized(@json["exercise"].to_s)%>.new(<%= subcases["input"]["scores"]%>)
expected = <%= subcases["expected"]%>
high_scores.<%= subcases["property"].to_s.split("After")[1] == "Best" || subcases["property"].to_s.split("After")[1] == "TopThree" ? to_snake("personal" + subcases["property"].to_s.split("After")[1]) : subcases["property"].to_s.split("After")[1]%>()
high_scores.<%= to_snake(subcases["property"].to_s.split("After")[0])%>.should eq expected
high_scores.<%= subcases["property"].to_s.split("After")[1] == "Best" || subcases["property"].to_s.split("After")[1] == "TopThree" ? ("personal" + subcases["property"].to_s.split("After")[1]).underscore : subcases["property"].to_s.split("After")[1]%>()
high_scores.<%= subcases["property"].to_s.split("After")[0].underscore %>.should eq expected
<% else %>
high_scores = <%= to_capitalized(@json["exercise"].to_s)%>.new(<%= subcases["input"]["scores"]%>)
high_scores.<%= to_snake(subcases["property"].to_s)%>().should eq(<%= subcases["expected"]%>)
high_scores.<%= subcases["property"].to_s.underscore %>().should eq(<%= subcases["expected"]%>)
<% end %>
end
<% end %>
<%- else -%>
<%= status()%> "<%-= cases["description"] %>" do
high_scores = <%= to_capitalized(@json["exercise"].to_s)%>.new(<%= cases["input"]["scores"]%>)
high_scores.<%= to_snake(cases["property"].to_s)%>().should eq(<%= cases["expected"]%>)
high_scores.<%= cases["property"].to_s.underscore %>().should eq(<%= cases["expected"]%>)
end
<% end %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/knapsack/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ require "../src/*"
describe <%= to_capitalized(@json["exercise"].to_s).inspect %> do
<% @json["cases"].as_a.each do |cases| %>
<%= status()%> "<%-= cases["description"] %>" do
<%= to_snake(cases["property"].to_s) %> = <%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s) %>(<%= cases["input"]["maximumWeight"].inspect %>, <%= cases["input"]["items"].inspect.gsub("\"", "").gsub(" =>", ":").gsub("{", "\n{").gsub("\n{}", "[] of NamedTuple(weight: Int32, value: Int32)") %>)
<%= to_snake(cases["property"].to_s) %>.should eq(<%= cases["expected"].inspect %>)
<%= cases["property"].to_s.underscore %> = <%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>(<%= cases["input"]["maximumWeight"].inspect %>, <%= cases["input"]["items"].inspect.gsub("\"", "").gsub(" =>", ":").gsub("{", "\n{").gsub("\n{}", "[] of NamedTuple(weight: Int32, value: Int32)") %>)
<%= cases["property"].to_s.underscore %>.should eq(<%= cases["expected"].inspect %>)
end
<% end %>
end
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%- else -%>
series = <%= to_capitalized(@json["exercise"].to_s) %>.new("<%= cases["input"]["digits"] %>")
expect_raises(ArgumentError) do
series.<%= to_snake(cases["property"].to_s)%>(<%= cases["input"]["span"] %>)
series.<%= cases["property"].to_s.underscore %>(<%= cases["input"]["span"] %>)
<% end %>
end
<%- else -%>
series = <%= to_capitalized(@json["exercise"].to_s) %>.new("<%= cases["input"]["digits"] %>")
series.<%= to_snake(cases["property"].to_s)%>(<%= cases["input"]["span"] %>).should eq(<%= cases["expected"] %>)
series.<%= cases["property"].to_s.underscore %>(<%= cases["input"]["span"] %>).should eq(<%= cases["expected"] %>)
<% end %>
end
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/luhn/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end
describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%- @json["cases"].as_a.each do |cases| %>
<%= status()%> "<%-= cases["description"] %>" do
<%-= to_capitalized(@json["exercise"].to_s) %>.<%-= to_snake(cases["property"].to_s)%>?("<%= cases["input"]["value"] %>").should <%-= cases["expected"].as_bool ? "be_true" : "be_false" %>
<%-= to_capitalized(@json["exercise"].to_s) %>.<%-= cases["property"].to_s.underscore %>?("<%= cases["input"]["value"] %>").should <%-= cases["expected"].as_bool ? "be_true" : "be_false" %>
end
<% end %>
end
2 changes: 1 addition & 1 deletion exercises/practice/meetup/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require "../src/*"
describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%- @json["cases"].as_a.each do |cases| %>
<%= status()%> "<%-= cases["description"] %>" do
<%-= to_capitalized(@json["exercise"].to_s) %>.<%-= to_snake(cases["property"].to_s)%>(<%= cases["input"]["year"] %>, <%= cases["input"]["month"] %>, "<%= cases["input"]["week"] %>", "<%= cases["input"]["dayofweek"] %>").should eq("<%-= cases["expected"]%>")
<%-= to_capitalized(@json["exercise"].to_s) %>.<%-= cases["property"].to_s.underscore %>(<%= cases["input"]["year"] %>, <%= cases["input"]["month"] %>, "<%= cases["input"]["week"] %>", "<%= cases["input"]["dayofweek"] %>").should eq("<%-= cases["expected"]%>")
end
<% end %>
end
2 changes: 1 addition & 1 deletion exercises/practice/minesweeper/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%- @json["cases"].as_a.each do |cases| %>
<%= status()%> "<%-= cases["description"] %>" do
minesweeper = <%-= to_capitalized(@json["exercise"].to_s) %>.new(<%= cases["input"]["minefield"] %> of String)
minesweeper.<%-= to_snake(cases["property"].to_s)%>.should eq(<%-= cases["expected"].to_s.gsub("[]", "[] of String")%> )
minesweeper.<%-= cases["property"].to_s.underscore %>.should eq(<%-= cases["expected"].to_s.gsub("[]", "[] of String") %> )
end
<% end %>
end
4 changes: 2 additions & 2 deletions exercises/practice/nth-prime/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%= status()%> "<%-= cases["description"] %>" do
<%- if cases["expected"].as_h? %>
expect_raises(ArgumentError) do
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>(<%= cases["input"]["number"] %>)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>(<%= cases["input"]["number"] %>)
end
<%- else %>
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>(<%= cases["input"]["number"] %>).should eq(<%= cases["expected"]%>)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>(<%= cases["input"]["number"] %>).should eq(<%= cases["expected"]%>)
<%- end %>
end
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/nucleotide-count/.meta/test_template.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
<%= status()%> "<%-= cases["description"] %>" do
<%- if cases["expected"]["error"]? %>
expect_raises(ArgumentError) do
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>("<%= cases["input"]["strand"] %>")
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>("<%= cases["input"]["strand"] %>")
end
<%- else %>
input = "<%= cases["input"]["strand"] %>"
expected = {'A' => <%= cases["expected"]["A"] %>, 'C' => <%= cases["expected"]["C"] %>, 'G' => <%= cases["expected"]["G"] %>, 'T' => <%= cases["expected"]["T"] %>}
<%= to_capitalized(@json["exercise"].to_s) %>.<%= to_snake(cases["property"].to_s)%>(input).should eq(expected)
<%= to_capitalized(@json["exercise"].to_s) %>.<%= cases["property"].to_s.underscore %>(input).should eq(expected)
<%- end %>
end
<% end %>
Expand Down
Loading

0 comments on commit 0355eec

Please sign in to comment.