Sha256: bab860c6b6e702b5e9ece72fc06fdb19ed9e5d9a8359dc8b389a75294ecf61ff

Contents?: true

Size: 1.57 KB

Versions: 23

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'
require 'generators/riveter/enquiry_controller/enquiry_controller_generator'

describe Riveter::Generators::EnquiryControllerGenerator, :type => :generator do
  before do
    FileUtils.mkdir_p(file('config'))
    File.open(file('config/routes.rb'), 'w') {|f| f.write "TestApp::Application.routes.draw do\nend\n" }
  end

  it "should run all tasks in the generator" do
    gen = generator %w(foo_bar)
    expect(gen).to receive(:create_enquiry_controller_file)
    expect(gen).to receive(:create_module_file)
    expect(gen).to receive(:add_enquiry_route)

    # hooks
    expect(gen).to receive(:_invoke_from_option_template_engine)
    expect(gen).to receive(:_invoke_from_option_test_framework)

    capture(:stdout) { gen.invoke_all }
  end

  describe "the generated files" do
    describe "the controller" do
      describe "with defaults" do
        before do
          run_generator %w(foo_bar)
        end

        subject { file('app/controllers/foo_bar_enquiry_controller.rb') }

        it { should exist }
        it { should contain('enquiry_controller_for FooBarEnquiry') }
      end

      describe "with action names" do
        before do
          run_generator %w(foo_bar showme)
        end

        subject { file('app/controllers/foo_bar_enquiry_controller.rb') }

        it { should exist }
        it { should contain('enquiry_controller_for FooBarEnquiry, :action => :showme') }
      end
    end

    it_should_behave_like 'a generator with a module', 'app/controllers'
    it_should_behave_like 'a generator with output to routes', 'enquiry :foo_bar'
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
riveter-0.8.3 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.8.2 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.8.1 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.8.0 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.7.0 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.6.0 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.3.0 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.2.1 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.2.0 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.1.1 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.0.15 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.0.14 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.0.13 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.0.12 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.0.11 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.0.10 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.0.9 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.0.8 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.0.7 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.0.6 spec/generators/riveter/enquiry_controller/enquiry_controller_generator_spec.rb