title: How to pass Rspec test has_many? [Shoulda-matchers]
body: <p>I´m trying rails to develop a rest api. I´m using rspec and shoulda-matchers. The problem is that one of my test always fails.</p>
  
  <p>How can I correct my code, so the test passes (GREEN).</p>
  
  <p>user.rb</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
      has_many :cards
  end
  </code></pre>
  
  <p>card.rb</p>
  
  <pre><code>class Card &lt; ActiveRecord::Base
      belongs_to :user
  end
  </code></pre>
  
  <p>user_spec.rb</p>
  
  <pre><code>require 'rails_helper'
  
  RSpec.describe User, type: :model do
      before { @user = FactoryGirl.create(:user) } 
  
      subject{ @user }
  
      # Columns
      it { should respond_to :name }
  
      # Associations
      it { should have_many :cards }
  end
  </code></pre>
  
  <p>Gemfile</p>
  
  <pre><code>source 'https://rubygems.org'
  
  
  gem 'rails', '4.2.0'
  
  gem 'rails-api'
  
  gem 'spring', :group =&gt; :development
  
  
  gem 'sqlite3'
  
  
  group :development, :test do
      gem 'factory_girl_rails'
    gem 'rspec-rails', '~&gt; 3.0'
    gem 'shoulda-matchers', '~&gt; 3.0'
  end
  </code></pre>
  
  <p>Terminal</p>
  
  <pre><code>➜  my_api  rspec spec/models/user_spec.rb
  .F
  
  Failures:
  
    1) User should have many :cards
       Failure/Error: it { should have_many :cards }
         expected #&lt;User:0x007f897ce0c0d8&gt; to respond to `has_many?`
       # ./spec/models/user_spec.rb:12:in `block (2 levels) in &lt;top (required)&gt;'
  
  Finished in 0.04623 seconds (files took 2.45 seconds to load)
  2 examples, 1 failure
  
  Failed examples:
  
  rspec ./spec/models/user_spec.rb:12 # User should have many :cards
  </code></pre>