Rails Dispatch

Rails news delivered fresh

Presented by Engine Yard

View Question

Vote on questions you’d like to see answered by the expert contributors

Signup to ask questions or vote for the questions you’d like to see answered.

Test Driven Development for Rails 3 plugin development.

How would I go about this? It seems that currently, each plugin author has his own style etc. What is the recommended approach?

One “simple” but cumbersome solution is to symlink a gem into plugin/vendors of a minimalistic Rails 3 app and go from there.
But how can I test the plugin without having a full fledged Rails app as baggage?

I am trying something along these lines…

require ‘rspec’
require ‘my_rails_plugin’
require ‘active_support’
require ‘active_record’
require ‘action_controller’
require ‘action_view’

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

describe “MyRailsPlugin” do
it “should extend ActionView on load” do

ActiveSupport.on_load(:action_view) do include MyAddition end ActionView::Base.methods.grep(/xxx/).should_not be_empty end

end

Not even sure which exact class (is it Base?) that I am extending in this case, and how do I ensure that ActiveSupport loads my extension into ActionView?

I hope there is soon a part 2 to the series which goes into this.
Thanks!

I am trying to build a small Rails 3 plugin toolbox to simplify plugin development.

Kristian

Asked August 21, 2010