Sha256: 7d1f83c97d44c7affcc45ff491f81db9dc1bb5943a62749d7ae4ef4b2fc87ca2

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require_generator :observer

module RSpec::Core
  class ExampleGroup
    include RSpec::Rails::Observer
  end
end

describe 'observer_generator' do  
  before :each do              
    setup_generator 'observer_generator' do
      tests ObserverGenerator
    end    
    remove_observer 'account'    
  end

  after :each do              
    remove_observer 'account'    
  end
    
  it "should not work without an Account observer file" do            
    with_generator do |g|   
      name = 'account'
      g.run_generator [name]
      g.should_not generate_observer name
    end
  end

  it "should decorate an existing Account observer file with a 'observe_me' method" do            
    with_generator do |g|  
      name = 'account'
      create_observer name do
        '# observer content'
      end    
      g.run_generator [name]
      g.should generate_observer name do |content|        
        content.should have_observer_class name do |klass|
          klass.should have_method :observe_me
        end
      end
    end
  end
end



Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
generator-spec-0.5.0 spec/generator_spec/generators/observer_generator_spec.rb
generator-spec-0.4.8 spec/generator_spec/generators/observer_generator_spec.rb