{"action":"created","issue":{"url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/849","labels_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/849/labels{/name}","comments_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/849/comments","events_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/849/events","html_url":"https://github.com/thoughtbot/shoulda-matchers/issues/849","id":118683422,"number":849,"title":"The allow_value matcher attempted to set :price on DeviceType to 0.1, but when the attribute was read back, it had stored 0 instead","user":{"login":"anthonator","id":420061,"avatar_url":"https://avatars.githubusercontent.com/u/420061?v=3","gravatar_id":"","url":"https://api.github.com/users/anthonator","html_url":"https://github.com/anthonator","followers_url":"https://api.github.com/users/anthonator/followers","following_url":"https://api.github.com/users/anthonator/following{/other_user}","gists_url":"https://api.github.com/users/anthonator/gists{/gist_id}","starred_url":"https://api.github.com/users/anthonator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anthonator/subscriptions","organizations_url":"https://api.github.com/users/anthonator/orgs","repos_url":"https://api.github.com/users/anthonator/repos","events_url":"https://api.github.com/users/anthonator/events{/privacy}","received_events_url":"https://api.github.com/users/anthonator/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-11-24T19:18:45Z","updated_at":"2015-12-08T14:32:20Z","closed_at":null,"body":"```\r\nFailure/Error: it { should validate_numericality_of(:price).only_integer.is_greater_than_or_equal_to(0) }\r\n     \r\n     Shoulda::Matchers::ActiveModel::AllowValueMatcher::CouldNotSetAttributeError:\r\n       The allow_value matcher attempted to set :price on DeviceType to 0.1,\r\n       but when the attribute was read back, it had stored 0 instead.\r\n     \r\n       This creates a problem because it means that the model is behaving in a\r\n       way that is interfering with the test -- there's a mismatch between the\r\n       test that was written and test that was actually run.\r\n     \r\n       There are a couple of reasons why this could be happening:\r\n     \r\n       * The writer method for :price has been overridden and contains custom\r\n         logic to prevent certain values from being set or change which values\r\n         are stored.\r\n       * ActiveRecord is typecasting the incoming value.\r\n     \r\n       Regardless, the fact you're seeing this message usually indicates a\r\n       larger problem. Please file an issue on the GitHub repo for\r\n       shoulda-matchers, including details about your model and the test\r\n       you've written, and we can point you in the right direction:\r\n     \r\n       https://github.com/thoughtbot/shoulda-matchers/issues\r\n```\r\n\r\n**Model**\r\n\r\n```\r\nclass DeviceType < ActiveRecord::Base\r\n  validates :label, presence: true\r\n\r\n  validates :price, presence: true,\r\n                    numericality: { only_integer: true, greater_than_or_equal_to: 0 }\r\nend\r\n```\r\n\r\n**Spec**\r\n\r\n```\r\nRSpec.describe DeviceType, type: :model do\r\n  # label\r\n  it { should validate_presence_of(:label) }\r\n\r\n  # price\r\n  it { should validate_presence_of(:price) }\r\n  it { should validate_numericality_of(:price).only_integer.is_greater_than_or_equal_to(0) }\r\nend\r\n```"},"comment":{"url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/comments/162898918","html_url":"https://github.com/thoughtbot/shoulda-matchers/issues/849#issuecomment-162898918","issue_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/849","id":162898918,"user":{"login":"ckib16","id":2160186,"avatar_url":"https://avatars.githubusercontent.com/u/2160186?v=3","gravatar_id":"","url":"https://api.github.com/users/ckib16","html_url":"https://github.com/ckib16","followers_url":"https://api.github.com/users/ckib16/followers","following_url":"https://api.github.com/users/ckib16/following{/other_user}","gists_url":"https://api.github.com/users/ckib16/gists{/gist_id}","starred_url":"https://api.github.com/users/ckib16/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ckib16/subscriptions","organizations_url":"https://api.github.com/users/ckib16/orgs","repos_url":"https://api.github.com/users/ckib16/repos","events_url":"https://api.github.com/users/ckib16/events{/privacy}","received_events_url":"https://api.github.com/users/ckib16/received_events","type":"User","site_admin":false},"created_at":"2015-12-08T14:32:20Z","updated_at":"2015-12-08T14:32:20Z","body":"+1 on this as well. The exact same issue. Happy to help if needed!\r\n\r\n"}}