Sha256: dc69156c754001214a9205b06519e49e118501131df12debba8096af09c91267

Contents?: true

Size: 1.84 KB

Versions: 3

Compression:

Stored size: 1.84 KB

Contents

module Skellington
  describe CLI do
    let :subject do
      described_class.new
    end

    it 'generates an app file' do
      subject.generate 'dummy_app'
      expect('dummy_app/lib/dummy_app.rb').to have_content (
      """
      require 'sinatra/base'
      require 'tilt/erubis'

      require_relative 'dummy_app/racks'
      require_relative 'dummy_app/helpers'

      module DummyApp
        class App < Sinatra::Base
          helpers do
            include DummyApp::Helpers
          end

          get '/' do
            respond_to do |wants|
              wants.html do
                @content = '<h1>Hello from DummyApp</h1>'
                @title = 'DummyApp'
                erb :index, layout: :default
              end

              wants.json do
                {
                  app: 'DummyApp'
                }.to_json
              end
            end
          end

          # start the server if ruby file executed directly
          run! if app_file == $0
        end
      end
      """
      )

      expect('dummy_app/lib/dummy_app/racks.rb').to have_content (
      """
      require 'rack/conneg'

      module DummyApp
        class App < Sinatra::Base
          set :public_folder, 'public'
          set :views, 'views'

          use Rack::Conneg do |conneg|
            conneg.set :accept_all_extensions, false
            conneg.set :fallback, :html
            conneg.ignore_contents_of 'public'
            conneg.provide [
              :html,
              :json
            ]
          end

          before do
            if negotiated?
              content_type negotiated_type
            end
          end
        end
      end
      """
      )

      expect('dummy_app/lib/dummy_app/helpers.rb').to have_content (
      """
      module DummyApp
        module Helpers
        end
      end
      """
      )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
skellington-0.4.4 spec/cli/app_spec.rb
skellington-0.4.3 spec/cli/app_spec.rb
skellington-0.4.2 spec/cli/app_spec.rb