Sha256: c487904971f1ca8d76096c596723ef6b6b02929d8617eafb75f4062b83d192d5

Contents?: true

Size: 845 Bytes

Versions: 16

Compression:

Stored size: 845 Bytes

Contents

module TestHelper
  module Rails
    def call
      super

      content = File.read(path)

      regexp = Regexp.new(
        '(' + start_of_requires.source + '.+?\n\n)',
        Regexp::MULTILINE
      )
      requires = project.requires_with_rr(@requires)
      require_lines = project.require_lines(requires).
        map { |str| "#{str}\n" }.
        join
      unless content.gsub!(regexp, '\1' + require_lines + "\n")
        raise "Regexp didn't match!\nRegex: #{regexp}\nContent:\n#{content}"
      end

      content << "\n\n" + @prelude

      File.open(path, 'w') { |f| f.write(content) }

      if RR.debug?
        puts "~ Content of #{File.basename(path)} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
        puts File.read(path)
        puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rr-3.1.1 spec/support/test_helper/rails.rb
rr-3.1.0 spec/support/test_helper/rails.rb
rr-3.0.9 spec/support/test_helper/rails.rb
rr-3.0.8 spec/support/test_helper/rails.rb
rr-3.0.7 spec/support/test_helper/rails.rb
rr-3.0.6 spec/support/test_helper/rails.rb
rr-3.0.5 spec/support/test_helper/rails.rb
rr-3.0.4 spec/support/test_helper/rails.rb
rr-3.0.3 spec/support/test_helper/rails.rb
rr-3.0.2 spec/support/test_helper/rails.rb
rr-3.0.1 spec/support/test_helper/rails.rb
rr-3.0.0 spec/support/test_helper/rails.rb
rr-1.2.1 spec/support/test_helper/rails.rb
rr-1.2.0 spec/support/test_helper/rails.rb
rr-1.1.2 spec/support/test_helper/rails.rb
rr-1.1.2.rc1 spec/support/test_helper/rails.rb