Sha256: 0a156e7c263ec514b4424d59a8138669d224391f481ffd025975c95305b2a490

Contents?: true

Size: 1.43 KB

Versions: 7

Compression:

Stored size: 1.43 KB

Contents

require_relative 'base_helpers'
require_relative '../../tests/command_runner'

module AcceptanceTests
  module CommandHelpers
    include BaseHelpers
    extend RSpec::Matchers::DSL

    def run_command(*args)
      Tests::CommandRunner.run(*args) do |runner|
        runner.directory = fs.project_directory
        yield runner if block_given?
      end
    end

    def run_command!(*args)
      run_command(*args) do |runner|
        runner.run_successfully = true
        yield runner if block_given?
      end
    end

    def run_command_within_bundle(*args)
      run_command(*args) do |runner|
        runner.command_prefix = 'bundle exec'
        runner.env['BUNDLE_GEMFILE'] = fs.find_in_project('Gemfile').to_s

        runner.around_command do |run_command|
          Bundler.with_clean_env(&run_command)
        end

        yield runner if block_given?
      end
    end

    def run_command_within_bundle!(*args)
      run_command_within_bundle(*args) do |runner|
        runner.run_successfully = true
        yield runner if block_given?
      end
    end

    def run_rake_tasks(*tasks)
      options = tasks.last.is_a?(Hash) ? tasks.pop : {}
      args = ['rake', *tasks, '--trace'] + [options]
      run_command_within_bundle(*args)
    end

    def run_rake_tasks!(*tasks)
      options = tasks.last.is_a?(Hash) ? tasks.pop : {}
      args = ['rake', *tasks, '--trace'] + [options]
      run_command_within_bundle!(*args)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shoulda-matchers-3.1.3 spec/support/acceptance/helpers/command_helpers.rb
shoulda-matchers-3.1.2 spec/support/acceptance/helpers/command_helpers.rb
shoulda-matchers-3.1.1 spec/support/acceptance/helpers/command_helpers.rb
shoulda-matchers-3.1.0 spec/support/acceptance/helpers/command_helpers.rb
shoulda-matchers-3.0.1 spec/support/acceptance/helpers/command_helpers.rb
shoulda-matchers-3.0.0 spec/support/acceptance/helpers/command_helpers.rb
shoulda-matchers-3.0.0.rc1 spec/support/acceptance/helpers/command_helpers.rb