Sha256: 45a6cd4f8676b0663d3a231b58525f3f7033e1335baa11564d5c2efa17e8a49d

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

require 'derketo/helpers'

describe Derketo::Helpers do
  class DummyClass
  end

  before(:each) do
    @dummy_class = DummyClass.new
    @dummy_class.extend(Derketo::Helpers)
  end

  describe '.clean' do
    it 'replaces "::" with "/"' do
      expect(@dummy_class.clean('::')).to eq('/')
    end

    it 'removes "#"' do
      expect(@dummy_class.clean('#')).to eq('')
    end

    it 'replaces ":" with "="' do
      expect(@dummy_class.clean(':')).to eq('=')
    end

    it 'removes "<"' do
      expect(@dummy_class.clean('<')).to eq('')
    end

    it 'removes ">"' do
      expect(@dummy_class.clean('>')).to eq('')
    end

    it 'replaces "," with "|"' do
      expect(@dummy_class.clean(',')).to eq('|')
    end
  end

  describe '.write' do
    before(:all) do
      Dir.mkdir(File.expand_path(File.dirname(__FILE__) + '../../tmp/'))
    end

    after(:all) do
      system("rm -r #{File.expand_path(File.dirname(__FILE__) + '../../tmp/')}")
    end

    it 'writes to a file' do
      filename = File.expand_path(File.dirname(__FILE__) + '../../tmp/test.txt')
      Derketo::Helpers.write(filename, 'test')
      expect(File.file?(filename)).to eq(true)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
derketo-0.1.2 spec/derketo/helpers_spec.rb
derketo-0.1.1 spec/derketo/helpers_spec.rb