Last active
February 8, 2016 08:10
-
-
Save wolframkriesing/48921fbd1d0b06db584b to your computer and use it in GitHub Desktop.
rake DSL as it should be?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tasks are defined using the DSL like this `task :name ....` | |
# But for a task that execute tests I can only find this piece of code everywhere on the web | |
Rake::TestTask.new do |t| | |
t.libs << "test" | |
t.test_files = FileList['test/test*.rb'] | |
t.verbose = true | |
end | |
# should it not be something like this | |
task :test => [Rake::TestTask] do |t| | |
t.libs << "test" | |
t.test_files = FileList['test/test*.rb'] | |
t.verbose = true | |
end | |
# I would understand that. But the very different syntax used above doesn't stick in | |
# my head and somehow yells at me "I don't want to be part of the DSL, I want to be Ruby". | |
# extracted from https://github.com/wolframkriesing/wolfram.kriesing.de/blob/use-react/content/tech.md#understanding-rake-in-order-to-keep-on-reading-objects-on-rails |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mh the 2. seems more dsl like but implies a task is created that depends on the test task, which is not the case.
Rake is a very thin DSL and
task
is just a constructor method. It could look more DSL like thisBut not sure how much this improves things, for me the DSL is clearer then you pass an argument to the
Rake::TestTask
construction.Overall I think the approach to only use DSL where it is most obvious is kind of clever.