Sha256: bdb50dcce22da77bb91b877535a27acde62d3b2e61f3344f1f4f2542ad5d0a0f

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

require 'test_helper'
require 'generators/apotomo/widget_generator'

class WidgetGeneratorTest < Rails::Generators::TestCase
  destination File.join(Rails.root, "tmp")
  setup :prepare_destination
  tests ::Apotomo::Generators::WidgetGenerator
   
  context "Running rails g apotomo::widget" do
    context "Gerbil squeak snuggle" do
      should "create the standard assets" do
        
        run_generator %w(Gerbil squeak snuggle -t test_unit)
        
        assert_file "app/widgets/gerbil_widget.rb", /class GerbilWidget < Apotomo::Widget/
        assert_file "app/widgets/gerbil_widget.rb", /def snuggle/
        assert_file "app/widgets/gerbil_widget.rb", /def squeak/
        assert_file "app/widgets/gerbil/snuggle.html.erb", %r(app/widgets/gerbil/snuggle\.html\.erb)
        assert_file "app/widgets/gerbil/snuggle.html.erb", %r(<p>)
        assert_file "app/widgets/gerbil/squeak.html.erb", %r(app/widgets/gerbil/squeak\.html\.erb)

        assert_file "test/widgets/gerbil_widget_test.rb", %r(class GerbilWidgetTest < Apotomo::TestCase)
        assert_file "test/widgets/gerbil_widget_test.rb", %r(widget\(:gerbil, 'me'\))
      end
      
      should "create haml assets with -e haml" do
        run_generator %w(Gerbil squeak snuggle -e haml -t test_unit)
        
        assert_file "app/widgets/gerbil_widget.rb", /class GerbilWidget < Apotomo::Widget/
        assert_file "app/widgets/gerbil_widget.rb", /def snuggle/
        assert_file "app/widgets/gerbil_widget.rb", /def squeak/
        assert_file "app/widgets/gerbil/snuggle.html.haml", %r(app/widgets/gerbil/snuggle\.html\.haml)
        assert_file "app/widgets/gerbil/snuggle.html.haml", %r(%p)
        assert_file "app/widgets/gerbil/squeak.html.haml", %r(app/widgets/gerbil/squeak\.html\.haml)
        assert_file "test/widgets/gerbil_widget_test.rb"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
apotomo-1.1.0 test/rails/widget_generator_test.rb
apotomo-1.1.0.rc1 test/rails/widget_generator_test.rb