{"action":"opened","issue":{"url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/646","labels_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/646/labels{/name}","comments_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/646/comments","events_url":"https://api.github.com/repos/thoughtbot/shoulda-matchers/issues/646/events","html_url":"https://github.com/thoughtbot/shoulda-matchers/issues/646","id":56334750,"number":646,"title":"`should have_many().through` gives `undefined method `class_name' for nil:NilClass`","user":{"login":"marnen","id":34378,"avatar_url":"https://avatars.githubusercontent.com/u/34378?v=3","gravatar_id":"","url":"https://api.github.com/users/marnen","html_url":"https://github.com/marnen","followers_url":"https://api.github.com/users/marnen/followers","following_url":"https://api.github.com/users/marnen/following{/other_user}","gists_url":"https://api.github.com/users/marnen/gists{/gist_id}","starred_url":"https://api.github.com/users/marnen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marnen/subscriptions","organizations_url":"https://api.github.com/users/marnen/orgs","repos_url":"https://api.github.com/users/marnen/repos","events_url":"https://api.github.com/users/marnen/events{/privacy}","received_events_url":"https://api.github.com/users/marnen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-03T05:12:41Z","updated_at":"2015-02-03T05:12:41Z","closed_at":null,"body":"I've just run into a problem with shoulda-matchers 2.7.0 and 2.8.0, Rails 4.2, and Ruby 2.2.0 on Mac OS X 10.10. The complete application is at https://github.com/marnen/duckbill/tree/shoulda-matchers-issue , if you need to see the code in context.\r\n\r\n```\r\n# user.rb\r\nhas_many :clients\r\nhas_many :projects, through: :clients\r\n```\r\n\r\n```\r\n# user_spec.rb\r\nit { should have_many :clients }\r\nit { should have_many(:projects).through :clients }\r\n```\r\n\r\nI would expect both specs to pass, but only the first one does. The second one gives the following error:\r\n```\r\nFailures:\r\n\r\n  1) User should have many projects through clients\r\n     Failure/Error: it {  should have_many(:projects).through :clients }\r\n     NoMethodError:\r\n       undefined method `class_name' for nil:NilClass\r\n     # /Users/marnen/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/reflection.rb:871:in `derive_class_name'\r\n     # /Users/marnen/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.0/lib/active_record/reflection.rb:147:in `class_name'\r\n     # /Users/marnen/.rvm/gems/ruby-2.2.0/gems/shoulda-matchers-2.8.0/lib/shoulda/matchers/active_record/association_matcher.rb:1067:in `rescue in class_exists?'\r\n     # /Users/marnen/.rvm/gems/ruby-2.2.0/gems/shoulda-matchers-2.8.0/lib/shoulda/matchers/active_record/association_matcher.rb:1064:in `class_exists?'\r\n     # /Users/marnen/.rvm/gems/ruby-2.2.0/gems/shoulda-matchers-2.8.0/lib/shoulda/matchers/active_record/association_matcher.rb:928:in `matches?'\r\n     # ./spec/models/user_spec.rb:5:in `block (2 levels) in <top (required)>'\r\n```\r\n\r\nI have no idea what's going on here. Is this a Rails 4.2 incompatibility? Or something else? Help?"}}