Permalink
Browse files

Update minitest integration

Since the integration is dependent on minitest-rails, use its test class.
Did MiniTest::Spec::Decorator ever exist in this project?
  • Loading branch information...
1 parent 984f33f commit 7117b2ee3397e5011b82f25bc9ee088ac0a7408f @blowmage blowmage committed Sep 27, 2012
Showing with 71 additions and 5 deletions.
  1. +1 −0 draper.gemspec
  2. +1 −1 lib/draper.rb
  3. +6 −4 lib/draper/test/minitest_integration.rb
  4. +63 −0 spec/minitest-rails/spec_type_spec.rb
View
@@ -23,5 +23,6 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rake', '~> 0.9.2'
s.add_development_dependency 'rspec', '~> 2.10'
s.add_development_dependency 'yard'
+ s.add_development_dependency 'minitest-rails', '~> 0.2'
s.add_development_dependency 'minitest', '~> 3.0' if RUBY_PLATFORM == "java"
end
View
@@ -13,4 +13,4 @@
# Test Support
require 'draper/test/rspec_integration' if defined?(RSpec) and RSpec.respond_to?(:configure)
-require 'draper/test/minitest_integration' if defined?(MiniTest::Spec)
+require 'draper/test/minitest_integration' if defined?(MiniTest::Rails)
@@ -1,5 +1,7 @@
-require 'draper/test/view_context'
-
-MiniTest::Spec.register_spec_type(MiniTest::Spec::Decorator) do |desc|
- desc.superclass == Draper::Base
+class MiniTest::Rails::ActiveSupport::TestCase
+ # Use AS::TestCase for the base class when describing a decorator
+ register_spec_type(self) do |desc|
+ desc < Draper::Base if desc.is_a?(Class)
+ end
+ register_spec_type(/Decorator( ?Test)?\z/i, self)
end
@@ -0,0 +1,63 @@
+require 'spec_helper'
+require 'minitest/rails/active_support'
+require 'draper/test/minitest_integration'
+
+describe "minitest-rails spec_type Lookup Integration" do
+ context "ProductDecorator" do
+ it "resolves constants" do
+ klass = MiniTest::Spec.spec_type(ProductDecorator)
+ klass.should == MiniTest::Rails::ActiveSupport::TestCase
+ end
+
+ it "resolves strings" do
+ klass = MiniTest::Spec.spec_type("ProductDecorator")
+ klass.should == MiniTest::Rails::ActiveSupport::TestCase
+ end
+ end
+
+ context "WidgetDecorator" do
+ it "resolves constants" do
+ klass = MiniTest::Spec.spec_type(WidgetDecorator)
+ klass.should == MiniTest::Rails::ActiveSupport::TestCase
+ end
+
+ it "resolves strings" do
+ klass = MiniTest::Spec.spec_type("WidgetDecorator")
+ klass.should == MiniTest::Rails::ActiveSupport::TestCase
+ end
+ end
+
+ context "decorator strings" do
+ it "resolves DoesNotExistDecorator" do
+ klass = MiniTest::Spec.spec_type("DoesNotExistDecorator")
+ klass.should == MiniTest::Rails::ActiveSupport::TestCase
+ end
+
+ it "resolves DoesNotExistDecoratorTest" do
+ klass = MiniTest::Spec.spec_type("DoesNotExistDecoratorTest")
+ klass.should == MiniTest::Rails::ActiveSupport::TestCase
+ end
+
+ it "resolves Does Not Exist Decorator" do
+ klass = MiniTest::Spec.spec_type("Does Not Exist Decorator")
+ klass.should == MiniTest::Rails::ActiveSupport::TestCase
+ end
+
+ it "resolves Does Not Exist Decorator Test" do
+ klass = MiniTest::Spec.spec_type("Does Not Exist Decorator Test")
+ klass.should == MiniTest::Rails::ActiveSupport::TestCase
+ end
+ end
+
+ context "non-decorators" do
+ it "doesn't resolve constants" do
+ klass = MiniTest::Spec.spec_type(Draper::HelperSupport)
+ klass.should == MiniTest::Spec
+ end
+
+ it "doesn't resolve strings" do
+ klass = MiniTest::Spec.spec_type("Nothing to see here...")
+ klass.should == MiniTest::Spec
+ end
+ end
+end

0 comments on commit 7117b2e

Please sign in to comment.