mirror of
				https://github.com/drapergem/draper
				synced 2023-03-27 23:21:17 -04:00 
			
		
		
		
	Update minitest integration
Since the integration is dependent on minitest-rails, use its test class. Did MiniTest::Spec::Decorator ever exist in this project?
This commit is contained in:
		
							parent
							
								
									984f33fc12
								
							
						
					
					
						commit
						7117b2ee33
					
				
					 4 changed files with 71 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ require 'draper/railtie' if defined?(Rails)
 | 
			
		|||
 | 
			
		||||
# 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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										63
									
								
								spec/minitest-rails/spec_type_spec.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								spec/minitest-rails/spec_type_spec.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue