aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support/load_file_fixtures.rb
blob: 08079f6545e0096d967bc80b6f447bfb1dd752e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def file_fixture_name(file_name)
    return File.join(RSpec.configuration.fixture_path, "files", file_name)
end

def load_file_fixture(file_name, as_binary=false)
    file_name = file_fixture_name(file_name)
    content = File.open(file_name, 'r') do |file|
        if as_binary
            file.set_encoding(Encoding::BINARY) if file.respond_to?(:set_encoding)
        end
        file.read
    end
    return content
end