{"action":"closed","issue":{"url":"https://api.github.com/repos/seattlerb/minitest/issues/462","repository_url":"https://api.github.com/repos/seattlerb/minitest","labels_url":"https://api.github.com/repos/seattlerb/minitest/issues/462/labels{/name}","comments_url":"https://api.github.com/repos/seattlerb/minitest/issues/462/comments","events_url":"https://api.github.com/repos/seattlerb/minitest/issues/462/events","html_url":"https://github.com/seattlerb/minitest/issues/462","id":43037676,"number":462,"title":"Where should custom assertions be defined?","user":{"login":"singpolyma","id":12770,"avatar_url":"https://avatars.githubusercontent.com/u/12770?v=3","gravatar_id":"","url":"https://api.github.com/users/singpolyma","html_url":"https://github.com/singpolyma","followers_url":"https://api.github.com/users/singpolyma/followers","following_url":"https://api.github.com/users/singpolyma/following{/other_user}","gists_url":"https://api.github.com/users/singpolyma/gists{/gist_id}","starred_url":"https://api.github.com/users/singpolyma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/singpolyma/subscriptions","organizations_url":"https://api.github.com/users/singpolyma/orgs","repos_url":"https://api.github.com/users/singpolyma/repos","events_url":"https://api.github.com/users/singpolyma/events{/privacy}","received_events_url":"https://api.github.com/users/singpolyma/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"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},"milestone":null,"comments":6,"created_at":"2014-09-17T17:03:48Z","updated_at":"2016-05-21T00:00:06Z","closed_at":"2016-05-21T00:00:06Z","body":"I want to define a custom assertion helper for the tests in one of my files (basically, I have a describe block I'm generating in a loop and when dealing with hash data I want to do must_equal and when dealing with array data I want to do must_equal for each member of the array).  I can do this easily as follows:\r\n\r\n    [:object, :array].each do |k|\r\n         describe \"#{k} data\" do\r\n            let(:data) { public_send(k) }\r\n            define_method(:all_equal) { |a, b|\r\n               if k == :array\r\n                  a.each { |x| x.must_equal(b) }\r\n               else\r\n                  a.must_equal(b)\r\n               end\r\n            }\r\n            it 'should filter out everything by default' do\r\n               all_equal (... my library call ...), {a: :b}\r\n            end\r\n         end\r\n    end\r\n\r\nHowever this results in every test failure being reported as the line inside the `define_method` instead of the line in my actual test.  I tried moving it to a class at the top of my test file, and the same thing happened.  Any insight into a better way to handle this?"}}
{"actor":{"display_login":"zenspider"}}