{"action":"created","issue":{"url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/946","repository_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers","labels_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/946/labels{/name}","comments_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/946/comments","events_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/946/events","html_url":"https://github.com/thoughtbot/shoulda-matchers/issues/946","id":163799674,"number":946,"title":"is_expected.to validate_inclusion_of(:role).in_array(%w(user blocked) raises ArgumentError","user":{"login":"majioa","id":417632,"avatar_url":"https://avatars.githubusercontent.com/u/417632?v=3","gravatar_id":"","url":"https://api.github.com/users/majioa","html_url":"https://github.com/majioa","followers_url":"https://api.github.com/users/majioa/followers","following_url":"https://api.github.com/users/majioa/following{/other_user}","gists_url":"https://api.github.com/users/majioa/gists{/gist_id}","starred_url":"https://api.github.com/users/majioa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/majioa/subscriptions","organizations_url":"https://api.github.com/users/majioa/orgs","repos_url":"https://api.github.com/users/majioa/repos","events_url":"https://api.github.com/users/majioa/events{/privacy}","received_events_url":"https://api.github.com/users/majioa/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/labels/UX","name":"UX","color":"cccccc"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-07-05T08:43:50Z","updated_at":"2016-09-13T21:57:22Z","closed_at":"2016-07-06T05:37:01Z","body":"I have the following matcher:\r\n\r\n    it { is_expected.to validate_inclusion_of(:role).in_array(%w(user blocked))\r\n\r\nwhen I run it to test I get strange error:\r\n\r\n    ArgumentError:\r\n      '123456789' is not a valid role\r\n\r\nThe model code is:\r\n\r\n    enum role: [:user, :blocked]\r\n\r\n    validates :role, inclusion: { in: %w(user blocked) }\r\n\r\nWhat is wrong here?"},"comment":{"url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/comments/246838549","html_url":"https://github.com/thoughtbot/shoulda-matchers/issues/946#issuecomment-246838549","issue_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/946","id":246838549,"user":{"login":"mcmire","id":7371,"avatar_url":"https://avatars.githubusercontent.com/u/7371?v=3","gravatar_id":"","url":"https://api.github.com/users/mcmire","html_url":"https://github.com/mcmire","followers_url":"https://api.github.com/users/mcmire/followers","following_url":"https://api.github.com/users/mcmire/following{/other_user}","gists_url":"https://api.github.com/users/mcmire/gists{/gist_id}","starred_url":"https://api.github.com/users/mcmire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcmire/subscriptions","organizations_url":"https://api.github.com/users/mcmire/orgs","repos_url":"https://api.github.com/users/mcmire/repos","events_url":"https://api.github.com/users/mcmire/events{/privacy}","received_events_url":"https://api.github.com/users/mcmire/received_events","type":"User","site_admin":false},"created_at":"2016-09-13T21:57:22Z","updated_at":"2016-09-13T21:57:22Z","body":"@gkop Okay, gotcha. Well, that's why I asked first :)\r\n\r\nThe ArgumentError that was mentioned above is definitely coming from Rails: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/enum.rb#L139\r\n\r\nSo, in that case, I think the only course of action here would be to modify `define_enum_for` to rescue the ArgumentError, and if the error message matches `/is not a valid #{attribute}/` then we swallow the error and move on."}}
{"actor":{"display_login":"mcmire"}}