Sha256: 38d3d881a7f0ae3c3b5ba515f5e0d2519ae21b4634773cb6f4da9f2e997ce3a9

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

class FakeHeroku
  RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'heroku_commands'), File.dirname(__FILE__))

  def initialize(args)
    @args = args
  end

  def run!
    File.open(RECORDER, 'a') do |file|
      file.puts @args.join(' ')
    end
  end

  def self.clear!
    FileUtils.rm_rf RECORDER
  end

  def self.has_gem_included?(project_path, gem_name)
    gemfile = File.open(File.join(project_path, 'Gemfile'), 'a')

    File.foreach(gemfile).any? do |line|
      line.match(/#{Regexp.quote(gem_name)}/)
    end
  end

  def self.has_created_app_for?(remote_name, flags = nil)
    app_name = "#{SuspendersTestHelpers::APP_NAME}-#{remote_name}"

    expected_line = if flags
      "create #{app_name} #{flags} --remote #{remote_name}\n"
    else
      "create #{app_name} --remote #{remote_name}\n"
    end

    File.foreach(RECORDER).any? { |line| line == expected_line }
  end

  def self.has_configured_vars?(remote_name, var)
    File.foreach(RECORDER).any? do |line|
      line =~ /^config:add #{var}=.+ --remote #{remote_name}\n$/
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
welaika-suspenders-2.7.1 spec/support/fake_heroku.rb
welaika-suspenders-2.7.0 spec/support/fake_heroku.rb
suspenders-1.24.0 spec/support/fake_heroku.rb
suspenders-1.23.0 spec/support/fake_heroku.rb
welaika-suspenders-2.6.0 spec/support/fake_heroku.rb
welaika-suspenders-2.5.0 spec/support/fake_heroku.rb
suspenders-1.22.0 spec/support/fake_heroku.rb