Hey,
thanks again for the help, I've given it another one but come up with
pretty much the same errors. (side note the strings I was asserting to
are now symbols)
def test_should_delete_word
assert_equal :published, words(:one).status
delete :destroy, :id => words(:one).to_param
reload!
word_status = Word.find(:id).status
assert_equal :deleted, word_status
end
Again returns: MethodError: undefined method `reload!' for
#<WordsControllerTest:0x2858368>
I also tried reloading on the active record object directly
def test_should_delete_word2
assert_equal :published, words(:one).status
delete :destroy, :id => words(:one).to_param
words(:one).reload (as well as reload!)
word_status = Word.find(:id).status
assert_equal :deleted, word_status
end
It returns: ActiveRecord::RecordNotFound: Couldn't find Word with
ID=id
Eventually it worked with(just a last attempt before I posted):
def test_should_delete_word2
assert_equal :published, words(:one).status
delete :destroy, :id => words(:one).to_param
words(:one).reload
word_status = Word.find(words(:one)).status
assert_equal :deleted, word_status
end
Which I find a little weird. Just because in this and other tests I've
found the fixtures produce weird id's when they hit the db. The only
way I can find matching id's is with the to_param string. So why
Word.find(words(:one)) managed to find a matching ID in the db without
using to_param beats me.
But thanks for everyones input ! If you have any idea about the id's I
wouldn't mind understanding exactly what is going on there.
-bp
On Sep 3, 12:41 am, Frederick Cheung <[email protected]>
wrote:
> On Sep 3, 1:20 am, brianp <[email protected]> wrote:
>
> > Hey everyone thanks for the input.
>
> > I've tried your suggestions with varying results:
>
> > def test_should_delete_word
> > assert_equal 'published', words(:one).status
> > debugger
> > delete :destroy, :id => words(:one).to_param
> > Word.reload
> > word_status=Word.find(:id).status
> > assert_equal 'deleted', word_status
> > end
> > Returns reload is not method.
>
> reload is a method on an individual activerecord object (ie words
> (:one).reload)
>
> Fred
>
> > I tried
> > def test_should_delete_word2
> > assert_equal 'published', words(:one).status
> > delete :destroy, :id => words(:one).to_param
>
> > assert_equal 'deleted', Word.find(:id.to_param).status
> > end
> > It claims "Couldn't find Word with ID=id" same with assert_equal
> > 'deleted', Word.find(:id).status
>
> > I also tried using Machinist but really don't know what objects to
> > call on to try anything. Wouldn't I have to first create a word then
> > find the word delete the ford and check the value. At that point it
> > sounds more like an integration test then Functional.
> > def test_should_delete_word
> > word = Word.plan
> > delete :destroy, :id => word.id // Returns cannot find id as the
> > object was never stored?
> > assert_equal 'deleted', assigns(:id).status
> > end
>
> > Thanks for your suggestions so far
>
> > On Sep 1, 10:20 pm, Nik Cool <[email protected]> wrote:
>
> > > def test_should_delete_word
> > > assert_equal 'published', words(:one).status
> > > debugger
> > > delete :destroy, :id => words(:one).to_param
> > > Word.reload
> > > word_status=Word.find(:id).status
> > > assert_equal 'deleted', word_status
> > > end
>
> > > --
> > > nik
>
> > > --
> > > Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---