Sha256: df2c9336c84fbed0a93a55d8a53625c7bccdd8d044795dd5f5abc229c7aaee54

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

# encoding: utf-8
require_relative "../lib/sublime_sunippetter"
require "spec_helper"

describe SublimeSunippetter::Core do
  cases_init = [
    {
    case_no: 1,
    expected: SublimeSunippetter::Core::DEFINE_FILE_TEMPLATE
    },
  ]

  cases_init.each do |c|
    it "#init case_no=#{c[:case_no]} generate #{SublimeSunippetter::Core::DEFINE_FILE}" do
      # given
      sunippet = SublimeSunippetter::Core.new

      # when
      sunippet.init

      # then
      actual = File.open("#{SublimeSunippetter::Core::DEFINE_FILE}") {|f|f.read}
      expect(actual).to eq(c[:expected])
    end
  end

  GENERATE_SUNIPPETS_CASE =<<-EOS
output_path "#{File.absolute_path('.')}"
scope "source.java"
add :hoge, :args1, :args2
add :hige
  EOS

  cases_generate_sunippets = [
    {
    case_no: 1,
    sunippetdefine: GENERATE_SUNIPPETS_CASE,
    output_file_names: ["hoge.sublime-snippet", "hige.sublime-snippet"],
    }
  ]

  context do
    before do
      File.open("./#{SublimeSunippetter::Core::DEFINE_FILE}", "w") {|f|f.puts GENERATE_SUNIPPETS_CASE}
    end
    
    cases_generate_sunippets.each do |c|

      it "#generate_sunippets case_no=#{c[:case_no]}" do
        # given
        sunippet = SublimeSunippetter::Core.new

        # when
        sunippet.generate_sunippets

        # then
        c[:output_file_names].each do |f|
          FileTest.exist?("./#{f}").should be_true
          File.delete("./#{f}")
        end
      end
    end
  end

  after(:each) do
    File.delete("#{SublimeSunippetter::Core::DEFINE_FILE}") if File.exists?("#{SublimeSunippetter::Core::DEFINE_FILE}")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sublime_sunippetter-0.0.2 spec/sublime_sunippetter_spec.rb
sublime_sunippetter-0.0.1 spec/sublime_sunippetter_spec.rb