{"action":"created","issue":{"url":"https://api.github.com/repos/rspec/rspec-mocks/issues/990","labels_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/990/labels{/name}","comments_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/990/comments","events_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/990/events","html_url":"https://github.com/rspec/rspec-mocks/issues/990","id":94378709,"number":990,"title":"Why it has to be such paint to test?","user":{"login":"mxrguspxrt","id":346566,"avatar_url":"https://avatars.githubusercontent.com/u/346566?v=3","gravatar_id":"","url":"https://api.github.com/users/mxrguspxrt","html_url":"https://github.com/mxrguspxrt","followers_url":"https://api.github.com/users/mxrguspxrt/followers","following_url":"https://api.github.com/users/mxrguspxrt/following{/other_user}","gists_url":"https://api.github.com/users/mxrguspxrt/gists{/gist_id}","starred_url":"https://api.github.com/users/mxrguspxrt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mxrguspxrt/subscriptions","organizations_url":"https://api.github.com/users/mxrguspxrt/orgs","repos_url":"https://api.github.com/users/mxrguspxrt/repos","events_url":"https://api.github.com/users/mxrguspxrt/events{/privacy}","received_events_url":"https://api.github.com/users/mxrguspxrt/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-10T19:47:23Z","updated_at":"2015-07-10T20:04:52Z","closed_at":"2015-07-10T20:04:52Z","body":"I do understand that these are not exactly the same objects in a Hash, but direct comparation would work. Also why it is not smart enough to understand that Postgre does not store with that precision?\r\n\r\n\r\n\r\n```ruby\r\n  describe '.send_notification_about_tomorrows_visits' do\r\n    before do\r\n      create(:visit_entry, datetime: DateTime.now)\r\n      @visit_entry = create(:visit_entry, datetime: DateTime.now+1.day)\r\n      create(:visit_entry, datetime: DateTime.now+1.day)\r\n    end\r\n    it 'sends notificaitons about tomorrows visits' do\r\n      allow(Notification).to receive(:send_notification).with(\r\n        {\r\n          :owner=> @visit_entry,\r\n          :to_email=>\"user3@wave.ee\",\r\n          :template_name=>\"notification_about_tomorrows_visits\",\r\n          :template_content=>\r\n           [\r\n              {\r\n                :visit_for_name=>\"Firstname 3 Lastname 3\",\r\n                :visit_at_time=>@visit_entry.datetime\r\n              }\r\n            ]\r\n        }\r\n        )\r\n      Notification.send_notification_about_tomorrows_visits\r\n    end\r\n  end\r\n```\r\n\r\n\r\n```ruby\r\n  def self.send_notification_about_tomorrows_visits\r\n    tomorrow = Date.today + 1.day\r\n    tomorrows_visits = VisitEntry.where('DATE(datetime) = ?', tomorrow)\r\n\r\n    tomorrows_visits.map do |tomorrows_visit|\r\n      send_notification(\r\n        owner: tomorrows_visit,\r\n        to_email: tomorrows_visit.diary.owner.email,\r\n        template_name: 'notification_about_tomorrows_visits',\r\n        template_content: [{\r\n          visit_for_name: tomorrows_visit.diary.full_name,\r\n          visit_at_time: tomorrows_visit.datetime\r\n          }]\r\n        )\r\n    end\r\n  end\r\n```\r\n\r\n```\r\nFailures:\r\n\r\n  1) Notification.send_notification_about_tomorrows_visits sends notificaitons about tomorrows visits\r\n     Failure/Error: Notification.send_notification_about_tomorrows_visits\r\n       #<Notification(id: integer, owner_id: integer, owner_type: string, notification_type: string, created_at: datetime, updated_at: datetime) (class)> received :send_notification with unexpected arguments\r\n         expected: ({:owner=>#<VisitEntry id: 4, datetime: \"2015-07-11 19:35:37\", diary_id: 3, created_at: \"2015-07-10 19:35:37\", updated_at: \"2015-07-10 19:35:37\", type: \"VisitEntry\", comment: \"Some comment\">, :to_email=>\"user3@wave.ee\", :template_name=>\"notification_about_tomorrows_visits\", :template_content=>[{:visit_for_name=>\"Firstname 3 Lastname 3\", :visit_at_time=>2015-07-11 22:35:37.798902185 +0300}]})\r\n              got: ({:owner=>#<VisitEntry id: 4, datetime: \"2015-07-11 19:35:37\", diary_id: 3, created_at: \"2015-07-10 19:35:37\", updated_at: \"2015-07-10 19:35:37\", type: \"VisitEntry\", comment: \"Some comment\">, :to_email=>\"user3@wave.ee\", :template_name=>\"notification_about_tomorrows_visits\", :template_content=>[{:visit_for_name=>\"Firstname 3 Lastname 3\", :visit_at_time=>2015-07-11 22:35:37.798902000 +0300}]})\r\n       Diff:\r\n       @@ -1,5 +1,5 @@\r\n        [{:owner=>\r\n       -   #<VisitEntry:0x00000009d21050\r\n       +   #<VisitEntry:0x00000009f91768\r\n            id: 4,\r\n            datetime: Sat, 11 Jul 2015 22:35:37 EEST +03:00,\r\n            diary_id: 3,\r\n       @@ -11,5 +11,5 @@\r\n          :template_name=>\"notification_about_tomorrows_visits\",\r\n          :template_content=>\r\n           [{:visit_for_name=>\"Firstname 3 Lastname 3\",\r\n       -     :visit_at_time=>2015-07-11 22:35:37.798902185 +0300}]}]\r\n       +     :visit_at_time=>2015-07-11 22:35:37.798902000 +0300}]}]\r\n       \r\n        Please stub a default value first if message might be received with other args as well. \r\n```"},"comment":{"url":"https://api.github.com/repos/rspec/rspec-mocks/issues/comments/120509055","html_url":"https://github.com/rspec/rspec-mocks/issues/990#issuecomment-120509055","issue_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/990","id":120509055,"user":{"login":"mxrguspxrt","id":346566,"avatar_url":"https://avatars.githubusercontent.com/u/346566?v=3","gravatar_id":"","url":"https://api.github.com/users/mxrguspxrt","html_url":"https://github.com/mxrguspxrt","followers_url":"https://api.github.com/users/mxrguspxrt/followers","following_url":"https://api.github.com/users/mxrguspxrt/following{/other_user}","gists_url":"https://api.github.com/users/mxrguspxrt/gists{/gist_id}","starred_url":"https://api.github.com/users/mxrguspxrt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mxrguspxrt/subscriptions","organizations_url":"https://api.github.com/users/mxrguspxrt/orgs","repos_url":"https://api.github.com/users/mxrguspxrt/repos","events_url":"https://api.github.com/users/mxrguspxrt/events{/privacy}","received_events_url":"https://api.github.com/users/mxrguspxrt/received_events","type":"User","site_admin":false},"created_at":"2015-07-10T20:04:52Z","updated_at":"2015-07-10T20:04:52Z","body":"@myronmarston Thank you! You are my hero!\r\n\r\nWorking solution:\r\n\r\n```ruby\r\nallow(Notification).to receive(:send_notification).with(\r\n        {\r\n          :owner=> an_object_matching(@visit_entry),\r\n          :to_email=>\"user3@saiku.ee\",\r\n          :template_name=>\"notification_about_tomorrows_visits\",\r\n          :template_content=>\r\n           [\r\n              {\r\n                :visit_for_name=>\"Firstname 3 Lastname 3\",\r\n                :visit_at_time=>a_value_within(1.second).of(@visit_entry.datetime)\r\n              }\r\n            ]\r\n        }\r\n        )\r\n```"}}