Sha256: f03896735c98cbbe5b67efa7b759e535c0875c39c6bd0c6b9e6bfec2b1fd571d

Contents?: true

Size: 1.26 KB

Versions: 28

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module Synvert::Core
  RSpec.describe Rewriter::ReplaceErbStmtWithExprAction do
    context 'replace with whitespace' do
      subject {
        erb_source = "<% form_for post do |f| %>\n<% end %>"
        source = Engine::Erb.encode(erb_source)
        node = parser_parse(source).children.first
        described_class.new(node, erb_source, adapter: NodeMutation::ParserAdapter.new).process
      }

      it 'gets start' do
        expect(subject.start).to eq '<%'.length
      end

      it 'gets end' do
        expect(subject.end).to eq '<%'.length
      end

      it 'gets new_code' do
        expect(subject.new_code).to eq '='
      end
    end

    context 'replace without whitespace' do
      subject {
        erb_source = "<%form_for post do |f|%>\n<%end%>"
        source = Engine::Erb.encode(erb_source)
        node = parser_parse(source).children.first
        described_class.new(node, erb_source, adapter: NodeMutation::ParserAdapter.new).process
      }

      it 'gets start' do
        expect(subject.start).to eq '<%'.length
      end

      it 'gets end' do
        expect(subject.end).to eq '<%'.length
      end

      it 'gets new_code' do
        expect(subject.new_code).to eq '='
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
synvert-core-2.2.2 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-2.2.1 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-2.2.0 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-2.1.2 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-2.1.1 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-2.1.0 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-2.0.3 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-2.0.2 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-2.0.1 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-2.0.0 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-1.35.4 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-1.35.3 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-1.35.2 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-1.35.1 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-1.35.0 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-1.34.0 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-1.33.3 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-1.33.2 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-1.33.1 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb
synvert-core-1.33.0 spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb