merlin371
merlin371

Reputation: 514

User not creating in rspec

I have this very weird issue that I cant really get why it's not working.

This is the test that I'm running to test post comments

https://gist.github.com/2794100

now I added 2 extra tests there to get an idea as to why it wasnt working the "user should exist" and "post should exist" to try and understand what's going on, all I gathered is that the user is not creating. Which is weird cause when I run this other test everything works fine

https://gist.github.com/2794105

the user creation is a copy and paste, seeing as I have the email as a unique key I even tried running the test by itself without any other tests to make sure there was no conflict and I also tried running it with a fresh made database.

if I run each command on the rails console everything works, it's just on the test itself that it doesnt work

Any help would be great.

Thanks

Upvotes: 0

Views: 401

Answers (1)

jdoe
jdoe

Reputation: 15771

Your test is full of lines like:

before { @post.title == "Example Post"}

It's just a comparison, not an assignment. This doesn't make any sense!

You always refer to implicit subject (it { should ...), which in your case is a new instance of PostComment. You should specify what exactly are you testing, like:

subject { @foo }

Or just explicitly name it:

it 'should be valid even if something is nil' do
  before { @foo.name = nil }
  @foo.should be_valid
end

Upvotes: 1

Related Questions