title: post:create in rspec test giving 'count should have been changed by 1, but was changed by 0'
body: <p>I've got a problem with testing a <code>create</code> method of a controller. My test:</p>
  
  <pre><code>describe "POST #create" do
    it "creates a new admin_user" do
      expect{
        post :create, :admin_user =&gt; FactoryGirl.attributes_for(:admin_user)
      }.to change(Admin::User,:count).by(1)
    end
  end
  </code></pre>
  
  <p>And the failed spec I'm getting: </p>
  
  <pre><code>1) Admin::UsersController logged in POST #create creates a new admin_user
       Failure/Error: expect{
         count should have been changed by 1, but was changed by 0
       # ./spec/controllers/admin_users_controller_spec.rb:75:in `block (4 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>Here's my controller:</p>
  
  <pre><code>  def create
      @admin_user = Admin::User.new(params[:admin_user])
      if @admin_user.save
        render nothing: true
      end
    end
  </code></pre>
  
  <p>and a factory: </p>
  
  <pre><code>require "factory_girl"
  require 'ffaker'
  
  FactoryGirl.define do
    factory :admin_user, class: "Admin::User" do |f|
      f.name {Faker::Name.first_name}
      f.email {Faker::Internet.email}
      f.password "aaa"
    end
  end
  </code></pre>
  
  <p>and my model:</p>
  
  <pre><code>class Admin::User &lt; ActiveRecord::Base
    has_secure_password
    validates :email, :uniqueness =&gt; true, :presence =&gt; true 
    validates_presence_of :password, :on =&gt; :create
  end
  </code></pre>
  
  <p>I have no idea what might be wrong. I've searched <em>the whole internet</em> for it but didn't find the answer. Adding user from the rails console works just fine. Any help would be highly appreciated. Thanks in advance.</p>