Sha256: 4fedf2c8a1496ebe54a299ea42ad24547e4a24a831d0e9b840be14f0c7e34043

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

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

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

describe 'view_generator' do  
  before :each do              
    setup_generator 'view_generator' do
      tests ViewGenerator
    end    
    remove_view :account, :edit, 'html.erb'
  end

  after :each do              
    remove_view :account, :edit, 'html.erb'
  end
    
  it "should not work without an Edit Account view file" do            
    with_generator do |g|   
      name = :account
      action = :edit
      type = 'html.erb'
      g.run_generator [name, action, type].map(&:to_s)
      g.should_not generate_view name, action, type
    end
  end

  it "should decorate an existing Edit Account view file with some view code" do            
    with_generator do |g|  
      name = :account
      action = :edit
      type = 'html.erb'

      create_view name, action, type do
        '# view content'
      end    
      g.run_generator [name, action, type].map(&:to_s)
      g.should generate_view name, action, type do |file|
        file.should match /Hello You/
      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/view_generator_spec.rb
generator-spec-0.4.8 spec/generator_spec/generators/view_generator_spec.rb