Sha256: 3b7298e14c7fc9fcd533d37b1433842e5a9d4d971162acf8d86ca9937034d6df
Contents?: true
Size: 1.16 KB
Versions: 9
Compression:
Stored size: 1.16 KB
Contents
require 'spec_helper' module Synvert::Core RSpec.describe Utils do describe '.eval_snippet' do it 'evals snippet by http url' do expect_any_instance_of(URI).to receive(:open).and_return(StringIO.new("Rewriter.new 'group', 'name' do\nend")) rewriter = described_class.eval_snippet('http://example.com/rewriter.rb') expect(rewriter.group).to eq 'group' expect(rewriter.name).to eq 'name' end it 'adds snippet by file path' do expect(File).to receive(:exist?).and_return(true) expect(File).to receive(:read).and_return("Rewriter.new 'group', 'name' do\nend") rewriter = described_class.eval_snippet('/home/richard/foo/bar.rb') expect(rewriter.group).to eq 'group' expect(rewriter.name).to eq 'name' end it 'adds snippet by snippet name' do expect(File).to receive(:exist?).and_return(false) expect(File).to receive(:read).and_return("Rewriter.new 'group', 'name' do\nend") rewriter = described_class.eval_snippet('/home/richard/foo/bar.rb') expect(rewriter.group).to eq 'group' expect(rewriter.name).to eq 'name' end end end end
Version data entries
9 entries across 9 versions & 1 rubygems