{"action":"created","issue":{"url":"https://api.github.com/repos/seattlerb/minitest/issues/485","labels_url":"https://api.github.com/repos/seattlerb/minitest/issues/485/labels{/name}","comments_url":"https://api.github.com/repos/seattlerb/minitest/issues/485/comments","events_url":"https://api.github.com/repos/seattlerb/minitest/issues/485/events","html_url":"https://github.com/seattlerb/minitest/issues/485","id":54707376,"number":485,"title":"Expand the expectation","user":{"login":"penibelst","id":3617307,"avatar_url":"https://avatars.githubusercontent.com/u/3617307?v=3","gravatar_id":"","url":"https://api.github.com/users/penibelst","html_url":"https://github.com/penibelst","followers_url":"https://api.github.com/users/penibelst/followers","following_url":"https://api.github.com/users/penibelst/following{/other_user}","gists_url":"https://api.github.com/users/penibelst/gists{/gist_id}","starred_url":"https://api.github.com/users/penibelst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/penibelst/subscriptions","organizations_url":"https://api.github.com/users/penibelst/orgs","repos_url":"https://api.github.com/users/penibelst/repos","events_url":"https://api.github.com/users/penibelst/events{/privacy}","received_events_url":"https://api.github.com/users/penibelst/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-18T19:40:55Z","updated_at":"2015-01-19T00:45:02Z","closed_at":null,"body":"I want to extend Minitest to validate text files. The usage should be:\r\n\r\n```ruby\r\nrequire \"minitest/autorun\"\r\nrequire \"minitest/validator\" # my file\r\n\r\ndescribe \"validate files\" do\r\n  parallelize_me!\r\n\r\n  it \"follows the foo algorithm\" do\r\n    \"**/*.txt\".must_validate :foo\r\n  end\r\n\r\nend\r\n```\r\n\r\n`must_validate` should \r\n\r\n1. Store the files in an array `files`.\r\n2. Expand the one expectation to `files.length` expectations. Every generated expectation should be named by the original expectation and the filename.\r\n3. Validate all files in parallel.\r\n\r\nFor 22 files the user should see something like:\r\n\r\n```\r\nRun options: --seed 1858\r\n\r\n# Running:\r\n\r\n..F...................\r\n\r\nFinished in 0.051691s, 425.6025 runs/s, 1180.0798 assertions/s.\r\n\r\n  1) Failure:\r\nvalidate files#test_0003_follows the foo algorithm '/foo/bar.txt'\r\n\r\n\r\n22 runs, 61 assertions, 1 failures, 0 errors, 0 skips\r\n\r\n```\r\n\r\nMy question is: how do I expand the expectation? Is there a plugin which does something similar? Can you provide a working example?"},"comment":{"url":"https://api.github.com/repos/seattlerb/minitest/issues/comments/70434729","html_url":"https://github.com/seattlerb/minitest/issues/485#issuecomment-70434729","issue_url":"https://api.github.com/repos/seattlerb/minitest/issues/485","id":70434729,"user":{"login":"zenspider","id":9832,"avatar_url":"https://avatars.githubusercontent.com/u/9832?v=3","gravatar_id":"","url":"https://api.github.com/users/zenspider","html_url":"https://github.com/zenspider","followers_url":"https://api.github.com/users/zenspider/followers","following_url":"https://api.github.com/users/zenspider/following{/other_user}","gists_url":"https://api.github.com/users/zenspider/gists{/gist_id}","starred_url":"https://api.github.com/users/zenspider/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zenspider/subscriptions","organizations_url":"https://api.github.com/users/zenspider/orgs","repos_url":"https://api.github.com/users/zenspider/repos","events_url":"https://api.github.com/users/zenspider/events{/privacy}","received_events_url":"https://api.github.com/users/zenspider/received_events","type":"User","site_admin":false},"created_at":"2015-01-19T00:45:02Z","updated_at":"2015-01-19T00:45:02Z","body":"I'd define something like `generate_validates` as a class method and call that in the `describe` block. `generate_validates` takes your arg and then does a bunch of `it` or `define_method` calls (same thing, really) to make test methods to run when the tests actually start running.\r\n\r\nBy the time you get to a test, everything has been introspected and the loop over the methods has already started. Doing it beforehand makes things clean and simple."}}