Sha256: 6ce16b60e111c5b1490633fe67d2b92384ff6446950ee0610f9096ddafbb26fb

Contents?: true

Size: 1.29 KB

Versions: 21

Compression:

Stored size: 1.29 KB

Contents

# -*- encoding : utf-8 -*-

require "optparse"

module Decko
  class Commands
    class CucumberCommand
      class Parser < OptionParser
        class Flagger
          def initialize parser, opts
            @parser = parser
            @opts = opts
          end

          def add_flags
            add_flag "DEBUG", "-d", "--debug", "Drop into debugger on failure"
            add_flag "FAST", "-f", "--fast", "Stop on first failure"
            add_flag "LAUNCH", "-l", "--launchy", "Open page on failure"
            add_flag "STEP", "-s", "--step", "Pause after each step"
          end

          def add_flag flag, *args
            @parser.on(*args) { |a| @opts[:env] << "#{flag}=1" if a }
          end
        end

        def parse_spring parser, opts
          parser.on("--[no-]spring", "Run with spring") do |spring|
            opts[:executer] = spring ? "spring" : "bundle exec"
          end
        end

        def initialize opts
          super() do |parser|
            parser.banner = "Usage: decko cucumber [DECKO ARGS] -- [CUCUMBER ARGS]\n\n"
            parser.separator "\nDECKO ARGS"
            opts[:env] = ["RAILS_ROOT=. RAILS_ENV=cucumber"]
            Flagger.new(parser, opts).add_flags
            parse_spring parser, opts
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
decko-0.18.1 lib/decko/commands/cucumber_command/parser.rb
decko-0.18.0 lib/decko/commands/cucumber_command/parser.rb
decko-0.17.0 lib/decko/commands/cucumber_command/parser.rb
decko-0.16.0 lib/decko/commands/cucumber_command/parser.rb
decko-0.15.6 lib/decko/commands/cucumber_command/parser.rb
decko-0.15.5 lib/decko/commands/cucumber_command/parser.rb
decko-0.15.4 lib/decko/commands/cucumber_command/parser.rb
decko-0.15.3 lib/decko/commands/cucumber_command/parser.rb
decko-0.15.2.pre1 lib/decko/commands/cucumber_command/parser.rb
decko-0.15.1.1 lib/decko/commands/cucumber_command/parser.rb
decko-0.15.1 lib/decko/commands/cucumber_command/parser.rb
decko-0.15.0 lib/decko/commands/cucumber_command/parser.rb
decko-0.14.2 lib/decko/commands/cucumber_command/parser.rb
decko-0.14.1 lib/decko/commands/cucumber_command/parser.rb
decko-0.14.0 lib/decko/commands/cucumber_command/parser.rb
decko-0.13.4 lib/decko/commands/cucumber_command/parser.rb
decko-0.13.3 lib/decko/commands/cucumber_command/parser.rb
decko-0.13.2 lib/decko/commands/cucumber_command/parser.rb
decko-0.13.1 lib/decko/commands/cucumber_command/parser.rb
decko-0.13.0 lib/decko/commands/cucumber_command/parser.rb