Sha256: 45f64ed8d426c7961c3508c13df38ee8386de61d20570562e7fe219d3328b0ec
Contents?: true
Size: 1.43 KB
Versions: 6
Compression:
Stored size: 1.43 KB
Contents
require 'spec_helper' module Synvert::Core describe Rewriter::Helper do let(:dummy_instance) { Class.new { include Rewriter::Helper }.new } let(:instance) do rewriter = Rewriter.new('foo', 'bar') Rewriter::Instance.new rewriter, 'spec/**/*_spec.rb' do; end end describe "add_receiver_if_necessary" do context "with receiver" do let(:node) { parse("User.save(false)") } it "adds reciever" do allow(dummy_instance).to receive(:node).and_return(node) expect(dummy_instance.add_receiver_if_necessary("save(validate: false)")).to eq "{{receiver}}.save(validate: false)" end end context "without receiver" do let(:node) { parse("save(false)") } it "doesn't add reciever" do allow(dummy_instance).to receive(:node).and_return(node) expect(dummy_instance.add_receiver_if_necessary("save(validate: false)")).to eq "save(validate: false)" end end end describe "strip_brackets" do it "strip ()" do expect(dummy_instance.strip_brackets("(123)")).to eq "123" end it "strip {}" do expect(dummy_instance.strip_brackets("{123}")).to eq "123" end it "strip []" do expect(dummy_instance.strip_brackets("[123]")).to eq "123" end it "not strip unmatched (]" do expect(dummy_instance.strip_brackets("(123]")).to eq "(123]" end end end end
Version data entries
6 entries across 6 versions & 1 rubygems