Question

I'm creating a plugin, and am looking to use RSpec so I can build it using BDD.

Is there a recommended method of doing this?

Was it helpful?

Solution

OK, I think I have a solution:

  • Generate the plugin via script/generate plugin
  • change the Rakefile, and add

require 'spec/rake/spectask'

desc 'Test the PLUGIN_NAME plugin.'
Spec::Rake::SpecTask.new(:spec) do |t|
  t.libs << 'lib'
  t.verbose = true
end

  • Create a spec directory, and begin adding specs in *_spec.rb files, as normal

You can also modify the default task to run spec instead of test, too.

OTHER TIPS

For an example of an existing plugin that uses rspec, check out the restful_authentication plugin. Maybe it will help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top