Sha256: 4937b0f422b30392511cb10bd43424f5f5d295f8368ab5fa18a79ed6a9ae5f61

Contents?: true

Size: 1.23 KB

Versions: 11

Compression:

Stored size: 1.23 KB

Contents

desc 'rspec [FILES]', 'Run RSpec'
long_desc <<-LONGDESC
Example: `geordi rspec spec/models/user_spec.rb:13`

Runs RSpec with RSpec 1/2 support, parallel_tests detection and `bundle exec`.
LONGDESC

def rspec(*files)
  if File.exist?('spec/spec_helper.rb')
    invoke_geordi 'bundle_install'
    invoke_geordi 'yarn_install'

    Interaction.announce 'Running specs'

    if Util.file_containing?('Gemfile', /parallel_tests/) && files.empty?
      Interaction.note 'All specs at once (using parallel_tests)'
      Util.run!([Util.binstub_or_fallback('rake'), 'parallel:spec'], fail_message: 'Specs failed.')

    else
      # tell which specs will be run
      if files.empty?
        files << 'spec/'
        Interaction.note 'All specs in spec/'
      else
        Interaction.note 'Only: ' + files.join(', ')
      end

      command = if File.exist?('script/spec')
        ['bundle exec spec -c'] # RSpec 1
      else
        [Util.binstub_or_fallback('rspec')]
      end
      command << '-r rspec_spinner -f RspecSpinner::Bar' if Util.file_containing?('Gemfile', /rspec_spinner/)
      command << files.join(' ')

      puts
      Util.run!(command.join(' '), fail_message: 'Specs failed.')
    end
  else
    Interaction.note 'RSpec not employed.'
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
geordi-5.3.0 lib/geordi/commands/rspec.rb
geordi-5.2.4 lib/geordi/commands/rspec.rb
geordi-5.2.3 lib/geordi/commands/rspec.rb
geordi-5.2.2 lib/geordi/commands/rspec.rb
geordi-5.2.1 lib/geordi/commands/rspec.rb
geordi-5.2.0 lib/geordi/commands/rspec.rb
geordi-5.1.0 lib/geordi/commands/rspec.rb
geordi-5.0.0 lib/geordi/commands/rspec.rb
geordi-4.2.1 lib/geordi/commands/rspec.rb
geordi-4.2.0 lib/geordi/commands/rspec.rb
geordi-4.1.1 lib/geordi/commands/rspec.rb