Sha256: 040807c6dab5533176a724cdbf58742e193b68242bc4e4e4aea588240c74f710

Contents?: true

Size: 1.98 KB

Versions: 11

Compression:

Stored size: 1.98 KB

Contents

require File.join(File.dirname(__FILE__), "..", "spec_helper" )
                
describe MoleFeature do                         
  before( :each ) do                                                                    
    ::Mole.reset_configuration!
    ::Mole.initialize( :application => "Test", 
                       :mode        => :persistent, 
                       :log_level   => :debug, 
                       :moleable    => true )
  end
                      
  it "should find or create known features correctly" do
    %w[ all performance exception].each do |f|
      feature = MoleFeature.send( "find_#{f}_feature".to_sym, ::Mole.application )
      feature.should_not           be_nil    
      feature.name.downcase.should == f
    end
  end     
  
  it "should create a new feature" do
    feature = MoleFeature.find_or_create_feature( "Fred", ::Mole.application, self.class.name )
    feature.should_not     be_nil
    feature.name.should    == "Fred"
    feature.context.should == self.class.name
  end  
  
  it "should not create a feature with no name" do
    feature = MoleFeature.find_or_create_feature( "", ::Mole.application, self.class.name )
    feature.should be_nil
  end    
  
  it "should find all features for a given application correctly" do
    %w[ all performance exception].each do |f|
      MoleFeature.send( "find_#{f}_feature".to_sym, ::Mole.application )
    end                                                                              
    MoleFeature.find_or_create_feature( "Fred", ::Mole.application, self.class.name )
    features = MoleFeature.find_features( ::Mole.application )
    features.should have(4).mole_features
  end     
  
  it "should find moled application names correctly" do
    MoleFeature.find_moled_application_names.should be_empty
    %w[ all performance exception].each do |f|
      feature = MoleFeature.send( "find_#{f}_feature".to_sym, ::Mole.application )
    end
    MoleFeature.find_moled_application_names.should == ["Test"]
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
derailed-mole-1.0.10 spec/models/mole_feature_spec.rb
mole-1.0.3 spec/models/mole_feature_spec.rb
mole-1.0.8 spec/models/mole_feature_spec.rb
mole-1.0.9 spec/models/mole_feature_spec.rb
mole-1.0.11 spec/models/mole_feature_spec.rb
mole-1.0.2 spec/models/mole_feature_spec.rb
mole-1.0.4 spec/models/mole_feature_spec.rb
mole-1.0.5 spec/models/mole_feature_spec.rb
mole-1.0.6 spec/models/mole_feature_spec.rb
mole-1.0.7 spec/models/mole_feature_spec.rb
mole-1.0.12 spec/models/mole_feature_spec.rb