# authlogic's password field is not required in rspec?

**URL:** <https://discuss.rubyonrails.org/t/authlogics-password-field-is-not-required-in-rspec/57811>\
**Category:** rubyonrails-talk\
**Created:** [March 10, 2011, 2:16am UTC](https://discuss.rubyonrails.org/t/authlogics-password-field-is-not-required-in-rspec/57811 "2011-03-10T02:16:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_H1](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@James\_H1](https://discuss.rubyonrails.org/u/James_H1)\
**Post date:** [March 10, 2011, 2:16am UTC](https://discuss.rubyonrails.org/t/authlogics-password-field-is-not-required-in-rspec/57811/1 "2011-03-10T02:16:21Z")

</div>

Hello,

I am using authlogic and rspec in our project. I steup the authlogic as the offical example. But when i run my rspec, it tells me that password field is not required. My spec file is as following:

require 'spec\_helper'

describe User do &nbsp;&nbsp;before(:each) do &nbsp;&nbsp;&nbsp;&nbsp;@valid\_attributes = { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:email =\> 'tcsnhj@gmail.com', &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:password =\> "aaaaaa", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:password\_confirmation =\> "aaaaaa" &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;@user = User.new(@valid\_attributes) &nbsp;&nbsp;end

......

&nbsp;&nbsp;it "should not be valid without a password" do &nbsp;&nbsp;&nbsp;&nbsp;@user.password = nil &nbsp;&nbsp;&nbsp;&nbsp;@user.should\_not be\_valid &nbsp;&nbsp;end ........ end

the rspec show me "expected valid? to return false, got true". but when I run the application in firefox, and if I leave the password field empty, the form will give errors. I also run irb: @user = User.new( :email =\> "gaga@gag.com", :password = nil, :password\_confirmation = 'a' \* 10), the @user.valid? returned false.

Why the rspec got true? .

---

<div class="post-metadata">

**Author:** ![James\_H1](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@James\_H1](https://discuss.rubyonrails.org/u/James_H1)\
**Post date:** [March 10, 2011, 6:50am UTC](https://discuss.rubyonrails.org/t/authlogics-password-field-is-not-required-in-rspec/57811/2 "2011-03-10T06:50:17Z")

</div>

Anyboby know why? I am waiting online!
