Sha256: a2ef83826efcce6ed338050795b04b7a172c35e5a04d6957d7b83f95224050af

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

# Generators are not automatically loaded by Rails
require 'generators/rspec/view/view_generator'

describe Rspec::Generators::ViewGenerator do
  # Tell the generator where to put its output (what it thinks of as Rails.root)
  destination File.expand_path("../../../../../tmp", __FILE__)

  before { prepare_destination }

  describe 'with default template engine' do
    it 'generates a spec for the supplied action' do
      run_generator %w(posts index)
      file('spec/views/posts/index.html.erb_spec.rb').tap do |f|
        f.should contain /require 'spec_helper'/
        f.should contain /describe "posts\/index.html.erb"/
      end
    end

    describe 'with a nested resource' do
      it 'generates a spec for the supplied action' do
        run_generator %w(admin/posts index)
        file('spec/views/admin/posts/index.html.erb_spec.rb').tap do |f|
          f.should contain /require 'spec_helper'/
          f.should contain /describe "admin\/posts\/index.html.erb"/
        end
      end
    end
  end

  describe 'haml' do
    it 'generates a spec for the supplied action' do
      run_generator %w(posts index --template_engine haml)
      file('spec/views/posts/index.html.haml_spec.rb').tap do |f|
        f.should contain /require 'spec_helper'/
        f.should contain /describe "posts\/index.html.haml"/
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-rails-2.8.0.rc2 spec/generators/rspec/view/view_generator_spec.rb
rspec-rails-2.8.0.rc1 spec/generators/rspec/view/view_generator_spec.rb
rspec-rails-2.7.0 spec/generators/rspec/view/view_generator_spec.rb
rspec-rails-2.7.0.rc1 spec/generators/rspec/view/view_generator_spec.rb