PS!
The "Failure" console output above is for the wrong test (as the
assertion was commented out in test_create_newsletter). Here's the right
output:
1) Failure:
test_should_create_newsletter(NewslettersControllerTest)
[./test/functional/newsletters_controller_test.rb:33:in
`test_should_create_newsletter'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/testing/setup_and_teardown.rb:33:in
`__send__'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/testing/setup_and_teardown.rb:33:in
`run']:
<2> expected but was
<1>.
/ Vahagn
Vahagn Hayrapetyan wrote:
> Hello all,-
>
> wondering if you can help me with a weird testing problem. I have a
> Newsletter model that has been developed and tested in a previous
> version (older branch) of my current project. Under that old project,
> all tests run perfectly with no failures. Moreover, in the current
> project Newsletter behaves perfectly with manual tests - ie creating,
> deleting, editing newsletters by hand.
>
> When I run rake test:functionals however, the tests don't do what they
> are supposed to. Here's a method from NewslettersControllerTest:
>
> def test_should_create_newsletter
> puts "TESTING CREATE"
> login_as(:admin_user) #method in test_helper.rb
> puts "I am " + users(:admin_user).id.to_s #loads correct user from
> fixture!
> puts "My email: " + users(:admin_user).email #same, correct user
> old_count = Newsletter.count
> puts "Old count: " + old_count.to_s #1
> post :create, :newsletter => { :subject => 'testing creating
> newsletter', :body => 'Test' }
> puts "Old count after create: " + old_count.to_s #1
> #assert_equal old_count+1, Newsletter.count #fails
> puts "Newsletter count after create: " + Newsletter.count.to_s #1
> AGAIN!
> #assert_redirected_to newsletter_path(assigns(:newsletter))
> end
>
> And here's the console output:
>
> Started
> ....TESTING CREATE
> I am 2
> My email: [EMAIL PROTECTED]
> Old count: 1
> Old count after create: 1
> Newsletter count after create: 1
> .FFFFFF....................
> Finished in 3.518293 seconds.
>
> 1) Failure:
> test_should_destroy_newsletter(NewslettersControllerTest)
>
> [/Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/test/unit/assertions.rb:43:in
> `assert_difference'
>
> /Library/Ruby/Gems/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/route.rb:48:in
> `each_with_index'
>
> /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/test/unit/assertions.rb:42:in
> `each'
>
> /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/test/unit/assertions.rb:42:in
> `each_with_index'
>
> /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/test/unit/assertions.rb:42:in
> `assert_difference'
> ./test/functional/newsletters_controller_test.rb:58:in
> `test_should_destroy_newsletter'
>
> /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/testing/setup_and_teardown.rb:33:in
> `__send__'
>
> /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/testing/setup_and_teardown.rb:33:in
> `run']:
> <0> expected but was
> <1>.
>
>
> Can anyone see what is wrong here?
>
> Many thanks, Vahagn
--
Posted via http://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
-~----------~----~----~----~------~----~------~--~---