spec/spec_helper.rb in merb-gen-1.0.15 vs spec/spec_helper.rb in merb-gen-1.1.0.pre
- old
+ new
@@ -1,16 +1,65 @@
-$:.push File.join(File.dirname(__FILE__), '..', 'lib')
+require "rubygems"
-require 'rubygems'
-require 'spec'
+# Use current merb-core sources if running from a typical dev checkout.
+lib = File.expand_path('../../../merb-core/lib', __FILE__)
+$LOAD_PATH.unshift(lib) if File.directory?(lib)
require 'merb-core'
-require 'merb-gen'
+
+# The lib under test
+require "merb-gen"
+
+# Satisfies Autotest and anyone else not using the Rake tasks
+require 'spec'
+
+# Templater spec support
require 'templater/spec/helpers'
Merb.disable(:initfile)
Spec::Runner.configure do |config|
config.include Templater::Spec::Helpers
+end
+
+describe "app generator", :shared => true do
+
+ describe "#gems_for_orm" do
+ [:activerecord, :sequel, :datamapper].each do |orm|
+ it "should generate DSL for #{orm} ORM plugin" do
+ @generator.gems_for_orm(orm).should == %Q{gem "merb_#{orm}"}
+ end
+ end
+
+ it "should not generate DSL if we don't use ORM" do
+ @generator.gems_for_orm(:none).should == ''
+ end
+ end
+
+ describe "#gems_for_template_engine" do
+ [:haml, :builder].each do |engine|
+ it "should generate DSL for #{engine} template engine plugin" do
+ @generator.gems_for_template_engine(engine).should == %Q{gem "merb-#{engine}"}
+ end
+ end
+
+ it "should generate DSL for template engine plugins other than haml and builder" do
+ @generator.gems_for_template_engine(:liquid).should == 'gem "merb_liquid"'
+ end
+
+ it "should not generate DSL if we use erb" do
+ @generator.gems_for_template_engine(:erb).should == ''
+ end
+ end
+
+ describe "#gems_for_testing_framework" do
+ it "should generate DSL for testing framework plugin" do
+ @generator.gems_for_testing_framework(:test_unit).should == 'gem "test_unit", :group => :test'
+ end
+
+ it "should not generate DSL if we use rspec" do
+ @generator.gems_for_testing_framework(:rspec).should == ''
+ end
+ end
end
describe "named generator", :shared => true do
describe '#file_name' do