Testing typo

So I’ve been looking into the built in unit tests in typo, and I figured
out how to run them.

This is the alarming end result:

Unit tests:
140 tests, 414 assertions, 14 failures, 8 errors

Functional test:

204 tests, 583 assertions, 20 failures, 39 errors

and then this:

rake aborted!
Test failures
/home/mattrose/rails/typo/config/…/vendor/rails/railties/lib/tasks/
testing.rake:35
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:232:in
execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:232:inexecute’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:202:in invoke' /usr/local/lib/ruby/1.8/thread.rb:135:insynchronize’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:195:in invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:1719:inrun’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:1719:in `run’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.0/bin/rake:7
/usr/local/bin/rake:18

So, a whole bunch of unit tests fail on the latest trunk. I think
some of it is db-dependent, as I get a different result using an
sqlite database, but I’m at a loss to explain the sheer amount of
errors.

Does anyone have a platform where all these tests pass?


Matt R. [email protected] Visit my blog! http://


He’s an uncontrollable pirate gangster with no name. She’s an enchanted
thirtysomething cab driver with a song in her heart and a spring in her
step. They fight crime!

For some reason, sqlite has a hard time with a lot of Typo’s tests. I
haven’t had time to figure out why.

Scott

these are actually the results with mysql[1]. the sqlite[2] results
are similar.

I also tried with postgresql and got similar results.

[1] I don’t have the innodb extension built in, and I only use
myISAM (and believe me, that causes other problems with rails)

[2] Unit: 140 tests, 410 assertions, 10 failures, 5 errors,
Functional: 204 tests, 472 assertions, 3 failures, 71 errors

Do all these tests work with a newer version of mysql?

I’ll re-run some tests as soon as I can, but things were clean the last
time
I checked.

Scott

Thanks. I’d like to help, but I don’t even know where to start.

Matt

Hi,

