Add support for dynamically generated blocks
A useful feature of RSpec/Ruby allows describe/context/it blocks to be dynamically generated, for example:
Spectator.describe "Foo" do
[1, 2, "foo"].each do |i|
it "turns #{i} into a string" do
expect(i.to_s).to be_a String
end
end
end
or
Spectator.describe "Bar" do
[1, 2, "foo"].each do |i|
context "with #{i}" do
let(input) { i }
it "turns it into a string" do
expect(input.to_s).to be_a String
end
end
end
end
Trying this with Spectator gives an error:
There was a problem expanding macro '_spectator_metadata'
Code in macro 'it'
4 | _spectator_metadata(__temp_46, :metadata, )
^
Called macro defined in lib/spectator/src/spectator/dsl/metadata.cr:6:13
6 | private macro _spectator_metadata(name, source, *tags, **metadata)
Which expanded to:
> 1 | private def self.__temp_46
^--------
Error: can't declare def dynamically
Is it feasible to add support for this feature?