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
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/fix.rb', line 74 def self.fetch_file_paths args absolute_paths = Set.new args.map do |s| s = File.absolute_path s unless s.start_with? '/' 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.freeze end |
.process_args(args) ⇒ Object
25 26 27 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 |
# File 'lib/fix.rb', line 25 def self.process_args args = { seed: Random.new_seed, color: false, debug: false, warnings: false } opt_parser = OptionParser.new do |opts| opts. = 'Usage: fix <files or directories> [options]' opts.separator '' opts.separator 'Specific options:' opts.on('-c', '--color', 'Enable color in the output.') do [:color] = (const_set :COLOR, true) end opts.on('-s [INTEGER]', '--seed [INTEGER]', Integer, 'Order of the tests') do |seed| [:seed] = seed end opts.on('-d', '--debug', 'Enable ruby debug') do [:debug] = $DEBUG = true end opts.on('-w', '--warnings', 'Enable ruby warnings') do [:warnings] = $VERBOSE = true end opts.separator '' opts.separator 'Common options:' opts.on_tail '-h', '--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) .freeze end |
.run(*args) ⇒ Object
This is the command line top-level run method. Everything starts from here.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fix.rb', line 10 def self.run *args process_args args file_paths = fetch_file_paths args print "> fix --seed #{SEED}" print ' --color' if defined? COLOR print ' --debug' if $DEBUG 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 |