Sha256: b1fdda162724c238853d455244ccaaec6787a2242e11787979c429e7290966ab

Contents?: true

Size: 1.6 KB

Versions: 23

Compression:

Stored size: 1.6 KB

Contents

require 'spec_helper'
require 'generators/riveter/command_controller/command_controller_generator'

describe Riveter::Generators::CommandControllerGenerator, :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_command_controller_file)
    expect(gen).to receive(:create_module_file)
    expect(gen).to receive(:add_command_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_command_controller.rb') }

        it { should exist }
        it { should contain('command_controller_for FooBarCommand') }
      end

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

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

        it { should exist }
        it { should contain('command_controller_for FooBarCommand, :new_action => :start, :create_action => :doit') }
      end
    end

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

Version data entries

23 entries across 23 versions & 1 rubygems

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