Sha256: d7930fcdd139af7a04a5f8527b0bc178e3e741f547861ca1888d2d74249e8a14

Contents?: true

Size: 1.67 KB

Versions: 23

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'
require 'generators/haml/enquiry_controller/enquiry_controller_generator'

describe Haml::Generators::EnquiryControllerGenerator, :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_enquiry/index.html.haml') }

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

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

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

        it { should exist }
        it { should contain('= enquiry_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_enquiry/baz.html.haml') }

        it { should exist }
        it { should contain('= enquiry_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.0.5 spec/generators/haml/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.0.4 spec/generators/haml/enquiry_controller/enquiry_controller_generator_spec.rb
riveter-0.0.3 spec/generators/haml/enquiry_controller/enquiry_controller_generator_spec.rb