I must be missing something fundamental. In the test code below, the assertion should fail unless WebPageCache.count == 1. But WebPageCache.count is zero (according to the print statement and all other evidence), yet the assertion passes. What am I missing? ====class WebPageCacheTest < ActiveSupport::TestCase ... test "table has one entry" do p "<<< #{WebPageCache.count}" # prints ''<<< 0'' assert (WebPageCache.count == 1), "WebPageCache size is not 1" end ... end ====(An aside: if I can''t trust a simple assert, what CAN I trust? :) - ff -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, May 7, 2010 at 4:39 PM, Fearless Fool <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I must be missing something fundamental. In the test code below, the > assertion should fail unless WebPageCache.count == 1.> assert (WebPageCache.count == 1), "WebPageCache size is not 1"Did you try WebPageCache.count.to_i == 1 or WebPageCache.count == ''1'' ? -- Greg Donald destiney.com | gregdonald.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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Greg Donald wrote:> Did you try WebPageCache.count.to_i == 1 or WebPageCache.count == ''1'' ?For grins, yes. No change. But I''m beginning to guess: are the db tables rolled back between EVERY call to test? I thought they were rolled back at the end of the test run, not between every test. Asked another way: if web_page_caches starts as empty, what are the expected results in the following? =====class WebPageCacheTest < ActiveSupport::TestCase test "store an entry" do WebPageCache.store("my_key", "my_value") assert (WebPageCache.count == 1), "WebPageCache size is not 1" test "table still has one entry" do assert (WebPageCache.count == 1), "WebPageCache size is not 1" end end =====-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On May 7, 11:09 pm, Fearless Fool <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Greg Donald wrote: > > Did you try WebPageCache.count.to_i == 1 or WebPageCache.count == ''1'' ? > > For grins, yes. No change. > > But I''m beginning to guess: are the db tables rolled back between EVERY > call to test? I thought they were rolled back at the end of the test > run, not between every test. >between every test (or rather each test runs inside a transaction which is rolled back). There should be no leakage of state from one test to another. Fred -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.