Testing

I’d like to be one of the cool kids who does “testing”. Yes, I know it’s
essential.

Where do I start. I’d just like to start with a/some simple test.

My app users authlogic and i have an User.admin boolean flag.

I’d like to start by testing some stuff around this like only the
current_user or an Admin can delete their own Advert(s).

Any links tips to help start me off.

A User has many Adverts.

2009/9/14 bingo bob [email protected]:

current_user or an Admin can delete their own Advert(s).

Any links tips to help start me off.

A User has many Adverts.

Have you seen the rails guide on testing at
http://guides.rubyonrails.org/ ?

Colin

I’m just reading it. TDD is a bit much for me initially!

One question, trying to understand the stated example…

def test_should_not_save_post_without_title
post = Post.new
assert !post.save
end

What does “!post.save” mean?
If I’ve understood correctly this test is testing that a new post does
NOT save?

Am I right?

bingo bob wrote:

I’m just reading it. TDD is a bit much for me initially!

It’s actually a lot easier to write the tests first, because you can’t
forget to write them! Also, the tests serve as documentation of what
you meant the app to do. Adding tests to already written code – as
you’re doing – requires lots of thought about what you meant originally
and where the failure points could be.

One question, trying to understand the stated example…

def test_should_not_save_post_without_title
post = Post.new
assert !post.save
end

What does “!post.save” mean?
If I’ve understood correctly this test is testing that a new post does
NOT save?

Yes.

By the way, I’d recommend that you try RSpec. I generally find its
syntax and philosophy far more friendly than Rails’ own test framework.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Am I right?

2009/9/14 bingo bob [email protected]:

What does “!post.save” mean?
If I’ve understood correctly this test is testing that a new post does
NOT save?

Am I right?

The clue is in the name of the test

Colin

What does “!post.save” mean?
If I’ve understood correctly this test is testing that a new post does
NOT save?

Am I right?

correct.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs