# Testing typo

**URL:** <https://www.ruby-forum.com/t/testing-typo/95932>\
**Category:** Typo\
**Created:** [June 20, 2006, 10:52am UTC](https://www.ruby-forum.com/t/testing-typo/95932 "2006-06-20T10:52:48Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 20, 2006, 10:52am UTC](https://www.ruby-forum.com/t/testing-typo/95932/1 "2006-06-20T10:52:48Z")

</div>

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:in `execute’  
/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:in `synchronize’  
/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:in `run’  
/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. removed\_email\_address@domain.invalid Visit my blog! http://

> **[Folkwolf.net](https://folkwolf.net/)**
>
> Descriptive Musings

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!

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 20, 2006, 10:52am UTC](https://www.ruby-forum.com/t/testing-typo/95932/2 "2006-06-20T10:52:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 20, 2006, 10:52am UTC](https://www.ruby-forum.com/t/testing-typo/95932/3 "2006-06-20T10:52:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 20, 2006, 10:52am UTC](https://www.ruby-forum.com/t/testing-typo/95932/4 "2006-06-20T10:52:49Z")

</div>

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

Scott

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 20, 2006, 10:52am UTC](https://www.ruby-forum.com/t/testing-typo/95932/5 "2006-06-20T10:52:49Z")

</div>

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

Matt

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 20, 2006, 10:52am UTC](https://www.ruby-forum.com/t/testing-typo/95932/6 "2006-06-20T10:52:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 22, 2006, 3:34am UTC](https://www.ruby-forum.com/t/testing-typo/95932/7 "2006-06-22T03:34:41Z")

</div>

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:in`create!’  
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

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 21, 2006, 8:10am UTC](https://www.ruby-forum.com/t/testing-typo/95932/8 "2006-06-21T08:10:19Z")

</div>

Matt R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 22, 2006, 5:50am UTC](https://www.ruby-forum.com/t/testing-typo/95932/9 "2006-06-22T05:50:40Z")

</div>

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

Scott

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 22, 2006, 4:02am UTC](https://www.ruby-forum.com/t/testing-typo/95932/10 "2006-06-22T04:02:25Z")

</div>

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:

mattrose@venice:~/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:in`create!’  
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:in`create!’  
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:in`create!’  
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:in`create!’  
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:in`create!’  
article\_test.rb.orig:161:in `test\_triggers\_are\_dependent’

21 tests, 45 assertions, 4 failures, 5 errors

After:

mattrose@venice:~/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

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 22, 2006, 1:40pm UTC](https://www.ruby-forum.com/t/testing-typo/95932/11 "2006-06-22T13:40:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 22, 2006, 5:48pm UTC](https://www.ruby-forum.com/t/testing-typo/95932/12 "2006-06-22T17:48:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [June 22, 2006, 11:41am UTC](https://www.ruby-forum.com/t/testing-typo/95932/13 "2006-06-22T11:41:57Z")

</div>

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
