{"action":"created","issue":{"url":"https://api.github.com/repos/mongoid-rspec/mongoid-rspec/issues/162","labels_url":"https://api.github.com/repos/mongoid-rspec/mongoid-rspec/issues/162/labels{/name}","comments_url":"https://api.github.com/repos/mongoid-rspec/mongoid-rspec/issues/162/comments","events_url":"https://api.github.com/repos/mongoid-rspec/mongoid-rspec/issues/162/events","html_url":"https://github.com/mongoid-rspec/mongoid-rspec/issues/162","id":115896153,"number":162,"title":"Bug in `matches?` method.","user":{"login":"Bartuz","id":4388676,"avatar_url":"https://avatars.githubusercontent.com/u/4388676?v=3","gravatar_id":"","url":"https://api.github.com/users/Bartuz","html_url":"https://github.com/Bartuz","followers_url":"https://api.github.com/users/Bartuz/followers","following_url":"https://api.github.com/users/Bartuz/following{/other_user}","gists_url":"https://api.github.com/users/Bartuz/gists{/gist_id}","starred_url":"https://api.github.com/users/Bartuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bartuz/subscriptions","organizations_url":"https://api.github.com/users/Bartuz/orgs","repos_url":"https://api.github.com/users/Bartuz/repos","events_url":"https://api.github.com/users/Bartuz/events{/privacy}","received_events_url":"https://api.github.com/users/Bartuz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-09T15:08:48Z","updated_at":"2015-11-09T15:31:18Z","closed_at":"2015-11-09T15:31:18Z","body":"I'm  testing model vs HABTM association\r\n```\r\n  1) Contact should reference and referenced in many \"synced_emails\" of type \"BccEmail\"\r\n     Failure/Error: it { is_expected.to have_and_belong_to_many(:synced_emails).of_type('BccEmail') }\r\n     NoMethodError:\r\n       undefined method `sub' for BccEmail:Class\r\n     # /Users/filip/.rvm/gems/ruby-2.2.1/gems/mongoid-4.0.2/lib/mongoid/relations/metadata.rb:126:in `class_name'\r\n     # /Users/filip/.rvm/gems/ruby-2.2.1/gems/mongoid-4.0.2/lib/mongoid/relations/metadata.rb:575:in `klass'\r\n     # /Users/filip/.rvm/gems/ruby-2.2.1/gems/mongoid-rspec-2.1.0/lib/matchers/associations.rb:129:in `matches?'\r\n     # ./spec/models/contact_spec.rb:4:in `block (2 levels) in <top (required)>'\r\n```\r\n\r\nand the same for of_type(Constant)\r\n\r\n```\r\n  1) Contact should reference and referenced in many \"synced_emails\" of type BccEmail\r\n     Failure/Error: it { is_expected.to have_and_belong_to_many(:synced_emails).of_type(BccEmail) }\r\n     NoMethodError:\r\n       undefined method `sub' for BccEmail:Class\r\n     # /Users/filip/.rvm/gems/ruby-2.2.1/gems/mongoid-4.0.2/lib/mongoid/relations/metadata.rb:126:in `class_name'\r\n     # /Users/filip/.rvm/gems/ruby-2.2.1/gems/mongoid-4.0.2/lib/mongoid/relations/metadata.rb:575:in `klass'\r\n     # /Users/filip/.rvm/gems/ruby-2.2.1/gems/mongoid-rspec-2.1.0/lib/matchers/associations.rb:129:in `matches?'\r\n     # ./spec/models/contact_spec.rb:4:in `block (2 levels) in <top (required)>'\r\n```"},"comment":{"url":"https://api.github.com/repos/mongoid-rspec/mongoid-rspec/issues/comments/155096667","html_url":"https://github.com/mongoid-rspec/mongoid-rspec/issues/162#issuecomment-155096667","issue_url":"https://api.github.com/repos/mongoid-rspec/mongoid-rspec/issues/162","id":155096667,"user":{"login":"Bartuz","id":4388676,"avatar_url":"https://avatars.githubusercontent.com/u/4388676?v=3","gravatar_id":"","url":"https://api.github.com/users/Bartuz","html_url":"https://github.com/Bartuz","followers_url":"https://api.github.com/users/Bartuz/followers","following_url":"https://api.github.com/users/Bartuz/following{/other_user}","gists_url":"https://api.github.com/users/Bartuz/gists{/gist_id}","starred_url":"https://api.github.com/users/Bartuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bartuz/subscriptions","organizations_url":"https://api.github.com/users/Bartuz/orgs","repos_url":"https://api.github.com/users/Bartuz/repos","events_url":"https://api.github.com/users/Bartuz/events{/privacy}","received_events_url":"https://api.github.com/users/Bartuz/received_events","type":"User","site_admin":false},"created_at":"2015-11-09T15:31:18Z","updated_at":"2015-11-09T15:31:18Z","body":"Sorry, it was my bad (I got a bit misled by error message). I haven't specified `:inverse_of` on `BccEmail`. Works like a charm now."}}