Rails 3 plugin development - recommended RSpec practices?

I have been thinking that there must be some better ways of doing
Rails plugin development than my current approach. Currently I tend to
have my plugin in one location as a gem and then link to it from some
fresh Rails 3 app, from the vendor/plugins folder, with a symlink.
Then I have to carry around the whole Rails 3 app as baggage for
development. What are some better options?

There must be some libraries, tools out there specifically to meet
this need?
Seems like various plugin developers each have their own setup for
doing this!?

I tend to use RSpec 2 for all my testing needs. How does rspec-rails
fit into this? Would it be better to use Steak or Cucumber for this?

Thanks.

Looking at Ryan B’s CanCan for inspiration

require ‘rspec’
require ‘rspec/autorun’
require ‘active_support’
require ‘active_record’
require ‘action_controller’
require ‘action_view’
require ‘rails3_plugin_toolbox’

RSpec.configure do |config|
config.mock_with :rr
end


require “spec_helper”

describe CanCan::ControllerAdditions do
before(:each) do
@controller_class = Class.new
@controller = @controller_class.new
stub(@controller).params { {} }
stub(@controller).current_user { :current_user }
mock(@controller_class).helper_method(:can?, :cannot?)
@controller_class.send(:include, CanCan::ControllerAdditions)
end

So here he uses a stub and mock approach…

I would like to use the approach described on Rails Dispatch:
http://www.railsdispatch.com/

module MyAddition
def hello
puts “Hello from MyAddition”
end
end

ActiveSupport.on_load(:action_view) do
include MyAddition
end

ActiveSupport.on_load(:action_controller) do
include MyAddition
end

Could I then spec sth. like this?

ActionController.methods.grep(/hello/).should_not be_empty

ActionView.methods.grep(/hello/).should_not be_empty

or how would I go about it?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs