Module: Fix
- Defined in:
- lib/fix.rb,
lib/fix/db.rb,
lib/fix/it.rb,
lib/fix/on.rb,
lib/fix/dsl.rb,
lib/fix/its.rb,
lib/fix/test.rb,
lib/fix/subject.rb,
lib/fix/version.rb,
lib/fix/expectation.rb,
lib/fix/expectation_low.rb,
lib/fix/expectation_high.rb,
lib/fix/helper/it_helper.rb,
lib/fix/helper/on_helper.rb,
lib/fix/helper/its_helper.rb,
lib/fix/expectation_medium.rb,
lib/fix/helper/let_reader_helper.rb,
lib/fix/helper/let_writer_helper.rb,
lib/fix/helper/requirement_helper.rb,
lib/fix/helper/let_accessor_helper.rb
Overview
Namespace for the Fix framework.
Defined Under Namespace
Modules: DSL, Helper Classes: Expectation, ExpectationHigh, ExpectationLow, ExpectationMedium, It, Its, On, Subject, Test
Constant Summary collapse
- VERSION =
Gem version
File.open( Pathname.new(__FILE__).join '..', '..', '..', 'VERSION.semver' ).read.chomp.to_sym
Class Method Summary collapse
- .fetch_file_paths(args) ⇒ Object
- .process_args(args) ⇒ Object
-
.run(*args) ⇒ Object
This is the command line top-level run method.
Class Method Details
.fetch_file_paths(args) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/fix.rb', line 82 def self.fetch_file_paths args absolute_paths = Set.new args.map do |s| s = File.absolute_path s unless s.start_with? File::SEPARATOR if File.directory? s spec_files = File.join s, '**', '*_spec.rb' Dir.glob(spec_files).each {|spec_file| absolute_paths.add spec_file } else absolute_paths.add s end end if absolute_paths.empty? warn 'Sorry, files or directories not found.' exit 1 end absolute_paths end |
.process_args(args) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/fix.rb', line 28 def self.process_args args = { color: false, debug: false, hide_progress: false, seed: Random.new_seed, warnings: false } opt_parser = OptionParser.new do |opts| opts. = 'Usage: fix <files or directories> [options]' opts.separator '' opts.separator 'Specific options:' opts.on('--color', 'Enable color in the output.') do [:color] = (const_set :COLOR, true) end opts.on('--debug', 'Enable ruby debug') do [:debug] = $DEBUG = true end opts.on('--hide_progress', 'Disable progress reporter in the output.') do [:hide_progress] = (const_set :HIDE_PROGRESS, true) end opts.on('--seed [INTEGER]', Integer, 'Order of the tests') do |seed| [:seed] = seed end opts.on('--warnings', 'Enable ruby warnings') do [:warnings] = $VERBOSE = true end opts.separator '' opts.separator 'Common options:' opts.on_tail '--help', 'Show this message' do puts opts exit end opts.on_tail '--version', 'Show the version' do puts VERSION exit end end opt_parser.parse! args const_set :SEED, .fetch(:seed) end |
.run(*args) ⇒ Object
This is the command line top-level run method. Everything starts from here.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fix.rb', line 11 def self.run *args process_args args file_paths = fetch_file_paths args print '> fix' print ' --color' if defined? COLOR print ' --debug' if $DEBUG print ' --hide_progress' if defined? HIDE_PROGRESS print " --seed #{SEED}" if defined? SEED print ' --warnings' if $VERBOSE puts ' ' + file_paths.to_a.join(' ') require_relative File.join 'fix', 'dsl' file_paths.each {|file_path| require file_path } end |