# Writing tests for plugins

**URL:** <https://www.ruby-forum.com/t/writing-tests-for-plugins/59259>\
**Category:** Rails\
**Created:** [May 2, 2006, 8:59pm UTC](https://www.ruby-forum.com/t/writing-tests-for-plugins/59259 "2006-05-02T20:59:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 2, 2006, 8:59pm UTC](https://www.ruby-forum.com/t/writing-tests-for-plugins/59259/1 "2006-05-02T20:59:51Z")

</div>

I’ve been googling around trying to find some tips on creating tests for  
plugins. Am I correct in assuming that I’d have to have the tests as  
part of a rails app in order to test the plugin? I’d like to find a way  
to do standalone tests for the plugin.

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 3, 2006, 7:05pm UTC](https://www.ruby-forum.com/t/writing-tests-for-plugins/59259/2 "2006-05-03T19:05:20Z")

</div>

On May 2, 2006, at 11:59 AM, Chris H. wrote:

> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Chris-

```
It really depends on what sort of plugin you are creating. But you

```

can take a look at a few of my plugins to see how I test one of them  
without rails and another with fixtures and all.

acl\_system does all its tests without the need for rails at all. It  
even has a mock controller object so you can test before filters and  
such without a full rails env.

[http://opensvn.csie.org/ezra/rails/plugins/dev/acl\_system2/](http://opensvn.csie.org/ezra/rails/plugins/dev/acl_system2/)

ez\_where is a think layer of ruby syntax sugar for  
ActiveRecord :condition building. It has fixtures and other stuff  
that ties into rails testing.

[http://opensvn.csie.org/ezra/rails/plugins/dev/ez\_where/](http://opensvn.csie.org/ezra/rails/plugins/dev/ez_where/)

```
Hopefully you can learn a little bit from the tests in these plugins.

```

-Ezra

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 3, 2006, 7:06pm UTC](https://www.ruby-forum.com/t/writing-tests-for-plugins/59259/3 "2006-05-03T19:06:31Z")

</div>

Ezra,  
I just checked out the ez\_where testing methods and am very  
impressed. I like the way sqlite is used in memory and then the  
fixtures are loaded as in a normal rails env. It allows for complete  
testing but with it all contained in the plugin without stepping on  
the app.  
Thanks for pointing these out as ways to learn.

Zack

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 3, 2006, 7:06pm UTC](https://www.ruby-forum.com/t/writing-tests-for-plugins/59259/4 "2006-05-03T19:06:32Z")

</div>

One more thing… if anyone can point me to more examples of testing  
controllers in plugins that would be great.

Thanks,  
Zack