I just checked out a fresh copy of typo from svn and ran all the tests
against a fresh db (mysql 5.0.13). I’m still using Ruby 1.8.2 and at
first I had one failing test (XmlControllerTest#test_xml_atom10).
This appeared to be rexml related and sure enough, having upgraded
rexml from 3.1.2.1 to 3.1.4, all the tests now pass. I have innodb
database engine installed. I’m on Mac Os x 10.4.6.

Not sure if this helps…

Chris

So I finally got a start on figuring out why tests were failing. It
looks like none of the tests have been updated since the “blogs”
table was added, as I keep getting this error on the tests

  1. Error:
    test_just_published_flag(ArticleTest):
    ActiveRecord::RecordInvalid: Validation failed: Blog can’t be blank
    /home/mattrose/typotest/typo.sqlite/config/…/vendor/rails/
    activerecord/lib/active_record/validations.rb:736:in save!' /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/ activerecord/lib/active_record/validations.rb:699:increate!’
    article_test.rb:144:in `test_just_published_flag’

and everytime I add the “blog_id” to the the article that gets
created in the test (I’m running through article tests right now) the
test passes.

However, this doesn’t really jibe with what everyone else is saying
on the list, as those tests shouldn’t be passing for anyone.

Matt

Matt R. [email protected] writes:

So I’ve been looking into the built in unit tests in typo, and I figured
out how to run them.

Umm… have you run ‘rake migrate’? ISTR that the schema in the trunk
doesn’t exactly tally with the migrations. Which could explain your
failures.

Hmm. Hey, Piers, isn’t the blog supposed to be set by default? Where
does that come from?

Scott

replying to myself here: I managed to fix article_test.rb so that it
now passes all tests on sqlite
Should I submit patches for the files I fix? I still haven’t worked
out all the errors on postgres. I’ll work on that more, but I like
sqlite more, so I’ll be concentrating on that platform.

Before:

[email protected]:~/typotest/typo.sqlite/test/unit$ ruby
article_test.rb.orig
Loaded suite article_test.rb.orig
Started
F…E.EEFEF…F.E.
Finished in 3.506417 seconds.

  1. Failure:
    test_create(ArticleTest) [article_test.rb.orig:24]:
    is not true.

  2. Error:
    test_find_published_by_category(ArticleTest):
    ActiveRecord::RecordInvalid: Validation failed: Blog can’t be blank
    /home/mattrose/typotest/typo.sqlite/config/…/vendor/rails/
    activerecord/lib/active_record/validations.rb:736:in save!' /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/ activerecord/lib/active_record/validations.rb:699:increate!’
    article_test.rb.orig:178:in `test_find_published_by_category’

  3. Error:
    test_future_publishing(ArticleTest):
    ActiveRecord::RecordInvalid: Validation failed: Blog can’t be blank
    /home/mattrose/typotest/typo.sqlite/config/…/vendor/rails/
    activerecord/lib/active_record/validations.rb:736:in save!' /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/ activerecord/lib/active_record/validations.rb:699:increate!’
    article_test.rb.orig:150:in `test_future_publishing’

  4. Error:
    test_future_publishing_without_published_flag(ArticleTest):
    ActiveRecord::RecordInvalid: Validation failed: Blog can’t be blank
    /home/mattrose/typotest/typo.sqlite/config/…/vendor/rails/
    activerecord/lib/active_record/validations.rb:736:in save!' /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/ activerecord/lib/active_record/validations.rb:699:increate!’
    article_test.rb.orig:156:in
    `test_future_publishing_without_published_flag’

  5. Failure:
    test_html_title(ArticleTest) [article_test.rb.orig:63]:
    is not true.

  6. Error:
    test_just_published_flag(ArticleTest):
    ActiveRecord::RecordInvalid: Validation failed: Blog can’t be blank
    /home/mattrose/typotest/typo.sqlite/config/…/vendor/rails/
    activerecord/lib/active_record/validations.rb:736:in save!' /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/ activerecord/lib/active_record/validations.rb:699:increate!’
    article_test.rb.orig:142:in `test_just_published_flag’

  7. Failure:
    test_notifications(ArticleTest) [article_test.rb.orig:203]:
    is not true.

  8. Failure:
    test_tags(ArticleTest) [article_test.rb.orig:92]:
    is not true.

  9. Error:
    test_triggers_are_dependent(ArticleTest):
    ActiveRecord::RecordInvalid: Validation failed: Blog can’t be blank
    /home/mattrose/typotest/typo.sqlite/config/…/vendor/rails/
    activerecord/lib/active_record/validations.rb:736:in save!' /home/mattrose/typotest/typo.sqlite/config/../vendor/rails/ activerecord/lib/active_record/validations.rb:699:increate!’
    article_test.rb.orig:161:in `test_triggers_are_dependent’

21 tests, 45 assertions, 4 failures, 5 errors

After:

[email protected]:~/typotest/typo.sqlite/test/unit$ ruby article_test.rb
Loaded suite article_test
Started

Finished in 11.862288 seconds.

21 tests, 72 assertions, 0 failures, 0 errors

and this is the unified diff

— article_test.rb.orig 2006-06-21 21:51:49.000000000 -0400
+++ article_test.rb 2006-06-21 21:57:34.000000000 -0400
@@ -18,6 +18,7 @@
def test_create
a = Article.new

  •           a.blog_id = 1
    a.user_id = 1
    a.body = "Foo"
    a.title = "Zzz"
    

@@ -60,6 +61,7 @@
def test_html_title
a = Article.new
a.title = “This is a test

  •           a.blog_id = 1
    assert a.save
    assert_equal 'this-is-a-test', a.permalink
    

@@ -79,7 +81,7 @@
end
def test_tags

  • a = Article.new(:title => ‘Test tag article’,
  • a = Article.new(:title => ‘Test tag article’, :blog_id => 1,
    :keywords => ‘test tag tag stuff’);
    assert_kind_of Article, a
    @@ -139,7 +141,7 @@
    assert art.save
    assert !art.just_published?
  • art = Article.create!(:title => ‘title2’,
  • art = Article.create!(:title => ‘title2’, :blog_id => 2,
    :body => ‘body’,
    :published => false)
    @@ -148,17 +150,18 @@
    def test_future_publishing
    assert_sets_trigger(Article.create!(:title => ‘title’, :body =>
    ‘body’,
              :blog_id => 1,
                                      :published => true,
                                      :published_at => Time.now +

2.seconds))
end
def test_future_publishing_without_published_flag

  • assert_sets_trigger Article.create!(:title => ‘title’, :body =>
    ‘body’,
  • assert_sets_trigger Article.create!(:title => ‘title’, :body =>
    ‘body’, :blog_id => 1,
    :published_at => Time.now +
    2.seconds)
    end
    def test_triggers_are_dependent
  • art = Article.create!(:title => ‘title’, :body => ‘body’,
  • art = Article.create!(:title => ‘title’, :body =>
    ‘body’, :blog_id => 1,
    :published_at => Time.now + 1.hour)
    assert_equal 1, Trigger.count
    art.destroy
    @@ -178,8 +181,10 @@
    Article.create!(:title => “News from the future!”,
    :body => “The future is cool!”,
    :keywords => “future”,
  •    :blog_id                => 1,
                    :published_at => Time.now + 12.minutes)
    
  •           #print @articles.find(/future/)
    @articles = Category.find_by_permalink
    

(‘personal’).published_articles
assert_results_are :article1, :article2, :article3
@@ -199,7 +204,7 @@
end
def test_notifications

  • a = Article.new(:title => ‘New Article’, :body => ‘Foo’, :author
    => ‘Tobi’, :user => users(:tobi))
  • a = Article.new(:title => ‘New Article’, :blog_id => 1, :body =>
    ‘Foo’, :author => ‘Tobi’, :user => users(:tobi))
    assert a.save
    assert_equal 2, a.notify_users.size

It may get set by the database itself, I know on some versions of sql
you can have a table with a column with a default value set. I’ll
look into this a little bit later today.

As a complete aside, this is a great way to learn how Rails works.
Thanks for all the help with this, guys.

Matt

It could be done with a DB default, but I thought there was an
explicit
default set via some rails magic, maybe the scope code in
application.rb.
It doesn’t seem to work right all the time, though.

Scott

On 22 Jun 2006, at 02:32, Matt R. wrote:

However, this doesn’t really jibe with what everyone else is saying
on the list, as those tests shouldn’t be passing for anyone.

Yeah that’s got me confused. The tests all passed for me except that
one xml related one … but I need to update my test system for that
and it’s not down to Typo.

G

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