Permalink
Browse files

Converting from test unit (rails plugin) to specs

  • Loading branch information...
1 parent 8951359 commit 94edf98f68d516597a9f6aaaa6676c24a81e5f25 Robert Evans committed Feb 26, 2008
Showing with 47 additions and 4 deletions.
  1. +1 −1 README
  2. +37 −2 spec/permalizer_spec.rb
  3. +9 −1 spec/spec_helper.rb
View
@@ -1,4 +1,4 @@
permalizer
==========
-A plugin for the Merb framework that provides ...
+An easy way to create clean URLs.
@@ -1,7 +1,42 @@
require File.dirname(__FILE__) + '/spec_helper'
+MERB_PERMALIZER_ROOT = File.dirname(__FILE__) + "/.."
+# same structure as merb_helpers
describe "permalizer" do
- it "should do nothing" do
- true.should == true
+
+ def unload_permalizer
+ Merb.class_eval do
+ remove_const("Permalizer") if defined?(Merb::Permalizer)
+ end
end
+
+ def reload_permalizer
+ unload_permalizer
+ load(MERB_PERMALIZER_ROOT + "/lib/permalizer.rb")
+ end
+
+ before(:each) do
+ unload_permalizer
+ end
+
+ after(:all) do
+ reload_permalizer
+ end
+
+ it "should not have permalizer" do
+ unload_permalizer
+ defined?(Merb::Permalizer).should be_nil
+ end
+
+ it "should load permalizer" do
+ unload_permalizer
+ reload_permalizer
+ defined?(Merb::Permalizer).should_not be_nil
+ end
+
+ it "should load permalizer by default" do
+ reload_permalizer
+ defined?(Merb::Permalizer).should_not be_nil
+ end
+
end
View
@@ -1,2 +1,10 @@
$TESTING=true
-$:.push File.join(File.dirname(__FILE__), '..', 'lib')
+$:.push File.join(File.dirname(__FILE__), '..', 'lib')
+require 'rubygems'
+require 'merb'
+require 'merb/test/rspec'
+
+Spec::Runner.configure do |config|
+ config.include(Merb::Test::Helper)
+ config.include(Merb::Test::RspecMatchers)
+end

0 comments on commit 94edf98

Please sign in to comment.