Sha256: faa4f2c867a292985bee76cadd5360be45eaf30060b001c5d0baa9956a6c18b0

Contents?: true

Size: 1.67 KB

Versions: 23

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'
require 'generators/haml/command_controller/command_controller_generator'

describe Haml::Generators::CommandControllerGenerator, :type => :generator do
  it "should run all tasks in the generator" do
    gen = generator %w(foo_bar)
    expect(gen).to receive(:create_template_file)
    capture(:stdout) { gen.invoke_all }
  end

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

        subject { file('app/views/foo_bar_command/new.html.haml') }

        it { should exist }
        it { should contain('= command_form_for') }
      end

      describe "with specified action name" do
        before do
          run_generator %w(foo_bar create)
        end

        subject { file('app/views/foo_bar_command/create.html.haml') }

        it { should exist }
        it { should contain('= command_form_for') }
      end

      describe "with specified action name and attributes" do
        before do
          run_generator %w(foo_bar baz qux:string quux:string:required corge:enum grault:boolean garply:model other)
        end

        subject { file('app/views/foo_bar_command/baz.html.haml') }

        it { should exist }
        it { should contain('= command_form_for') }
        it { should contain('= f.input :qux') }
        it { should contain('= f.input :quux') }
        it { should contain('= f.input :corge, :collection => CorgeEnum.collection') }
        it { should contain('= f.input :grault') }
        it { should contain('= f.input :garply, :collection => Garply.all') }
        it { should contain('= f.input :other') }
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

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