RSpec for Rails plugin

I’m trying to write specs to test a Rails plugin and I’m not clear on
what needs to be installed and required. Works fine for many specs, but
view testing fails (i.e. anything relying rspec-rails over just rspec).

In other words, how can I use the rspec-rails gem to test a plugin?

Thanks,
Sarah

On Tue, May 19, 2009 at 11:54 AM, Sarah A. [email protected]
wrote:

I’m trying to write specs to test a Rails plugin and I’m not clear on
what needs to be installed and required. Works fine for many specs, but
view testing fails (i.e. anything relying rspec-rails over just rspec).

In other words, how can I use the rspec-rails gem to test a plugin?’

Check out Pat’s rspec plugin generator:

http://github.com/pat-maddox/rspec-plugin-generator/tree/master

David C. wrote:

Check out Pat’s rspec plugin generator:

http://github.com/pat-maddox/rspec-plugin-generator/tree/master

Hey thanks. That sounds like just the thing, but I’m kind of new to
this stuff. I guessed where to put it and it seemed to work so far.
I’m adding notes as I go to the wiki:
http://wiki.github.com/pat-maddox/rspec-plugin-generator/installation-and-basic-use

I’m following along with The Basics of Creating Rails Plugins — Ruby on Rails Guides but
I’m feeling my way around in the dark a bit since I’m relatively new to
rspec and plugins. If anyone is inspired to read the new wiki page and
let me know if there’s any points I’m missing, that would be nice.

I expected to be able to run ‘spec:plugins’ but it appears to have no
effect:
$ rake spec:plugins
(in /Users/sarah/src/yaffle_guide)

It does work if I call spec on the spec.rb file

$ spec vendor/plugins/yaffle/spec/yaffle_spec.rb
– create_table(:hickwalls, {:force=>true})
→ 0.0663s
– create_table(:wickwalls, {:force=>true})
→ 0.0114s
– create_table(:woodpeckers, {:force=>true})
→ 0.0075s
– initialize_schema_migrations_table()
→ 0.0011s
– assume_migrated_upto_version(0)
→ 0.0009s
.

Finished in 0.005407 seconds

1 example, 0 failures

With a plugin that has many spec.rb files, how do I run all of them?

Thanks,
Sarah

On Sat, May 23, 2009 at 12:30 AM, Sarah A. [email protected]
wrote:

I’m following along with The Basics of Creating Rails Plugins — Ruby on Rails Guides but

→ 0.0009s
.

Finished in 0.005407 seconds

1 example, 0 failures

With a plugin that has many spec.rb files, how do I run all of them?

I’m not sure why ‘rake spec:plugins’ is not working for you, but short
of solving that problem, you can type the spec command directly if you
have rspec and rspec-rails gems installed:

spec vendor/plugins/yaffle/spec

By default, that will pick up all the files below
vendor/plugins/yaffle/spec that end in _spec.rb. You can learn more
about how to use the command by typing:

spec --help

Cheers,
David