{"action":"closed","issue":{"url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/906","repository_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers","labels_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/906/labels{/name}","comments_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/906/comments","events_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/906/events","html_url":"https://github.com/thoughtbot/shoulda-matchers/issues/906","id":136626218,"number":906,"title":"NoMethodError: undefined method negative_failure_message for Shoulda::Matchers::ActiveModel::AllowValueMatcher","user":{"login":"ajvondrak","id":600924,"avatar_url":"https://avatars.githubusercontent.com/u/600924?v=3","gravatar_id":"","url":"https://api.github.com/users/ajvondrak","html_url":"https://github.com/ajvondrak","followers_url":"https://api.github.com/users/ajvondrak/followers","following_url":"https://api.github.com/users/ajvondrak/following{/other_user}","gists_url":"https://api.github.com/users/ajvondrak/gists{/gist_id}","starred_url":"https://api.github.com/users/ajvondrak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajvondrak/subscriptions","organizations_url":"https://api.github.com/users/ajvondrak/orgs","repos_url":"https://api.github.com/users/ajvondrak/repos","events_url":"https://api.github.com/users/ajvondrak/events{/privacy}","received_events_url":"https://api.github.com/users/ajvondrak/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-26T08:14:08Z","updated_at":"2016-06-14T00:20:26Z","closed_at":"2016-06-14T00:20:26Z","body":"Using Minitest 5.8.4, shoulda-context 1.2.1, and shoulda-matchers 3.1.1 with an assertion like\r\n\r\n```ruby\r\nclass FooTest < ActiveSupport::TestCase\r\n  should_not allow_values(:a, :b, :c).for(:bar)\r\nend\r\n```\r\n\r\nWhen there's a logical failure in the test, we try to show a negated failure message. However, it seems like shoulda-context and/or shoulda-matchers winds up trying to call `negative_failure_message`, which raises ```NoMethodError: undefined method `negative_failure_message' for #<Shoulda::Matchers::ActiveModel::AllowValueMatcher:0x007fbe9701e980>```\r\n\r\nPoking around the code bases, it looks like the shoulda-matchers method names were updated to be RSpec 3.0 compliant, like `failure_message_when_negated`, but not all of them define an alias back to the old-style `failure_message_for_should_not`. Ergo, this bit of code in shoulda-context tries to call `negative_failure_message` (not sure where this name comes from):\r\n\r\n```\r\n~/.rvm/gems/ruby-2.3.0/gems/shoulda-context-1.2.1$ ack --ruby negative_failure_message\r\nlib/shoulda/context/assertions.rb\r\n57:            message = matcher.respond_to?(:failure_message_for_should_not) ? matcher.failure_message_for_should_not : matcher.negative_failure_message\r\n82:          message = matcher.respond_to?(:failure_message_for_should_not) ? matcher.failure_message_for_should_not : matcher.negative_failure_message\r\n\r\ntest/shoulda/helpers_test.rb\r\n144:                                 :negative_failure_message => 'bad failure message')\r\n```\r\n\r\nThis can be fixed by either (a) updating shoulda-context (possibly a better solution, I'm not sure) or (b) setting up the `alias` in the `AllowValueMatcher`, which I've monkey-patched into my test_helper.rb like so:\r\n\r\n```ruby\r\nShoulda::Matchers::ActiveModel::AllowValueMatcher.class_eval do\r\n  alias :failure_message_for_should_not :failure_message_when_negated\r\nend\r\n```\r\n\r\nNot sure what other matchers are missing this alias as well. Probably worth investigating."}}
{"actor":{"display_login":"mcmire"}}