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