Forum: RSpec RSpec for Rails plugin

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
20ee0d23c969c7740d3c936a4675bb23?d=identicon&s=25 Sarah Allen (ultrasaurus)
on 2009-05-19 18:54
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
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-05-19 22:08
(Received via mailing list)
On Tue, May 19, 2009 at 11:54 AM, Sarah Allen <lists@ruby-forum.com>
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-generato...
20ee0d23c969c7740d3c936a4675bb23?d=identicon&s=25 Sarah Allen (ultrasaurus)
on 2009-05-23 06:30
David Chelimsky wrote:
> Check out Pat's rspec plugin generator:
>
> http://github.com/pat-maddox/rspec-plugin-generato...

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-gen...

I'm following along with http://guides.rubyonrails.org/plugins.html 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
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-05-24 00:18
(Received via mailing list)
On Sat, May 23, 2009 at 12:30 AM, Sarah Allen <lists@ruby-forum.com>
wrote:
> I'm following along with http://guides.rubyonrails.org/plugins.html 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
This topic is locked and can not be replied to.