Class: Spanner::Translator::Rules::Translation::AddTestCase

Inherits:
BaseRule
  • Object
show all
Defined in:
lib/spanner/translator/rules/translation/add_test_case.rb

Overview

replace ApplicationRecord with the configured class during translation of models

Constant Summary

Constants inherited from BaseRule

BaseRule::RAILS_COLUMN_TYPES

Instance Attribute Summary

Attributes inherited from BaseRule

#translation_options

Instance Method Summary collapse

Methods inherited from BaseRule

#any_index?, #capture_column_nullity, #capture_primary_key_argument, #capture_table_name, #conditionally_propagate_argument, #create_range, #initialize, #unless_seen

Constructor Details

This class inherits a constructor from Spanner::Translator::Rules::BaseRule

Instance Method Details

#on_block(node) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/spanner/translator/rules/translation/add_test_case.rb', line 15

def on_block(node)
  main_describe?(node) do
    # only rewrite the first time RSpec.describe is seen
    unless_seen(:insert_test_case) do
      if translation_options[:test_case]
        @rewriter.insert_before(node.loc.end, translation_options[:test_case])
      else
        @rewriter.insert_before(node.loc.end, '  # i am here\n')
      end
    end
  end
end