Sha256: 01d14c1dcef22ad8e28fb203d0f9b8e4b8db5be7e24e6b4c04d507e25e82db14

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module Synvert
  describe Snippet do
    let(:snippets_path) { File.join(File.dirname(__FILE__), '.synvert-ruby') }
    let(:snippet) { Snippet.new(snippets_path) }
    after { FileUtils.rmdir(snippets_path) if File.exist?(snippets_path) }

    describe '.fetch_core_version' do
      it 'gets remote version' do
        stub_request(:get, 'https://rubygems.org/api/v1/versions/synvert-core.json').to_return(
          body: '[{"number":"0.4.2"}]'
        )
        expect(Snippet.fetch_core_version).to eq '0.4.2'
      end
    end

    describe 'sync' do
      it 'git clones snippets' do
        expect(Kernel).to receive(:system).with(
          "git clone https://github.com/xinminlabs/synvert-snippets-ruby.git #{snippets_path}"
        )
        snippet.sync
      end

      it 'git pull snippets' do
        FileUtils.mkdir snippets_path
        expect(Kernel).to receive(:system).with('git checkout .; git pull --rebase')
        snippet.sync
        FileUtils.cd File.dirname(__FILE__)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
synvert-1.2.0 spec/synvert/snippet_spec.rb
synvert-1.1.3 spec/synvert/snippet_spec.rb
synvert-1.1.2 spec/synvert/snippet_spec.rb