Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Basic specs for plugin loading

  • Loading branch information...
commit 576a6817a039d611c1ab9bcaafa68e0a84c707b3 1 parent f5d481c
@ngollan ngollan authored
View
4 .rspec
@@ -0,0 +1,4 @@
+--color
+--format progress
+--format html
+--out rspec_results.html
View
24 Rakefile
@@ -1,4 +1,5 @@
require File.expand_path("../merb-core/lib/merb-core/version.rb", __FILE__)
+require File.expand_path("../merb/lib/merb/stack_info.rb", __FILE__)
require 'fileutils'
@@ -25,22 +26,7 @@ yard_local_options = [
['--no-yardopts']
]
-merb_stack_gems = [
- { :name => 'merb-core', :path => "#{ROOT}/merb-core", :doc => :yard },
- { :name => 'merb-action-args', :path => "#{ROOT}/merb-action-args", :doc => :yard },
- { :name => 'merb-assets', :path => "#{ROOT}/merb-assets", :doc => :yard },
- { :name => 'merb-slices', :path => "#{ROOT}/merb-slices", :doc => :yard },
- { :name => 'merb-cache', :path => "#{ROOT}/merb-cache", :doc => :yard },
- { :name => 'merb-gen', :path => "#{ROOT}/merb-gen", :doc => :yard },
- { :name => 'merb-haml', :path => "#{ROOT}/merb-haml", :doc => :yard },
- { :name => 'merb-helpers', :path => "#{ROOT}/merb-helpers", :doc => :yard },
- { :name => 'merb-mailer', :path => "#{ROOT}/merb-mailer", :doc => :yard },
- { :name => 'merb-param-protection', :path => "#{ROOT}/merb-param-protection", :doc => :yard },
- { :name => 'merb-exceptions', :path => "#{ROOT}/merb-exceptions", :doc => :yard },
- { :name => 'merb-auth', :path => "#{ROOT}/../merb-auth", :doc => :rdoc },
- { :name => 'merb_datamapper', :path => "#{ROOT}/../merb_datamapper", :doc => :rdoc },
- { :name => 'merb', :path => "#{ROOT}/merb", :doc => :rdoc }
-]
+merb_stack_gems = Merb::STACK_GEMS
def gem_command(command, *args)
sh "#{RUBY} -S gem #{command} #{args.join(' ')}"
@@ -54,7 +40,7 @@ end
desc "Install all merb stack gems"
task :install do
merb_stack_gems.each do |gem_info|
- Dir.chdir(gem_info[:path]) { rake_command "install" }
+ Dir.chdir(File.join(ROOT, gem_info[:path])) { rake_command "install" }
end
end
@@ -68,7 +54,7 @@ end
desc "Build all merb stack gems"
task :build do
merb_stack_gems.each do |gem_info|
- Dir.chdir(gem_info[:path]) { gem_command "build", "#{gem_info[:name]}.gemspec" }
+ Dir.chdir(File.join(ROOT, gem_info[:path])) { gem_command "build", "#{gem_info[:name]}.gemspec" }
end
end
@@ -76,7 +62,7 @@ desc "Run specs for all merb stack gems"
task :spec do
# Omit the merb metagem, no specs there
merb_stack_gems[0..-2].each do |gem_info|
- Dir.chdir(gem_info[:path]) { rake_command "spec" }
+ Dir.chdir(File.join(ROOT, gem_info[:path])) { rake_command "spec" }
end
end
View
25 merb/lib/merb/stack_info.rb
@@ -0,0 +1,25 @@
+module Merb
+ # List of gems in the Merb stack.
+ #
+ # The `:path` entry is relative to a root in a common development
+ # environment where all gems are residing under a common directory.
+ #
+ # @note Make sure that merb-core is always the first element.
+ STACK_GEMS = [
+ { :name => 'merb-core', :path => "merb-core", :doc => :yard, :repo => 'merb' },
+ { :name => 'merb-action-args', :path => "merb-action-args", :doc => :yard, :repo => 'merb' },
+ { :name => 'merb-assets', :path => "merb-assets", :doc => :yard, :repo => 'merb' },
+ { :name => 'merb-slices', :path => "merb-slices", :doc => :yard, :repo => 'merb' },
+ { :name => 'merb-cache', :path => "merb-cache", :doc => :yard, :repo => 'merb' },
+ { :name => 'merb-gen', :path => "merb-gen", :doc => :yard, :repo => 'merb' },
+ { :name => 'merb-haml', :path => "merb-haml", :doc => :yard, :repo => 'merb' },
+ { :name => 'merb-helpers', :path => "merb-helpers", :doc => :yard, :repo => 'merb' },
+ { :name => 'merb-mailer', :path => "merb-mailer", :doc => :yard, :repo => 'merb' },
+ { :name => 'merb-param-protection', :path => "merb-param-protection", :doc => :yard, :repo => 'merb' },
+ { :name => 'merb-exceptions', :path => "merb-exceptions", :doc => :yard, :repo => 'merb' },
+ { :name => 'merb-auth', :path => "../merb-auth", :doc => :rdoc, :repo => 'merb-auth' },
+ { :name => 'merb_datamapper', :path => "../merb_datamapper", :doc => :rdoc, :repo => 'merb_datamapper' },
+ { :name => 'merb', :path => "merb", :doc => :rdoc, :repo => 'merb' }
+ ]
+end
+
View
25 spec/plugins_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+shared_examples_for "a loadable plugin" do |plugin_info|
+ it "should be possible to load both a gem and its version.rb" do
+ plugin = plugin_info[:path]
+ lib_dir = plugin_path(plugin)
+
+ if File.directory?(lib_dir) && File.exist?(File.join(lib_dir, 'lib', plugin_info[:name], 'version.rb'))
+ $LOAD_PATH.unshift(File.join(lib_dir, 'lib'))
+ else
+ pending "No plugin found or missing version.rb at #{lib_dir}"
+ end
+
+ expect do
+ require File.join(plugin_info[:name], 'version')
+ require plugin_info[:name]
+ end.to_not raise_error
+ end
+end
+
+Merb::STACK_GEMS.each do |gem_info|
+ describe gem_info[:name] do
+ it_should_behave_like "a loadable plugin", gem_info
+ end
+end
View
11 spec/spec_helper.rb
@@ -0,0 +1,11 @@
+require "rubygems"
+require 'rspec'
+
+require File.expand_path("../../merb/lib/merb/stack_info", __FILE__)
+
+RSpec.configure do |config|
+ def plugin_path(relative_path, *elements)
+ subpath = File.join(relative_path, *elements)
+ File.expand_path(File.join('../../', subpath), __FILE__)
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.