Sha256: 9ec7a6fa95acb5d1e2947620e7512a2b6bf110e73e9931ae4039306b9dd16b16

Contents?: true

Size: 1.17 KB

Versions: 7

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 |content|
        content.should match /Hello You/
      end
    end
  end
end



Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
generator-spec-0.4.7 spec/generator_spec/generators/view_generator_spec.rb
generator-spec-0.4.5 spec/generator_spec/view_generator_spec.rb
generator-spec-0.4.4 spec/generator_spec/view_generator_spec.rb
generator-spec-0.4.3 spec/rspec_for_generators/view_generator_spec.rb
generator-spec-0.4.2 spec/rspec_for_generators/view_generator_spec.rb
generator-spec-0.4.1 spec/rspec_for_generators/view_generator_spec.rb
generator-spec-0.4.0 spec/rspec_for_generators/view_generator_spec.rb