[
  {
    "path": ".gitignore",
    "content": "/.bundle/\n/.yardoc\n/Gemfile.lock\n/_yardoc/\n/coverage/\n/doc/\n/pkg/\n/spec/reports/\n/spec/support/rails_test_app/Gemfile.lock\n/tmp/\n*.bundle\n*.so\n*.o\n*.a\nmkmf.log\n\n.rspec_status\ngemfiles/*.lock\nspec/support/rails_test_app/db/*.sqlite3\nspec/support/rails_test_app/db/*.sqlite3-journal\nspec/support/rails_test_app/log/*.log\nspec/support/rails_test_app/tmp/\n"
  },
  {
    "path": ".rspec",
    "content": "--color\n--warnings\n--require spec_helper\n--pattern \"spec/*_spec.rb\""
  },
  {
    "path": ".rubocop.yml",
    "content": "AllCops:\n  TargetRubyVersion: 2.3\n  Exclude:\n    - 'spec/support/rails_test_app/**/*'\n\nStyle/Documentation:\n  Enabled: false\n\nLayout/ParameterAlignment:\n  Enabled: true\n  EnforcedStyle: with_fixed_indentation\n\nLayout/MultilineOperationIndentation:\n  Enabled: true\n  EnforcedStyle: indented\n\nLayout/MultilineMethodCallIndentation:\n  Enabled: true\n  EnforcedStyle: indented\n\nLayout/CaseIndentation:\n  Enabled: true\n  EnforcedStyle: end\n\nLayout/EndAlignment:\n  Enabled: true\n  EnforcedStyleAlignWith: variable\n\nStyle/EmptyMethod:\n  Enabled: false\n\nMetrics/BlockLength:\n  Exclude:\n    - 'spec/**/*_spec.rb'\n    - 'zapata.gemspec'\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: ruby\nscript: script/test\nrvm:\n  - 2.3.8\n  - 2.4.8\n  - 2.5.7\n  - 2.6.5\n  - 2.7.0\ngemfile:\n  - gemfiles/5.2.gemfile\n  - gemfiles/6.0.gemfile\nmatrix:\n  exclude:\n  - rvm: 2.3.8\n    gemfile: gemfiles/6.0.gemfile\n  - rvm: 2.4.8\n    gemfile: gemfiles/6.0.gemfile\n"
  },
  {
    "path": "Appraisals",
    "content": "# frozen_string_literal: true\n\nappraise '5.2' do\n  gem 'rails', '~> 5.2.0'\n  gem 'sqlite3'\nend\n\nappraise '6.0' do\n  gem 'rails', '~> 6.0.0'\n  gem 'sqlite3'\nend\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "## Collaboration :heart:\n\nIt is encouraged by somehow managing to bring a cake to your house. I promise,\nI will really try.\n\nThis is a great project to understand language architecture in general. A\nproject to let your free and expressionistic side shine through by leaving meta\nhacks and rainbows everywhere.\n\nThank you to everyone who do. I strongly believe that this can make the\ndeveloper job less robotic and more creative.\n\n1. [Fork it](https://github.com/Nedomas/zapata/fork)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\nTo install, run:\n```sh\ncd zapata\nscript/bootstrap\n```\n\nFor specs:\n\n```sh\nscript/test\n\n# or\n\nbundle exec rspec --pattern \"spec/*_spec.rb\"\n```\n"
  },
  {
    "path": "Gemfile",
    "content": "# frozen_string_literal: true\n\nsource 'https://rubygems.org'\n\n# Specify your gem's dependencies in zapata.gemspec\ngroup :test do\n  gem 'coveralls', require: false\nend\n\ngemspec\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2014 Domas\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Zapata\n\nWho has time to write tests? This is a revolutionary tool to make them write\nthemselves.\n\n[![Gem Version](http://img.shields.io/gem/v/zapata.svg?style=flat)][rubygems]\n[![Build Status](http://img.shields.io/travis/Nedomas/zapata.svg?style=flat)][travis]\n[![Dependency Status](http://img.shields.io/gemnasium/Nedomas/zapata.svg?style=flat)][gemnasium]\n[![Coverage Status](http://img.shields.io/coveralls/Nedomas/zapata/master.svg?style=flat)][coveralls]\n\n![Emiliano Zapata](https://cloud.githubusercontent.com/assets/1877286/3753719/af3bfec2-1814-11e4-8790-242c2b26a8e9.jpg)\n\n# What is your problem?\n\nThere comes a day where you have this bullshit class ``RobotToTest``. We need\ntests. :shipit:\n\n```ruby\nclass RobotToTest\n  def initialize(human_name, cv)\n    @name = robot_name(human_name)\n  end\n\n  def robot_name(human_name)\n    \"#{self.class.prefix}_#{human_name}\"\n  end\n\n  def cv\n    { planets: planets }\n  end\n\n  def nested_fun_objects(fun_objects)\n    'It was fun'\n  end\n\n  def self.prefix\n    'Robot'\n  end\n\n  private\n\n  def planets\n    ['Mars', Human.home]\n  end\n\n  def fun_objects\n    [%i(array in array), { hash: nested_hash }]\n  end\n\n  def nested_hash\n    { in_hash: { in: array } }\n  end\n\n  def array\n    %w(array)\n  end\nend\n\n# just another class to analyze\nclass Human\n  def initialize\n    human_name = 'Emiliano'\n  end\n\n  def self.home\n    'Earth'\n  end\nend\n```\n\n## Solving it\n\nYou run ``zapata generate app/models/robot_to_test.rb`` and pop the champagne.\nZapata generated ``spec/models/robot_to_test_spec.rb`` for you.\n\n```ruby\ndescribe RobotToTest do\n  let(:robot_to_test) do\n    RobotToTest.new('Emiliano', { planets: ['Mars', Human.home] })\n  end\n\n  it '#robot_name' do\n    expect(robot_to_test.robot_name('Emiliano')).to eq('Robot_Emiliano')\n  end\n\n  it '#cv' do\n    expect(robot_to_test.cv).to eq({ planets: ['Mars', 'Earth'] })\n  end\n\n  it '#nested_fun_objects' do\n    expect(robot_to_test.nested_fun_objects([\n      [:array, :in, :array],\n      {\n        hash: {\n          in_hash: {\n            in: ['array']\n          }\n        }\n      }\n    ])).to eq('It was fun')\n  end\n\n  it '#prefix' do\n    expect(RobotToTest.prefix).to eq('Robot')\n  end\nend\n```\n\n## What does it do?\n\nIt tries to write a passing RSpec spec off the bat. It does fancy analysis\nto predict the values it could feed to the API of a class.\n\n__To be more specific:__\n- Analyzes all vars and methods definitions in ``app/models``\n- Checks what arguments does a testable method in ``app/models/robot_to_test.rb`` need\n- Searches for such variable or method name in methods in analyzed\n- Selects the most probable value by how many times it was repeated in code\n- Runs the RSpec and fills in the expected values of the test with those returned by RSpec\n\nFor more things it can currently do check test files\nhttps://github.com/Nedomas/zapata/tree/master/spec\n\n## Workflow with Zapata\n\nSay you are writing some new feature on your existing project.\nBefore writing that, you probably want to test out the current functionality.\nBut who has time for that?\n\nYou let *Zapata* create that quick spec for you.\nThink of it as a *current functionality lock*.\nWrite more code and when you're happy with the result - lock it up again.\n\n## Requirements\n\n- Ruby 2.1+\n- Rails 3.0+\n\n## Installation\n\nAdd `zapata` to your `Gemfile`. It currently only works if the library is added to the `Gemfile`.\n\n```ruby\ngem 'zapata', groups: %w(development test)\n```\n\n## Usage\n\nTo use run\n```sh\nzapata generate app/models/model_name.rb\n```\n\nTo ignore other files and analyze a single model you want to generate a spec for:\n```sh\nzapata generate app/models/model_name.rb --single\n```\n\n## Collaboration :heart:\n\nIt is encouraged by somehow managing to bring a cake to your house. I promise,\nI will really try.\n\nThis is a great project to understand language architecture in general. A\nproject to let your free and expressionistic side shine through by leaving meta\nhacks and rainbows everywhere.\n\nThank you to everyone who do. I strongly believe that this can make the\ndeveloper job less robotic and more creative.\n\n1. [Fork it](https://github.com/Nedomas/zapata/fork)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\nTo install, run:\n```sh\ncd zapata\nscript/bootstrap\n```\n\nFor specs:\n\n```sh\nscript/test\n\n# or\n\nbundle exec rspec --pattern \"spec/*_spec.rb\"\n```\n\n## Awareness\n\nI am well aware that this is featured in [Ruby Weekly 223](http://rubyweekly.com/issues/223).\nOn that note I'd like to thank everybody who helped it shine through.\n\nSpecial thanks to my comrade [@jpalumickas](https://github.com/jpalumickas), with whom we share a vision of a better world.\nAlso - thank you [@edgibbs](https://github.com/edgibbs), for being the early contributor. \n[@morron](https://github.com/morron) - for caring.\n\nHuge thanks to [@marcinruszkiewicz](https://github.com/marcinruszkiewicz) for reviving this gem to life in 2019/2020. Also additional thanks to [@jpalumickas](https://github.com/jpalumickas) for all the extra fixes and modernizing the codebase. This would not be done without you all.\n\n## Copyright\nCopyright (c) 2014-2018 Justas, Andrew, Ed, Dmitry, Domas.\nSee [LICENSE](LICENSE) for details.\n\n[rubygems]: https://rubygems.org/gems/zapata\n[travis]: http://travis-ci.org/Nedomas/zapata\n[gemnasium]: https://gemnasium.com/Nedomas/zapata\n[coveralls]: https://coveralls.io/r/Nedomas/zapata\n[codeclimate]: https://codeclimate.com/github/Nedomas/zapata\n"
  },
  {
    "path": "Rakefile",
    "content": "# frozen_string_literal: true\n\nrequire 'bundler/gem_tasks'\n"
  },
  {
    "path": "bin/zapata",
    "content": "#!/usr/bin/env ruby\n# frozen_string_literal: true\n\nrequire 'rubygems'\nrequire 'bundler/setup'\nrequire 'zapata'\nrequire 'zapata/cli'\n\nZapata::CLI.start(ARGV)\n"
  },
  {
    "path": "gemfiles/5.2.gemfile",
    "content": "# frozen_string_literal: true\n\n# This file was generated by Appraisal\n\nsource 'https://rubygems.org'\n\ngem 'rails', '~> 5.2.0'\ngem 'sqlite3'\n\ngroup :test do\n  gem 'coveralls', require: false\nend\n\ngemspec path: '../'\n"
  },
  {
    "path": "gemfiles/6.0.gemfile",
    "content": "# frozen_string_literal: true\n\n# This file was generated by Appraisal\n\nsource 'https://rubygems.org'\n\ngem 'rails', '~> 6.0.0'\ngem 'sqlite3'\n\ngroup :test do\n  gem 'coveralls', require: false\nend\n\ngemspec path: '../'\n"
  },
  {
    "path": "lib/zapata/analyst.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  class Analyst\n    attr_reader :result\n\n    def self.analyze(filename)\n      code = Core::Reader.parse(filename)\n      analyst = Analyst.new(code)\n      result = analyst.result.dup\n      analyst.clean\n      result\n    end\n\n    def initialize(code)\n      # class dive\n      Diver.search_for(:klass)\n      Diver.dive(code)\n      # var dive\n      Diver.search_for(:var)\n      Diver.dive(code)\n      # def dive\n      Diver.search_for(:def)\n      Diver.dive(code)\n      # send dive\n      Diver.search_for(:send)\n      Diver.dive(code)\n\n      @result = DB.all\n    end\n\n    def clean\n      DB.destroy_all\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/cli.rb",
    "content": "# frozen_string_literal: true\n\nrequire 'thor'\nrequire_relative 'version'\n\nmodule Zapata\n  class CLI < Thor\n    desc 'generate FILENAME', 'Generate spec file for model'\n    option :single, type: :boolean,\n                    desc: 'Skip app/models analysis',\n                    aliases: :s\n    def generate(filename)\n      Zapata::Revolutionist.generate_with_friendly_output(\n        filename: filename, single: options[:single]\n      )\n    end\n\n    desc 'version', 'Shows zapata version'\n    def version\n      puts \"v#{Zapata::VERSION}\"\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/core/collector.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Core\n    class Collector\n      def self.expand_dirs_to_files(dirs)\n        dirs.map { |dir| Dir[\"#{dir}/*.rb\"] }.flatten\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/core/loader.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Core\n    class Loader\n      class << self\n        def spec_dir\n          File.join(Dir.pwd, '/spec')\n        end\n\n        def rails_helper_path\n          File.expand_path(\"#{spec_dir}/rails_helper\", __FILE__)\n        end\n\n        def spec_helper_path\n          File.expand_path(\"#{spec_dir}/spec_helper\", __FILE__)\n        end\n\n        def helper_name\n          if File.exist?(\"#{rails_helper_path}.rb\")\n            'rails_helper'\n          elsif File.exist?(\"#{spec_helper_path}.rb\")\n            'spec_helper'\n          else\n            raise 'Was not able to load nor rails_helper, nor spec_helper'\n          end\n        end\n\n        def full_helper_path\n          paths = {\n            rails_helper: rails_helper_path,\n            spec_helper: spec_helper_path\n          }.freeze\n\n          paths[helper_name.to_sym]\n        end\n\n        def load_spec_helper\n          $LOAD_PATH << spec_dir\n          require helper_name.to_s\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/core/reader.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Core\n    class Reader\n      def self.parse(filename)\n        plain_text_code = File.open(filename).read\n        Parser::CurrentRuby.parse(plain_text_code)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/core/writer.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Core\n    class Writer\n      def initialize(filename)\n        @filename = filename\n        @padding = 0\n        clean\n      end\n\n      def clean\n        file = File.open(@filename, 'w')\n        file.write('')\n        file.close\n      end\n\n      def append_line(line = '')\n        @padding -= 1 if word_exists?(line, 'end')\n\n        padding_to_use = @padding\n        padding_to_use = 0 if line.empty?\n        file = File.open(@filename, 'ab+')\n        file.puts(\"#{'  ' * padding_to_use}#{line}\")\n        file.close\n\n        @padding += 1 if word_exists?(line, 'do')\n      end\n\n      def word_exists?(string, word)\n        !!/\\b(?:#{word})\\b/.match(string)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/core.rb",
    "content": "# frozen_string_literal: true\n\nrequire_relative 'core/collector'\nrequire_relative 'core/loader'\nrequire_relative 'core/reader'\nrequire_relative 'core/writer'\n\nmodule Zapata\n  module Core\n  end\nend\n"
  },
  {
    "path": "lib/zapata/db.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  class DB\n    @records = []\n    @locs = []\n\n    class << self\n      def create(record)\n        loc = record.code.loc\n\n        unless @locs.include?(loc)\n          @records << record\n          @locs << loc\n          record\n        end\n      end\n\n      def all\n        @records\n      end\n\n      def destroy_all\n        @records = []\n      end\n    end\n  end\n\n  class SaveManager\n    def self.clean(name)\n      name.to_s.delete('@').to_sym\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/diver.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  RETURN_TYPES = %i[missing raw const_send sym float str int ivar true false const nil].freeze\n  FINAL_TYPES = Zapata::RETURN_TYPES + %i[array hash]\n  DIVE_TYPES = %i[args begin block defined? nth_ref splat kwsplat class\n                  block_pass sclass masgn or and irange erange when and\n                  return array kwbegin yield while dstr ensure pair].freeze\n  ASSIGN_TYPES = %i[ivasgn lvasgn or_asgn casgn optarg].freeze\n  DEF_TYPES = %i[def defs].freeze\n  HARD_TYPES = %i[if dsym resbody mlhs next self break zsuper\n                  super retry rescue match_with_lvasgn case op_asgn regopt regexp].freeze\n  TYPES_BY_SEARCH_FOR = {\n    klass: %i[class],\n    var: ASSIGN_TYPES,\n    def: DEF_TYPES,\n    send: %i[send]\n  }.freeze\n\n  PRIMITIVE_TYPES = {\n    Def: %i[def],\n    Defs: %i[defs],\n    Send: %i[send],\n    Array: %i[args array],\n    Hash: %i[hash],\n    Ivar: %i[ivar],\n    Lvar: %i[lvar],\n    Klass: %i[class],\n    Sklass: %i[sclass],\n    Modul: %i[module],\n    Const: %i[const],\n    Optarg: %i[optarg],\n    Arg: %i[arg],\n    Basic: RETURN_TYPES,\n    Casgn: %i[casgn],\n    Var: ASSIGN_TYPES\n  }.freeze\n\n  class Diver\n    class << self\n      attr_accessor :current_moduls, :current_klass, :current_sklass, :access_level\n\n      def search_for(what)\n        @search_for = what\n        @current_moduls ||= []\n      end\n\n      def dive(code)\n        return Primitive::Nil.new unless code\n        if HARD_TYPES.include?(code.type)\n          return Primitive::Raw.new(:missing, :hard_type)\n        end\n\n        if (klass = primitive_klass(code))\n          result = klass.new(code)\n          DB.create(result) if search_for_types.include?(code.type)\n        end\n\n        deeper_dives(code)\n\n        result || Primitive::Raw.new(:super, nil)\n      end\n\n      def primitive_klass(code)\n        primitive_type = find_primitive_type(code)\n        return unless primitive_type\n\n        \"Zapata::Primitive::#{primitive_type}\".constantize\n      end\n\n      def find_primitive_type(code)\n        klass_pair = PRIMITIVE_TYPES.detect do |_, types|\n          types.include?(code.type)\n        end\n        return unless klass_pair\n\n        klass_pair.first\n      end\n\n      def search_for_types\n        TYPES_BY_SEARCH_FOR[@search_for]\n      end\n\n      def deeper_dives(code)\n        return unless DIVE_TYPES.include?(code.type)\n\n        code.to_a.compact.each do |part|\n          dive(part)\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/predictor/args.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Predictor\n    class Args\n      class << self\n        def literal(args_node)\n          return unless args_node\n\n          raw_args = Diver.dive(args_node).to_raw\n          chosen_args = choose_values(raw_args)\n          Printer.print(chosen_args, args: true)\n        end\n\n        def choose_values(raw_args)\n          case raw_args.type\n          when :array\n            array = raw_args.value.map do |arg|\n              Value.new(arg.value, arg).choose.to_raw\n            end\n\n            Primitive::Raw.new(:array, array)\n          when :hash\n            hash = raw_args.value.each_with_object({}) do |(rkey, rval), obj|\n              key = Value.new(rkey.value, rkey).choose.to_raw\n              val = Value.new(rval.value, rval).choose.to_raw\n              obj[key] = val\n            end\n\n            Primitive::Raw.new(:hash, hash)\n          when :int\n            Primitive::Raw.new(:int, raw_args.value)\n          when :missing\n            Primitive::Raw.new(:missing, raw_args.value)\n          when :nil\n            Primitive::Nil.new.to_raw\n          else\n            raise 'Not yet implemented'\n          end\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/predictor/chooser.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Predictor\n    class Chooser\n      def initialize(possible_values)\n        @possible_values = possible_values.dup\n      end\n\n      def by_probability\n        return if @possible_values.empty?\n\n        by_count\n      end\n\n      private\n\n      def by_count\n        group_with_counts(@possible_values).max_by { |_, v| v }.first\n      end\n\n      def group_with_counts(values)\n        values.each_with_object(Hash.new(0)) do |value, obj|\n          obj[value] += 1\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/predictor/value.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Predictor\n    class Value\n      extend Memoist\n\n      def initialize(name, finder = nil)\n        @name = name\n        @finder = finder\n      end\n\n      def choose\n        return Primitive::Raw.new(:nil, nil) if @name.nil?\n        return @finder if @finder && FINAL_TYPES.include?(@finder.type)\n        return Primitive::Raw.new(:super, @name) if possible_values.empty?\n\n        Chooser.new(possible_values).by_probability\n      end\n\n      def a_finder?(primitive)\n        return false unless @finder\n\n        primitive.class == @finder.class && primitive.name == @finder.name\n      end\n\n      def possible_values\n        Revolutionist.analysis_as_array.select do |element|\n          !a_finder?(element) && element.name == @name\n        end\n      end\n      memoize :possible_values\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/predictor.rb",
    "content": "# frozen_string_literal: true\n\nrequire_relative 'predictor/args'\nrequire_relative 'predictor/chooser'\nrequire_relative 'predictor/value'\n\nmodule Zapata\n  module Predictor\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/arg.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Arg < Base\n      def node\n        name = @code.to_a.first\n        type = @code.type\n        OpenStruct.new(type: type, name: name, body: @code)\n      end\n\n      def to_raw\n        chosen_value = Predictor::Value.new(node.name, self).choose.to_raw\n        return_with_super_as_missing(chosen_value, self)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/array.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Array < Base\n      def node\n        body = @code\n        type = @code.type\n        OpenStruct.new(type: type, body: body)\n      end\n\n      def to_a\n        value\n      end\n\n      def to_raw\n        value = node.body.to_a.map do |node|\n          primitive = Diver.dive(node)\n          raw = primitive.to_raw\n\n          if raw.type == :super\n            predicted = Predictor::Value.new(raw.value).choose.to_raw\n            return_with_super_as_missing(predicted, primitive)\n          else\n            raw\n          end\n        end\n\n        Raw.new(:array, value)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/base.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Base\n      attr_accessor :code, :type\n\n      def initialize(code)\n        @code = code\n        @type = code.type\n      end\n\n      def name\n        SaveManager.clean(node.name)\n      end\n\n      def dive_deeper\n        return if RETURN_TYPES.include?(node.type)\n\n        Diver.dive(node.args)\n        Diver.dive(node.body)\n      end\n\n      def to_raw\n        Diver.dive(node.body).to_raw\n      end\n\n      def return_with_super_as_missing(raw, primitive)\n        raw.type == :super ? Missing.new(primitive.name).to_raw : raw\n      end\n\n      def return_with_missing_as_super(raw, name)\n        raw.type == :missing ? Raw.new(:super, name) : raw\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/basic.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Basic < Base\n      def to_a\n        [value]\n      end\n\n      def node\n        body = @code\n        type = @code.type\n        OpenStruct.new(type: type, body: body)\n      end\n\n      def to_raw\n        Raw.new(node.body.type, node.body.to_a.last)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/casgn.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Casgn < Base\n      def node\n        modul, name, body = @code.to_a\n        type = @code.type\n        OpenStruct.new(type: type, modul: modul, name: name, body: body)\n      end\n\n      def literal\n        Diver.dive(node.body).literal\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/const.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Const < Basic\n      def node\n        modul, klass = @code.to_a\n        type = @code.type\n        OpenStruct.new(modul: modul, klass: klass, type: type)\n      end\n\n      def to_raw\n        Raw.new(:const, [node.modul, node.klass].compact.join('::'))\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/const_send.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class ConstSend\n      def initialize(raw_receiver, method_name, args)\n        @raw_receiver = raw_receiver\n        @method_name = method_name\n        @args = args\n      end\n\n      def node\n        OpenStruct.new(method_name: @method_name, args: @args)\n      end\n\n      def to_raw\n        Raw.new(:const_send, \"#{Printer.print(@raw_receiver)}.#{node.method_name}#{Predictor::Args.literal(node.args)}\")\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/def.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Def < Base\n      attr_accessor :klass\n\n      def initialize(code)\n        @code = code\n        @klass = Diver.current_klass\n        @self = Diver.current_sklass\n        @access_level = Diver.access_level\n        dive_deeper\n      end\n\n      def self?\n        !!@self\n      end\n\n      def public?\n        @access_level == :public\n      end\n\n      def node\n        name, args, body = @code.to_a\n        type = @code.type\n        OpenStruct.new(type: type, name: name, args: args, body: body)\n      end\n\n      def literal_predicted_args\n        Predictor::Args.literal(node.args)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/defs.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Defs < Base\n      attr_accessor :klass\n\n      def initialize(code)\n        @code = code\n        @klass = Diver.current_klass\n        @access_level = Diver.access_level\n        dive_deeper\n      end\n\n      def self?\n        true\n      end\n\n      def public?\n        @access_level == :public\n      end\n\n      def node\n        _, name, args, body = @code.to_a\n        type = @code.type\n        OpenStruct.new(type: type, name: name, args: args, body: body)\n      end\n\n      def literal_predicted_args\n        Predictor::Args.literal(node.args)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/hash.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Hash < Base\n      def node\n        body = @code\n        type = @code.type\n        OpenStruct.new(type: type, body: body)\n      end\n\n      def to_a\n        value.to_a.flatten\n      end\n\n      def to_raw\n        result = {}\n\n        node.body.to_a.each do |pair|\n          key_node, value_node = pair.to_a\n          key = Diver.dive(key_node).to_raw\n          value = Diver.dive(value_node).to_raw\n          result[key] = value\n        end\n\n        Raw.new(:hash, result)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/ivar.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Ivar < Basic\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/klass.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Klass < Base\n      def initialize(code)\n        @code = code\n        @moduls = Diver.current_moduls.dup\n        Diver.access_level = :public\n        Diver.current_klass = self\n        dive_deeper\n        Diver.current_klass = nil\n      end\n\n      def parent_modul_names\n        @moduls.map { |mod| mod&.name }.compact\n      end\n\n      def node\n        const, _, body = @code.to_a\n        immediate_modul, klass = const.to_a\n        chain = parent_modul_names + [immediate_modul, klass]\n        name = chain.compact.join('::')\n        type = @code.type\n\n        OpenStruct.new(\n          type: type,\n          immediate_modul: immediate_modul,\n          klass: klass,\n          name: name,\n          body: body\n        )\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/lvar.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Lvar < Base\n      def node\n        name = @code.to_a.first\n        type = @code.type\n        OpenStruct.new(type: type, name: name, body: @code)\n      end\n\n      def to_raw\n        chosen_value = Predictor::Value.new(node.name, self).choose\n\n        if chosen_value.respond_to?(:node) && chosen_value.node.body == node.body\n          Missing.new(node.name).to_raw\n        else\n          chosen_value.to_raw\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/missing.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Missing\n      def initialize(name)\n        @name = name\n      end\n\n      def node\n        OpenStruct.new(type: :missing)\n      end\n\n      def to_raw\n        Raw.new(:missing, @name)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/modul.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Modul < Base\n      def initialize(code)\n        @code = code\n        Diver.current_moduls << self\n        dive_deeper\n        Diver.current_moduls.pop\n      end\n\n      def node\n        const, body = @code.to_a\n        modul, name = const.to_a\n        type = @code.type\n\n        OpenStruct.new(type: type, modul: modul, name: name, body: body)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/nil.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Nil < Basic\n      def initialize\n      end\n\n      def node\n        OpenStruct.new(type: :nil)\n      end\n\n      def to_raw\n        Raw.new(:nil, nil)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/optarg.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Optarg < Base\n      def node\n        name, body = @code.to_a\n        type = @code.type\n        OpenStruct.new(type: type, name: name, body: body)\n      end\n\n      def to_raw\n        Diver.dive(node.body).to_raw\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/raw.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Raw\n      attr_accessor :type, :value\n\n      def initialize(type, value)\n        @type = type\n        @value = value\n      end\n\n      def to_raw\n        self\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/send.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Send < Base\n      def initialize(code)\n        super\n\n        if node.name == :private\n          Diver.access_level = :private\n        elsif node.name == :protected\n          Diver.access_level = :protected\n        elsif node.name == :public\n          Diver.access_level = :public\n        end\n      end\n\n      def to_a\n        [value]\n      end\n\n      def node\n        receiver, name, args = @code.to_a\n        type = @code.type\n        OpenStruct.new(type: type, name: name, args: args, receiver: receiver)\n      end\n\n      def raw_receiver\n        return unless node.receiver\n\n        Diver.dive(node.receiver).to_raw\n      end\n\n      def to_raw\n        if raw_receiver && raw_receiver.type == :const\n          ConstSend.new(raw_receiver, node.name, node.args).to_raw\n        else\n          missing_name = if node.receiver\n            Unparser.unparse(code)\n          else\n            node.name\n          end\n\n          Missing.new(missing_name).to_raw\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/sklass.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Sklass < Base\n      def initialize(code)\n        @code = code\n\n        Diver.current_sklass = self\n        dive_deeper\n        Diver.current_sklass = nil\n      end\n\n      def node\n        _, body = @code.to_a\n        type = @code.type\n\n        OpenStruct.new(type: type, body: body)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive/var.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module Primitive\n    class Var < Base\n      def node\n        name, body = @code.to_a\n        type = @code.type\n        OpenStruct.new(type: type, name: name, body: body)\n      end\n\n      def literal\n        Diver.dive(node.body).literal\n      end\n\n      def to_raw\n        raw = Diver.dive(node.body).to_raw\n\n        if raw.type == :super\n          Missing.new(node.name).to_raw\n        else\n          raw\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/primitive.rb",
    "content": "# frozen_string_literal: true\n\nrequire_relative 'primitive/base'\nrequire_relative 'primitive/arg'\nrequire_relative 'primitive/array'\nrequire_relative 'primitive/basic'\nrequire_relative 'primitive/casgn'\nrequire_relative 'primitive/const'\nrequire_relative 'primitive/const_send'\nrequire_relative 'primitive/def'\nrequire_relative 'primitive/defs'\nrequire_relative 'primitive/hash'\nrequire_relative 'primitive/ivar'\nrequire_relative 'primitive/klass'\nrequire_relative 'primitive/lvar'\nrequire_relative 'primitive/missing'\nrequire_relative 'primitive/modul'\nrequire_relative 'primitive/nil'\nrequire_relative 'primitive/optarg'\nrequire_relative 'primitive/raw'\nrequire_relative 'primitive/send'\nrequire_relative 'primitive/sklass'\nrequire_relative 'primitive/var'\n\nmodule Zapata\n  module Primitive\n  end\nend\n"
  },
  {
    "path": "lib/zapata/printer.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  class Printer\n    class << self\n      extend Memoist\n\n      def print(raw, args: false)\n        type = raw.type\n\n        result = case type\n        when :const, :send, :int, :const_send, :literal, :float\n          raw.value\n        when :str\n          str(raw)\n        when :sym\n          sym(raw)\n        when :true\n          true\n        when :false\n          false\n        when :array\n          array(raw.value)\n        when :hash\n          hash(raw.value)\n        when :nil\n          'nil'\n        when :missing\n          missing(raw)\n        when :ivar\n          ivar(raw)\n        else\n          raise \"Not yet implemented #{raw}\"\n        end\n\n        args ? argize(result, type) : result\n      end\n\n      def to_var_name(name)\n        name.to_s.split('::').last.underscore.delete('@')\n      end\n\n      private\n\n      def array(given)\n        unnested = given.map { |el| unnest(el) }\n\n        \"[#{unnested.join(', ')}]\"\n      end\n\n      def str(raw)\n        # decide which one to use\n        # \"\\\"#{raw.value}\\\"\"\n        \"'#{raw.value}'\"\n      end\n\n      def sym(raw)\n        \":#{raw.value}\"\n      end\n\n      def ivar(raw)\n        RZpec::Writer.ivars << raw\n        to_var_name(raw.value)\n      end\n\n      def missing(raw)\n        print(Primitive::Raw.new(:str, \"Missing \\\"#{raw.value}\\\"\"))\n      end\n\n      def argize(value, type)\n        case type\n        when :array\n          value = value[1...-1]\n        when :hash\n          value = value[2...-2]\n        end\n\n        return unless value.present?\n\n        \"(#{[value].flatten.join(', ')})\"\n      end\n\n      def hash(given)\n        unnested = given.each_with_object({}) do |(key, val), obj|\n          obj[unnest(key)] = unnest(val)\n        end\n\n        values = unnested.map do |key, val|\n          print_hash_pair(key, val, all_keys_symbols?(unnested))\n        end\n        \"{ #{values.join(', ')} }\"\n      end\n\n      def print_hash_pair(key, val, symbol_keys)\n        symbol_keys ? \"#{key[1..-1]}: #{val}\" : \"#{key} => #{val}\"\n      end\n\n      def all_keys_symbols?(hash)\n        hash.keys.all? do |key|\n          Parser::CurrentRuby.parse(key.to_s).type == :sym\n        end\n      end\n      memoize :all_keys_symbols?\n\n      def unnest(raw)\n        return raw unless raw.respond_to?(:value)\n\n        if raw.value.is_a?(Primitive::Raw)\n          print(unnest(raw.value))\n        else\n          print(raw)\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/rzpec/runner.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module RZpec\n    class Runner\n      attr_reader :ran\n\n      def initialize(spec_filename)\n        @spec_filename = spec_filename\n        run\n        # silence { run }\n      end\n\n      def silence\n        original_stderr = $stderr.dup\n        original_stdout = $stdout.dup\n\n        $stdout.reopen('/dev/null', 'w')\n        $stdout.reopen('/dev/null', 'w')\n\n        yield\n\n        $stderr = original_stderr\n        $stdout = original_stdout\n      end\n\n      def methodz\n        examples.index_by { |ex| ex['description'].delete('#').to_sym }\n      end\n\n      def result_message(method_name)\n        methodz[method_name]['exception']['message']\n      end\n\n      def expected(method_name)\n        report_lines = result_message(method_name).to_s.split(/\\n/)\n        expected_line = report_lines.detect { |line| line.match('got:') }\n\n        if expected_line\n          clean_expected_line = expected_line[10..-1]\n\n          if (matches = clean_expected_line.match(/\\#\\<(.+):(.+)\\>/))\n            \"'Returned instance object #{matches[1]}'\"\n          else\n            Printer.print(Diver.dive(Parser::CurrentRuby.parse(clean_expected_line)).to_raw)\n          end\n        else\n          \"'Exception in RSpec'\"\n        end\n      end\n\n      def run\n        @ran = true\n\n        @stdin, @stdout, @stderr = Bundler.with_clean_env do\n          Open3.popen3(\"bundle exec rspec #{@spec_filename} --format j\")\n        end\n      end\n\n      def examples\n        parsed_json_result['examples']\n      end\n\n      def parsed_json_result\n        @json ||= JSON.parse(@stdout.readlines.last)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/rzpec/writer.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  module RZpec\n    class Writer\n      class << self\n        attr_accessor :ivars\n\n        def reset_ivars\n          @ivars = []\n        end\n      end\n\n      def initialize(file, _code, subject_analysis, whole_analysis, spec_analysis = nil)\n        self.class.reset_ivars\n        @subject_analysis = subject_analysis\n        @whole_analysis = whole_analysis\n        @spec_analysis = spec_analysis\n        @writer = Core::Writer.new(file)\n        @result = {}\n\n        write_require\n\n        klasses.each do |klass|\n          write_class(klass)\n        end\n\n        self.class.reset_ivars\n      end\n\n      def write_require\n        @writer.append_line(\"require '#{Core::Loader.helper_name}'\")\n      end\n\n      def klasses\n        @subject_analysis.select { |obj| obj.is_a?(Primitive::Klass) }\n      end\n\n      def klass_defs(klass)\n        @subject_analysis.select do |method|\n          [Primitive::Def, Primitive::Defs].include?(method.class) &&\n            method.public? && method.klass.name == klass.name\n        end\n      end\n\n      def initialize_def(klass)\n        klass_defs(klass).detect { |method| method.name == :initialize }\n      end\n\n      def write_class(klass)\n        @writer.append_line\n        @writer.append_line(\"describe #{klass.name} do\")\n\n        write_instance_let(klass)\n\n        klass_defs(klass).each do |primitive_def|\n          write_method(primitive_def)\n        end\n\n        self.class.ivars.each do |ivar|\n          predicted_value = Predictor::Value.new(ivar.value, ivar).choose\n          literal_predicted_value = Printer.print(predicted_value.to_raw)\n          write_let(ivar.value, literal_predicted_value)\n        end\n\n        @writer.append_line('end')\n      end\n\n      def write_instance_let(klass)\n        if initialize_def = initialize_def(klass)\n          write_let_from_initialize(initialize_def)\n        else\n          write_let(klass.name, \"#{klass.name}.new\")\n        end\n      end\n\n      def write_let(name, block)\n        @writer.append_line(\"let(:#{Printer.to_var_name(name)}) do\")\n        @writer.append_line(block)\n        @writer.append_line('end')\n      end\n\n      def write_let_from_initialize(initialize_def)\n        block = \"#{initialize_def.klass.name}.new#{initialize_def.literal_predicted_args}\"\n        write_let(initialize_def.klass.name, block)\n      end\n\n      def write_method(primitive_def)\n        return unless primitive_def.node.body\n        return if primitive_def.name == :initialize\n\n        @writer.append_line\n        @writer.append_line(\"it '##{primitive_def.name}' do\")\n\n        receiver = if primitive_def.self?\n          primitive_def.klass.name\n        else\n          Printer.to_var_name(primitive_def.klass.name)\n        end\n\n        @writer.append_line(\n          \"expect(#{receiver}.#{primitive_def.name}#{primitive_def.literal_predicted_args}).to eq(#{write_equal(primitive_def.name)})\"\n        )\n\n        @writer.append_line('end')\n      end\n\n      def write_equal(method_name)\n        if @spec_analysis\n          Printer.print(Primitive::Raw.new(:literal, @spec_analysis.expected(method_name)))\n        else\n          Printer.print(Primitive::Raw.new(:str, 'Fill this in by hand'))\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/zapata/version.rb",
    "content": "# frozen_string_literal: true\n\nmodule Zapata\n  VERSION = '1.0.0'\nend\n"
  },
  {
    "path": "lib/zapata.rb",
    "content": "# frozen_string_literal: true\n\nrequire 'parser/current'\nrequire 'unparser'\nrequire 'tempfile'\nrequire 'rails'\nrequire 'open3'\nrequire 'rspec'\nrequire 'memoist'\n\nrequire_relative 'zapata/core'\nrequire_relative 'zapata/predictor'\nrequire_relative 'zapata/primitive'\nrequire_relative 'zapata/rzpec/runner'\nrequire_relative 'zapata/rzpec/writer'\nrequire_relative 'zapata/analyst'\nrequire_relative 'zapata/diver'\nrequire_relative 'zapata/db'\nrequire_relative 'zapata/printer'\nrequire_relative 'zapata/version'\n\nmodule Zapata\n  class Revolutionist\n    class << self\n      attr_accessor :analysis, :analysis_as_array\n\n      def generate_with_friendly_output(filename:, single: false)\n        spec_filename = Zapata::Revolutionist.generate(filename: filename, single: single)\n        puts \"Its done, comrades. File #{spec_filename} was generated.\"\n      end\n\n      def generate(filename:, single: false)\n        dirs = single ? [] : %w[app/models]\n        file_list = Core::Collector.expand_dirs_to_files(dirs)\n        new(file_list).generate_rspec_for(filename, spec_filename(filename))\n      end\n\n      def init_analysis_as_array\n        @analysis_as_array = analysis.values.flatten\n      end\n\n      def spec_filename(filename)\n        filename.gsub('app/', 'spec/').gsub('.rb', '_spec.rb')\n      end\n\n      private\n\n      def single?(opts, args)\n        opts.single? || args.include?('-s') || args.include?('--single')\n      end\n    end\n\n    def initialize(file_list)\n      Core::Loader.load_spec_helper\n      self.class.analysis = analyze_multiple(file_list)\n    end\n\n    def analyze_multiple(files)\n      total = files.size.to_s\n\n      files.each_with_object({}).with_index do |(filename, obj), i|\n        puts \"[#{adjusted_current(i, total)}/#{total}] Analyzing: #{filename}\"\n        obj[filename] = Analyst.analyze(filename)\n      end\n    end\n\n    def adjusted_current(index, total)\n      (index + 1).to_s.rjust(total.size)\n    end\n\n    def generate_rspec_for(filename, spec_filename)\n      unless self.class.analysis[filename]\n        self.class.analysis[filename] = Analyst.analyze(filename)\n      end\n\n      self.class.init_analysis_as_array\n\n      code = Core::Reader.parse(filename)\n\n      global_analysis = Revolutionist.analysis_as_array\n      # first run\n      Tempfile.open('spec') do |tempfile|\n        RZpec::Writer.new(tempfile.path, code, self.class.analysis[filename], global_analysis)\n\n        save_spec_file(tempfile.path, spec_filename)\n        spec_analysis = RZpec::Runner.new(spec_filename)\n\n        # second run with RSpec results\n        RZpec::Writer.new(tempfile.path, code, self.class.analysis[filename], global_analysis, spec_analysis)\n        save_spec_file(tempfile.path, spec_filename)\n      end\n    end\n\n    def save_spec_file(tmp_spec_filename, spec_filename)\n      spec_path = \"#{Dir.pwd}/#{spec_filename}\"\n      spec_dir = spec_path.split('/')[0...-1].join('/')\n      FileUtils.mkdir_p(spec_dir)\n      FileUtils.cp(tmp_spec_filename, spec_path)\n      spec_filename\n    end\n  end\nend\n"
  },
  {
    "path": "script/bootstrap",
    "content": "#!/usr/bin/env bash\n\nset -e\n\nrake install\ncd spec/support/rails_test_app\nbundle update\ncd ../../..\n\necho 'Run specs with:'\necho './script/test'\n"
  },
  {
    "path": "script/test",
    "content": "#!/usr/bin/env bash\n\nset -e\n\nbundle exec rspec --pattern \"spec/*_spec.rb\"\n"
  },
  {
    "path": "spec/array_spec.rb",
    "content": "# frozen_string_literal: true\n\ndescribe Zapata::Revolutionist do\n  before(:all) do\n    @generated = exec_generation('app/models/test_array.rb')\n  end\n\n  it '#test_in_arg' do\n    has_block('#test_in_arg', %{\n      expect(test_array.test_in_arg([2, 7.1, 8])).to eq([2, 7.1, 8])\n    })\n  end\n\n  it '#test_nested_one_level' do\n    has_block('#test_nested_one_level', %{\n      expect(test_array.test_nested_one_level([[2, 7.1, 8], :mexico])).to eq([[2, 7.1, 8], :mexico])\n    })\n  end\n\n  it '#test_nested_two_levels' do\n    has_block('#test_nested_two_levels', %{\n      expect(test_array.test_nested_two_levels([[[2, 7.1, 8], :mexico], [2, 7.1, 8], :mexico])).to eq([[[2, 7.1, 8], :mexico], [2, 7.1, 8], :mexico])\n    })\n  end\n\n  it '#test_nested_three_levels' do\n    has_block('#test_nested_three_levels', %{\n      expect(test_array.test_nested_three_levels([[[[2, 7.1, 8], :mexico], [2, 7.1, 8], :mexico], [[2, 7.1, 8], :mexico], [2, 7.1, 8], :mexico])).to eq([[[[2, 7.1, 8], :mexico], [2, 7.1, 8], :mexico], [[2, 7.1, 8], :mexico], [2, 7.1, 8], :mexico])\n    })\n  end\n\n  it '#test_hash_nested' do\n    has_block('#test_hash_nested', %{\n      expect(test_array.test_hash_nested([{ emiliano: [2, 7.1, 8] }])).to eq([{ emiliano: [2, 7.1, 8] }])\n    })\n  end\nend\n"
  },
  {
    "path": "spec/definition_spec.rb",
    "content": "# frozen_string_literal: true\n\ndescribe Zapata::Revolutionist do\n  before(:all) do\n    @generated = exec_generation('app/models/test_definition.rb')\n  end\n\n  it '#in_optional_args' do\n    has_block('#in_optional_args', %{\n      expect(test_definition.in_optional_args(:audioslave)).to eq(:audioslave)\n    })\n  end\n\n  it '#use_optional' do\n    has_block('#use_optional', %{\n      expect(test_definition.use_optional(:audioslave)).to eq(:audioslave)\n    })\n  end\n\n  # it '#var_in_optional_args' do\n  #   has_block('#var_in_optional_args', %Q{\n  #     expect(test_definition.var_in_optional_args('Chuck')).to eq('Chuck')\n  #   })\n  # end\n\n  # it '#method_in_optional_args' do\n  #   has_block('#method_in_optional_args', %Q{\n  #     expect(test_definition.method_in_optional_args('I am falling')).to eq('I am falling')\n  #   })\n  # end\n\n  it '#call_method_result_in_optional_args' do\n    has_block('#call_method_result_in_optional_args', %{\n      expect(test_definition.call_method_result_in_optional_args('Missing \"fall_meth.first\"')).to eq('Missing \"fall_meth.first\"')\n    })\n  end\n\n  it '#resursive_method' do\n    has_block('#recursive_method', %{\n      expect(test_definition.recursive_method).to eq('Exception in RSpec')\n    })\n  end\nend\n"
  },
  {
    "path": "spec/generation_spec.rb",
    "content": "# frozen_string_literal: true\n\ndescribe Zapata::Revolutionist do\n  describe '#generate_with_friendly_output' do\n    let(:file_name) { 'app/models/test_array.rb' }\n\n    context 'with the generate command' do\n      context 'with single specified' do\n        it 'returns a single file generation message' do\n          output = execution_output(\"cd #{RAILS_TEST_APP_DIR} && bundle exec zapata generate #{file_name} -s\")\n          expect(output.count).to eq 1\n          expect(output.first).to eq \"Its done, comrades. File spec/models/test_array_spec.rb was generated.\\n\"\n        end\n      end\n\n      context 'with no single specified' do\n        it 'returns mulptile files generation messages' do\n          output = execution_output(\"cd #{RAILS_TEST_APP_DIR} && bundle exec zapata generate #{file_name}\")\n          expect(output.count).to be > 1\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "spec/hash_spec.rb",
    "content": "# frozen_string_literal: true\n\ndescribe Zapata::Revolutionist do\n  before(:all) do\n    @generated = exec_generation('app/models/test_hash.rb')\n  end\n\n  it '#test_in_arg' do\n    has_block('#test_in_arg', %{\n      expect(test_hash.test_in_arg({ 1 => :one, TestHash => 2.718 })).to eq({ 1 => :one, TestHash => 2.718 })\n    })\n  end\n\n  it '#test_nested_one_level' do\n    has_block('#test_nested_one_level', %{\n      expect(test_hash.test_nested_one_level({ first_level: { 1 => :one, TestHash => 2.718 } })).to eq({ first_level: { 1 => :one, TestHash => 2.718 } })\n    })\n  end\n\n  it '#test_nested_two_levels' do\n    has_block('#test_nested_two_levels', %{\n      expect(test_hash.test_nested_two_levels({ second_level: { first_level: { 1 => :one, TestHash => 2.718 } } })).to eq({ second_level: { first_level: { 1 => :one, TestHash => 2.718 } } })\n    })\n  end\n\n  it '#test_nested_three_levels' do\n    has_block('#test_nested_three_levels', %{\n      expect(test_hash.test_nested_three_levels({ third_level: { second_level: { first_level: { 1 => :one, TestHash => 2.718 } } } })).to eq({ third_level: { second_level: { first_level: { 1 => :one, TestHash => 2.718 } } } })\n    })\n  end\n\n  it '#test_key_as_another_hash' do\n    has_block('#test_key_as_another_hash', %{\n      expect(test_hash.test_key_as_another_hash({ { 1 => :one, TestHash => 2.718 } => :ratm })).to eq({ { 1 => :one, TestHash => 2.718 } => :ratm })\n    })\n  end\n\n  it '#test_keys_are_symbols' do\n    has_block('#test_keys_are_symbols', %{\n      expect(test_hash.test_keys_are_symbols({ this: 'should', be: 'pretty' })).to eq({ be: 'pretty', this: 'should' })\n    })\n  end\nend\n"
  },
  {
    "path": "spec/klass_types_spec.rb",
    "content": "# frozen_string_literal: true\n\ndescribe Zapata::Revolutionist do\n  context 'it should work with' do\n    it 'bare module' do\n      generated = exec_generation('app/models/testing_module/bare.rb')\n      expected = expected(%{require 'rails_helper'\n\n      describe TestingModule::Bare do\n        let(:bare) do\n          TestingModule::Bare.new\n        end\n      end})\n\n      expect(generated).to eq(expected)\n    end\n\n    it 'nested module' do\n      generated = exec_generation('app/models/testing_module/nested/inside.rb')\n      expected = expected(%{require 'rails_helper'\n\n      describe TestingModule::Nested::Inside do\n        let(:inside) do\n          TestingModule::Nested::Inside.new\n        end\n      end})\n\n      expect(generated).to eq(expected)\n    end\n\n    context 'klass methods' do\n      before(:all) do\n        @generated = exec_generation('app/models/testing_module/klass_methods.rb')\n      end\n\n      it '#defined_with_self' do\n        has_block('#defined_with_self', %{\n          expect(TestingModule::KlassMethods.defined_with_self(5)).to eq(5)\n        })\n      end\n\n      it '#defined_with_back_back_self' do\n        has_block('#defined_with_back_back_self', %{\n          expect(TestingModule::KlassMethods.defined_with_back_back_self(5)).to eq(5)\n        })\n      end\n\n      it '#back_to_public_defined_with_self' do\n        has_block('#back_to_public_defined_with_self', %{\n          expect(TestingModule::KlassMethods.back_to_public_defined_with_self(5)).to eq(5)\n        })\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "spec/send_spec.rb",
    "content": "# frozen_string_literal: true\n\ndescribe Zapata::Revolutionist do\n  before(:all) do\n    @generated = exec_generation('app/models/test_send.rb')\n  end\n\n  it '#another_method_as_arg' do\n    has_block('#another_method_as_arg', %{\n      expect(test_send.another_method_as_arg('Help method')).to eq('Help method')\n    })\n  end\n\n  # it '#second_level_method_chain' do\n  #   has_block('#second_level_method_chain', %Q{\n  #     expect(test_send.second_level_method_chain('Help method')).to eq('Help method')\n  #   })\n  # end\n\n  # it '#third_level_method_chain' do\n  #   has_block('#third_level_method_chain', %Q{\n  #     expect(test_send.third_level_method_chain('Help method')).to eq('Help method')\n  #   })\n  # end\n\n  # it '#method_with_calculated_value' do\n  #   has_block('#method_with_calculated_value', %Q{\n  #     expect(test_send.method_with_calculated_value('Missing \"calculated_value\"')).to eq('Missing \"calculated_value\"')\n  #   })\n  # end\n\n  it '#to_another_object' do\n    has_block('#to_another_object', %{\n      expect(test_send.to_another_object(AnotherObject.my_name)).to eq('Domas')\n    })\n  end\n\n  it '#to_another_object_with_params' do\n    has_block('#to_another_object_with_params', %{\n      expect(test_send.to_another_object_with_params(AnotherObject.send_with_params(12))).to eq('Id was 12')\n    })\n  end\n\n  it '#not_explicit_with_params' do\n    has_block('#not_explicit_with_params', %{\n      expect(test_send.not_explicit_with_params('Could you find it?')).to eq('Could you find it?')\n    })\n  end\n\n  it '#fail_to_understand' do\n    has_block('#fail_to_understand', %{\n      expect(test_send.fail_to_understand('Missing \"failure\"')).to eq('Missing \"failure\"')\n    })\n  end\nend\n"
  },
  {
    "path": "spec/simple_types_spec.rb",
    "content": "# frozen_string_literal: true\n\ndescribe Zapata::Revolutionist do\n  context 'it should work with' do\n    it 'ints' do\n      generated = exec_generation('app/models/test_int.rb')\n      expected = expected(%{require 'rails_helper'\n\n      describe TestInt do\n        let(:test_int) do\n          TestInt.new\n        end\n\n        it '#test_int_in_arg' do\n          expect(test_int.test_int_in_arg(1)).to eq(1)\n        end\n      end})\n\n      expect(generated).to eq(expected)\n    end\n\n    it 'symbols' do\n      generated = exec_generation('app/models/test_sym.rb')\n      expected = expected(%{require 'rails_helper'\n\n      describe TestSym do\n        let(:test_sym) do\n          TestSym.new\n        end\n\n        it '#test_sym_in_arg' do\n          expect(test_sym.test_sym_in_arg(:rock)).to eq(:rock)\n        end\n      end})\n\n      expect(generated).to eq(expected)\n    end\n\n    it 'strings' do\n      generated = exec_generation('app/models/test_str.rb')\n      expected = expected(%{require 'rails_helper'\n\n      describe TestStr do\n        let(:test_str) do\n          TestStr.new\n        end\n\n        it '#test_str_in_arg' do\n          expect(test_str.test_str_in_arg('audioslave')).to eq('audioslave')\n        end\n      end})\n\n      expect(generated).to eq(expected)\n    end\n\n    it 'floats' do\n      generated = exec_generation('app/models/test_float.rb')\n      expected = expected(%{require 'rails_helper'\n\n      describe TestFloat do\n        let(:test_float) do\n          TestFloat.new\n        end\n\n        it '#test_float_in_arg' do\n          expect(test_float.test_float_in_arg(2.718)).to eq(2.718)\n        end\n      end})\n\n      expect(generated).to eq(expected)\n    end\n\n    it 'consts' do\n      generated = exec_generation('app/models/test_const.rb')\n      expected = expected(%{require 'rails_helper'\n\n      describe TestConst do\n        let(:test_const) do\n          TestConst.new\n        end\n\n        it '#test_const_in_arg' do\n          expect(test_const.test_const_in_arg(TestConst)).to eq(TestConst)\n        end\n      end})\n\n      expect(generated).to eq(expected)\n    end\n  end\nend\n"
  },
  {
    "path": "spec/spec_helper.rb",
    "content": "# frozen_string_literal: true\n\nrequire 'coveralls'\n\nCoveralls.wear!\n\nrequire 'zapata'\n\nRSpec.configure do |config|\n  # Enable flags like --only-failures and --next-failure\n  config.example_status_persistence_file_path = '.rspec_status'\n\n  config.expect_with :rspec do |c|\n    c.syntax = :expect\n  end\nend\n\n# Helper methods\nRAILS_TEST_APP_DIR = \"#{Dir.pwd}/spec/support/rails_test_app\"\n\ndef execution_output(command)\n  stdout = Bundler.with_clean_env do\n    Open3.pipeline_r(\n      command\n    )\n  end\n  stdout.first.readlines\nend\n\ndef clean(string)\n  string.split(/\\n/).map(&:strip).join(\"\\n\")\nend\n\ndef expected(code)\n  clean(\n    <<-EXPECTED\n      #{code}\n    EXPECTED\n  )\nend\n\ndef exec_generation(generate_for)\n  _, stdout, stderr = Bundler.with_clean_env do\n    Open3.popen3(\n      \"cd #{RAILS_TEST_APP_DIR} && bundle exec zapata generate #{generate_for} -s\"\n    )\n  end\n\n  output = stdout.readlines\n  begin\n    generated_filename = output.last.match(/File\\ (.+)\\ was/)[1]\n  rescue StandardError\n    raise \"Did not get the message that file was generated. Got this instead:\n      STDOUT: #{output}\n      STDERR: #{stderr.readlines}\"\n  end\n  spec_path = \"#{RAILS_TEST_APP_DIR}/#{generated_filename}\"\n\n  clean(\n    <<-ACTUAL\n      #{File.read(spec_path)}\n    ACTUAL\n  )\nend\n\ndef has_block(name, expected_content)\n  generated_lines = @generated.split(\"\\n\")\n  it_starts = generated_lines.index { |line| line == \"it '#{name}' do\" }\n  raise 'No such block' unless it_starts\n\n  might_match_lines = generated_lines[it_starts..-1]\n  it_ends = might_match_lines.index { |line| line == 'end' }\n\n  block = might_match_lines[1...it_ends].first\n  expect(block).to eq(expected_content.strip)\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/README.md",
    "content": "# Zapata Rails test\n\nJust a testing app for [Zapata gem](https://github.com/Nedomas/zapata)\n"
  },
  {
    "path": "spec/support/rails_test_app/Rakefile",
    "content": "# Add your own tasks in files placed in lib/tasks ending in .rake,\n# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.\n\nrequire File.expand_path('../config/application', __FILE__)\n\nRails.application.load_tasks\n"
  },
  {
    "path": "spec/support/rails_test_app/app/assets/config/manifest.js",
    "content": "//= link_tree ../images\n//= link_directory ../javascripts .js\n//= link_directory ../stylesheets .css\n"
  },
  {
    "path": "spec/support/rails_test_app/app/assets/images/.keep",
    "content": ""
  },
  {
    "path": "spec/support/rails_test_app/app/assets/javascripts/application.js",
    "content": "// This is a manifest file that'll be compiled into application.js, which will include all the files\n// listed below.\n//\n// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,\n// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.\n//\n// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the\n// compiled file.\n//\n// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details\n// about supported directives.\n//\n//= require jquery\n//= require jquery_ujs\n//= require turbolinks\n//= require_tree .\n"
  },
  {
    "path": "spec/support/rails_test_app/app/assets/stylesheets/application.css",
    "content": "/*\n * This is a manifest file that'll be compiled into application.css, which will include all the files\n * listed below.\n *\n * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,\n * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.\n *\n * You're free to add application-wide styles to this file and they'll appear at the bottom of the\n * compiled file so the styles you add here take precedence over styles defined in any styles\n * defined in the other CSS/SCSS files in this directory. It is generally better to create a new\n * file per style scope.\n *\n *= require_tree .\n *= require_self\n */\n"
  },
  {
    "path": "spec/support/rails_test_app/app/controllers/application_controller.rb",
    "content": "class ApplicationController < ActionController::Base\n  # Prevent CSRF attacks by raising an exception.\n  # For APIs, you may want to use :null_session instead.\n  protect_from_forgery with: :exception\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/controllers/concerns/.keep",
    "content": ""
  },
  {
    "path": "spec/support/rails_test_app/app/helpers/application_helper.rb",
    "content": "module ApplicationHelper\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/mailers/.keep",
    "content": ""
  },
  {
    "path": "spec/support/rails_test_app/app/models/.keep",
    "content": ""
  },
  {
    "path": "spec/support/rails_test_app/app/models/concerns/.keep",
    "content": ""
  },
  {
    "path": "spec/support/rails_test_app/app/models/robot_to_test.rb",
    "content": "class RobotToTest\n  def initialize(human_name, _cv)\n    @name = robot_name(human_name)\n  end\n\n  def robot_name(human_name)\n    \"#{self.class.prefix}_#{human_name}\"\n  end\n\n  def cv\n    { planets: planets }\n  end\n\n  def nested_fun_objects(_fun_objects)\n    'It was fun'\n  end\n\n  def self.prefix\n    'Robot'\n  end\n\n  private\n\n  def planets\n    ['Mars', Human.home]\n  end\n\n  def fun_objects\n    [%i[array in array], { hash: nested_hash }]\n  end\n\n  def nested_hash\n    { in_hash: { in: array } }\n  end\n\n  def array\n    %w[array]\n  end\nend\n\nclass Human\n  def initialize\n    human_name = 'Emiliano'\n  end\n\n  def self.home\n    'Earth'\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/models/test_array.rb",
    "content": "class TestArray\n  def initialize\n  end\n\n  def test_in_arg(numbers_array)\n    numbers_array\n  end\n\n  def test_nested_one_level(nested_one_level)\n    nested_one_level\n  end\n\n  def test_nested_two_levels(nested_two_levels)\n    nested_two_levels\n  end\n\n  def test_nested_three_levels(nested_three_levels)\n    nested_three_levels\n  end\n\n  def test_hash_nested(hash_nested)\n    hash_nested\n  end\n\n  private\n\n  def data_to_analyze\n    numbers_array = [2, 7.1, 8]\n    nested_one_level = [numbers_array, :mexico]\n    nested_two_levels = [nested_one_level, numbers_array, :mexico]\n    nested_three_levels = [nested_two_levels, nested_one_level, numbers_array, :mexico]\n    hash_nested = [{ emiliano: numbers_array }]\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/models/test_const.rb",
    "content": "class TestConst\n  def initialize\n  end\n\n  def test_const_in_arg(const)\n    const\n  end\n\n  private\n\n  def data_to_analyze\n    const = TestConst\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/models/test_definition.rb",
    "content": "class TestDefinition\n  def in_optional_args(optional = :audioslave)\n    optional\n  end\n\n  def use_optional(optional)\n    optional\n  end\n\n  def var_in_optional_args(optional_var = fallback)\n    optional_var\n  end\n\n  def method_in_optional_args(optional_method = fall_meth)\n    optional_method\n  end\n\n  def call_method_result_in_optional_args(complex_method = fall_meth.first)\n    complex_method\n  end\n\n  def should_not_show_empty_method\n  end\n\n  def recursive_method\n    recursive_method\n  end\n\n  private\n\n  def fall_meth\n    'I am falling'\n  end\n\n  def data_to_analyze\n    fallback = 'Chuck'\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/models/test_float.rb",
    "content": "class TestFloat\n  def initialize\n  end\n\n  def test_float_in_arg(float)\n    float\n  end\n\n  private\n\n  def data_to_analyze\n    float = 2.718\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/models/test_hash.rb",
    "content": "class TestHash\n  def initialize\n  end\n\n  def test_in_arg(hash)\n    hash\n  end\n\n  def test_nested_one_level(one_level_nested_hash)\n    one_level_nested_hash\n  end\n\n  def test_nested_two_levels(two_levels_nested_hash)\n    two_levels_nested_hash\n  end\n\n  def test_nested_three_levels(three_levels_nested_hash)\n    three_levels_nested_hash\n  end\n\n  def test_key_as_another_hash(key_as_another_hash)\n    key_as_another_hash\n  end\n\n  def test_keys_are_symbols(pretty_hash)\n    pretty_hash\n  end\n\n  private\n\n  def data_to_analyze\n    hash = { 1 => :one, TestHash => 2.718 }\n    one_level_nested_hash = { first_level: hash }\n    two_levels_nested_hash = { second_level: one_level_nested_hash }\n    three_levels_nested_hash = { third_level: two_levels_nested_hash }\n    key_as_another_hash = { hash => :ratm }\n    pretty_hash = { this: 'should', be: 'pretty' }\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/models/test_int.rb",
    "content": "class TestInt\n  def initialize\n  end\n\n  def test_int_in_arg(int)\n    int\n  end\n\n  private\n\n  def data_to_analyze\n    int = 1\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/models/test_send.rb",
    "content": "class TestSend\n  def another_method_as_arg(help_method)\n    help_method\n  end\n\n  def second_level_method_chain(second_level_method)\n    second_level_method\n  end\n\n  def third_level_method_chain(third_level_method)\n    third_level_method\n  end\n\n  def method_with_calculated_value(calculated_value)\n    calculated_value\n  end\n\n  def to_another_object(another_object_method)\n    another_object_method\n  end\n\n  def to_another_object_with_params(send_with_params)\n    send_with_params\n  end\n\n  def not_explicit_with_params(not_explicit)\n    not_explicit\n  end\n\n  def fail_to_understand(failure)\n    failure\n  end\n\n  private\n\n  def help_method\n    'Help method'\n  end\n\n  def second_level_method\n    help_method\n  end\n\n  def third_level_method\n    second_level_method\n  end\n\n  def calculated_value\n    1 + 3\n  end\n\n  def not_explicit(_name)\n    'Could you find it?'\n  end\n\n  def failure(name)\n    # does not understand :dstr\n    \"Can't you understand, #{name}?\"\n  end\n\n  def data_to_analyze\n    another_object_method = AnotherObject.my_name\n    send_with_params = AnotherObject.send_with_params(12)\n  end\nend\n\nclass AnotherObject\n  def self.my_name\n    'Domas'\n  end\n\n  def self.send_with_params(id)\n    \"Id was #{id}\"\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/models/test_str.rb",
    "content": "class TestStr\n  def initialize\n  end\n\n  def test_str_in_arg(str)\n    str\n  end\n\n  private\n\n  def data_to_analyze\n    str = 'audioslave'\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/models/test_sym.rb",
    "content": "class TestSym\n  def initialize\n  end\n\n  def test_sym_in_arg(sym)\n    sym\n  end\n\n  private\n\n  def data_to_analyze\n    sym = :rock\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/models/testing_module/bare.rb",
    "content": "module TestingModule\n  class Bare\n    def initialize\n    end\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/models/testing_module/klass_methods.rb",
    "content": "module TestingModule\n  class KlassMethods\n    def self.defined_with_self(klass_methods_int)\n      klass_methods_int\n    end\n\n    class << self\n      def defined_with_back_back_self(klass_methods_int)\n        klass_methods_int\n      end\n    end\n\n    private\n\n    class << self\n      def privately_defined_with_back_back_self(klass_methods_int)\n        klass_methods_int\n      end\n    end\n\n    def self.privately_defined_with_self(klass_methods_int)\n      klass_methods_int\n    end\n\n    protected\n\n    class << self\n      def protectedly_defined_with_back_back_self(klass_methods_int)\n        klass_methods_int\n      end\n    end\n\n    def self.protectedly_defined_with_self(klass_methods_int)\n      klass_methods_int\n    end\n\n    def data_to_analyze\n      klass_methods_int = 5\n    end\n\n    public\n\n    def self.back_to_public_defined_with_self(klass_methods_int)\n      klass_methods_int\n    end\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/models/testing_module/nested/inside.rb",
    "content": "module TestingModule\n  module Nested\n    class Inside\n      def initialize\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/app/views/layouts/application.html.erb",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <title>ZapataRailsTest</title>\n  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>\n  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>\n  <%= csrf_meta_tags %>\n</head>\n<body>\n\n<%= yield %>\n\n</body>\n</html>\n"
  },
  {
    "path": "spec/support/rails_test_app/config/application.rb",
    "content": "require File.expand_path('../boot', __FILE__)\n\nrequire 'rails/all'\n\n# Require the gems listed in Gemfile, including any gems\n# you've limited to :test, :development, or :production.\nBundler.require(*Rails.groups)\n\nmodule RailsTestApp\n  class Application < Rails::Application\n    # Settings in config/environments/* take precedence over those specified here.\n    # Application configuration should go into files in config/initializers\n    # -- all .rb files in that directory are automatically loaded.\n\n    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.\n    # Run \"rake -D time\" for a list of tasks for finding time zone names. Default is UTC.\n    # config.time_zone = 'Central Time (US & Canada)'\n\n    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.\n    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]\n    # config.i18n.default_locale = :de\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/config/boot.rb",
    "content": "# Set up gems listed in the Gemfile.\nENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)\n\nrequire 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])\n"
  },
  {
    "path": "spec/support/rails_test_app/config/database.yml",
    "content": "# SQLite version 3.x\n#   gem install sqlite3\n#\n#   Ensure the SQLite 3 gem is defined in your Gemfile\n#   gem 'sqlite3'\n#\ndefault: &default\n  adapter: sqlite3\n  pool: 5\n  timeout: 5000\n\ndevelopment:\n  <<: *default\n  database: db/development.sqlite3\n\n# Warning: The database defined as \"test\" will be erased and\n# re-generated from your development database when you run \"rake\".\n# Do not set this db to the same as development or production.\ntest:\n  <<: *default\n  database: db/test.sqlite3\n\nproduction:\n  <<: *default\n  database: db/production.sqlite3\n"
  },
  {
    "path": "spec/support/rails_test_app/config/environment.rb",
    "content": "# Load the Rails application.\nrequire File.expand_path('../application', __FILE__)\n\n# Initialize the Rails application.\nRails.application.initialize!\n"
  },
  {
    "path": "spec/support/rails_test_app/config/environments/development.rb",
    "content": "Rails.application.configure do\n  # Settings specified here will take precedence over those in config/application.rb.\n\n  # In the development environment your application's code is reloaded on\n  # every request. This slows down response time but is perfect for development\n  # since you don't have to restart the web server when you make code changes.\n  config.cache_classes = false\n\n  # Do not eager load code on boot.\n  config.eager_load = false\n\n  # Show full error reports and disable caching.\n  config.consider_all_requests_local       = true\n  config.action_controller.perform_caching = false\n\n  # Don't care if the mailer can't send.\n  config.action_mailer.raise_delivery_errors = false\n\n  # Print deprecation notices to the Rails logger.\n  config.active_support.deprecation = :log\n\n  # Raise an error on page load if there are pending migrations.\n  config.active_record.migration_error = :page_load\n\n  # Debug mode disables concatenation and preprocessing of assets.\n  # This option may cause significant delays in view rendering with a large\n  # number of complex assets.\n  config.assets.debug = true\n\n  # Adds additional error checking when serving assets at runtime.\n  # Checks for improperly declared sprockets dependencies.\n  # Raises helpful error messages.\n  config.assets.raise_runtime_errors = true\n\n  # Raises error for missing translations\n  # config.action_view.raise_on_missing_translations = true\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/config/environments/production.rb",
    "content": "Rails.application.configure do\n  # Settings specified here will take precedence over those in config/application.rb.\n\n  # Code is not reloaded between requests.\n  config.cache_classes = true\n\n  # Eager load code on boot. This eager loads most of Rails and\n  # your application in memory, allowing both threaded web servers\n  # and those relying on copy on write to perform better.\n  # Rake tasks automatically ignore this option for performance.\n  config.eager_load = true\n\n  # Full error reports are disabled and caching is turned on.\n  config.consider_all_requests_local       = false\n  config.action_controller.perform_caching = true\n\n  # Enable Rack::Cache to put a simple HTTP cache in front of your application\n  # Add `rack-cache` to your Gemfile before enabling this.\n  # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.\n  # config.action_dispatch.rack_cache = true\n\n  # Disable Rails's static asset server (Apache or nginx will already do this).\n  config.serve_static_assets = false\n\n  # Compress JavaScripts and CSS.\n  config.assets.js_compressor = :uglifier\n  # config.assets.css_compressor = :sass\n\n  # Do not fallback to assets pipeline if a precompiled asset is missed.\n  config.assets.compile = false\n\n  # Generate digests for assets URLs.\n  config.assets.digest = true\n\n  # Version of your assets, change this if you want to expire all your assets.\n  config.assets.version = '1.0'\n\n  # Specifies the header that your server uses for sending files.\n  # config.action_dispatch.x_sendfile_header = \"X-Sendfile\" # for apache\n  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx\n\n  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.\n  # config.force_ssl = true\n\n  # Set to :debug to see everything in the log.\n  config.log_level = :info\n\n  # Prepend all log lines with the following tags.\n  # config.log_tags = [ :subdomain, :uuid ]\n\n  # Use a different logger for distributed setups.\n  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)\n\n  # Use a different cache store in production.\n  # config.cache_store = :mem_cache_store\n\n  # Enable serving of images, stylesheets, and JavaScripts from an asset server.\n  # config.action_controller.asset_host = \"http://assets.example.com\"\n\n  # Precompile additional assets.\n  # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.\n  # config.assets.precompile += %w( search.js )\n\n  # Ignore bad email addresses and do not raise email delivery errors.\n  # Set this to true and configure the email server for immediate delivery to raise delivery errors.\n  # config.action_mailer.raise_delivery_errors = false\n\n  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to\n  # the I18n.default_locale when a translation cannot be found).\n  config.i18n.fallbacks = true\n\n  # Send deprecation notices to registered listeners.\n  config.active_support.deprecation = :notify\n\n  # Disable automatic flushing of the log to improve performance.\n  # config.autoflush_log = false\n\n  # Use default logging formatter so that PID and timestamp are not suppressed.\n  config.log_formatter = ::Logger::Formatter.new\n\n  # Do not dump schema after migrations.\n  config.active_record.dump_schema_after_migration = false\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/config/environments/test.rb",
    "content": "Rails.application.configure do\n  # Settings specified here will take precedence over those in config/application.rb.\n\n  # The test environment is used exclusively to run your application's\n  # test suite. You never need to work with it otherwise. Remember that\n  # your test database is \"scratch space\" for the test suite and is wiped\n  # and recreated between test runs. Don't rely on the data there!\n  config.cache_classes = true\n\n  # Do not eager load code on boot. This avoids loading your whole application\n  # just for the purpose of running a single test. If you are using a tool that\n  # preloads Rails for running tests, you may have to set it to true.\n  config.eager_load = false\n\n  # Configure static asset server for tests with Cache-Control for performance.\n  config.serve_static_assets  = true\n  config.static_cache_control = 'public, max-age=3600'\n\n  # Show full error reports and disable caching.\n  config.consider_all_requests_local       = true\n  config.action_controller.perform_caching = false\n\n  # Raise exceptions instead of rendering exception templates.\n  config.action_dispatch.show_exceptions = false\n\n  # Disable request forgery protection in test environment.\n  config.action_controller.allow_forgery_protection = false\n\n  # Tell Action Mailer not to deliver emails to the real world.\n  # The :test delivery method accumulates sent emails in the\n  # ActionMailer::Base.deliveries array.\n  config.action_mailer.delivery_method = :test\n\n  # Print deprecation notices to the stderr.\n  config.active_support.deprecation = :stderr\n\n  # Raises error for missing translations\n  # config.action_view.raise_on_missing_translations = true\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/config/initializers/backtrace_silencers.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\n# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.\n# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }\n\n# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.\n# Rails.backtrace_cleaner.remove_silencers!\n"
  },
  {
    "path": "spec/support/rails_test_app/config/initializers/cookies_serializer.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\nRails.application.config.action_dispatch.cookies_serializer = :json\n"
  },
  {
    "path": "spec/support/rails_test_app/config/initializers/filter_parameter_logging.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\n# Configure sensitive parameters which will be filtered from the log file.\nRails.application.config.filter_parameters += [:password]\n"
  },
  {
    "path": "spec/support/rails_test_app/config/initializers/inflections.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\n# Add new inflection rules using the following format. Inflections\n# are locale specific, and you may define rules for as many different\n# locales as you wish. All of these examples are active by default:\n# ActiveSupport::Inflector.inflections(:en) do |inflect|\n#   inflect.plural /^(ox)$/i, '\\1en'\n#   inflect.singular /^(ox)en/i, '\\1'\n#   inflect.irregular 'person', 'people'\n#   inflect.uncountable %w( fish sheep )\n# end\n\n# These inflection rules are supported but not enabled by default:\n# ActiveSupport::Inflector.inflections(:en) do |inflect|\n#   inflect.acronym 'RESTful'\n# end\n"
  },
  {
    "path": "spec/support/rails_test_app/config/initializers/mime_types.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\n# Add new mime types for use in respond_to blocks:\n# Mime::Type.register \"text/richtext\", :rtf\n"
  },
  {
    "path": "spec/support/rails_test_app/config/initializers/session_store.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\nRails.application.config.session_store :cookie_store, key: '_zapata_rails_test_session'\n"
  },
  {
    "path": "spec/support/rails_test_app/config/initializers/wrap_parameters.rb",
    "content": "# Be sure to restart your server when you modify this file.\n\n# This file contains settings for ActionController::ParamsWrapper which\n# is enabled by default.\n\n# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.\nActiveSupport.on_load(:action_controller) do\n  wrap_parameters format: [:json] if respond_to?(:wrap_parameters)\nend\n\n# To enable root element in JSON for ActiveRecord objects.\n# ActiveSupport.on_load(:active_record) do\n#  self.include_root_in_json = true\n# end\n"
  },
  {
    "path": "spec/support/rails_test_app/config/locales/en.yml",
    "content": "# Files in the config/locales directory are used for internationalization\n# and are automatically loaded by Rails. If you want to use locales other\n# than English, add the necessary files in this directory.\n#\n# To use the locales, use `I18n.t`:\n#\n#     I18n.t 'hello'\n#\n# In views, this is aliased to just `t`:\n#\n#     <%= t('hello') %>\n#\n# To use a different locale, set it with `I18n.locale`:\n#\n#     I18n.locale = :es\n#\n# This would use the information in config/locales/es.yml.\n#\n# To learn more, please read the Rails Internationalization guide\n# available at http://guides.rubyonrails.org/i18n.html.\n\nen:\n  hello: \"Hello world\"\n"
  },
  {
    "path": "spec/support/rails_test_app/config/routes.rb",
    "content": "Rails.application.routes.draw do\n  # The priority is based upon order of creation: first created -> highest priority.\n  # See how all your routes lay out with \"rake routes\".\n\n  # You can have the root of your site routed with \"root\"\n  # root 'welcome#index'\n\n  # Example of regular route:\n  #   get 'products/:id' => 'catalog#view'\n\n  # Example of named route that can be invoked with purchase_url(id: product.id)\n  #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase\n\n  # Example resource route (maps HTTP verbs to controller actions automatically):\n  #   resources :products\n\n  # Example resource route with options:\n  #   resources :products do\n  #     member do\n  #       get 'short'\n  #       post 'toggle'\n  #     end\n  #\n  #     collection do\n  #       get 'sold'\n  #     end\n  #   end\n\n  # Example resource route with sub-resources:\n  #   resources :products do\n  #     resources :comments, :sales\n  #     resource :seller\n  #   end\n\n  # Example resource route with more complex sub-resources:\n  #   resources :products do\n  #     resources :comments\n  #     resources :sales do\n  #       get 'recent', on: :collection\n  #     end\n  #   end\n\n  # Example resource route with concerns:\n  #   concern :toggleable do\n  #     post 'toggle'\n  #   end\n  #   resources :posts, concerns: :toggleable\n  #   resources :photos, concerns: :toggleable\n\n  # Example resource route within a namespace:\n  #   namespace :admin do\n  #     # Directs /admin/products/* to Admin::ProductsController\n  #     # (app/controllers/admin/products_controller.rb)\n  #     resources :products\n  #   end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/config/secrets.yml",
    "content": "# Be sure to restart your server when you modify this file.\n\n# Your secret key is used for verifying the integrity of signed cookies.\n# If you change this key, all old signed cookies will become invalid!\n\n# Make sure the secret is at least 30 characters and all random,\n# no regular words or you'll be exposed to dictionary attacks.\n# You can use `rake secret` to generate a secure secret key.\n\n# Make sure the secrets in this file are kept private\n# if you're sharing your code publicly.\n\ndevelopment:\n  secret_key_base: ef3f44bcc760cb4d0ffae8aba6eb815bb51ffce6282871b327adf69b91efde6e910ebf2994950d0514c97cb2f98db71e7e49144b870357c744ed3066b12d1c5a\n\ntest:\n  secret_key_base: beeab7b99b31e2b533f1b9ff126857f637fc83b50efa4e33c87dcfcd9c90b99ea29b128fc0074f028b1b639c1330efe37fd40e25a1c98dfaa0151c2638b2a334\n\n# Do not keep production secrets in the repository,\n# instead read values from the environment.\nproduction:\n  secret_key_base: <%= ENV[\"SECRET_KEY_BASE\"] %>\n"
  },
  {
    "path": "spec/support/rails_test_app/config.ru",
    "content": "# This file is used by Rack-based servers to start the application.\n\nrequire ::File.expand_path('../config/environment', __FILE__)\nrun Rails.application\n"
  },
  {
    "path": "spec/support/rails_test_app/db/seeds.rb",
    "content": "# This file should contain all the record creation needed to seed the database with its default values.\n# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).\n#\n# Examples:\n#\n#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])\n#   Mayor.create(name: 'Emanuel', city: cities.first)\n"
  },
  {
    "path": "spec/support/rails_test_app/lib/assets/.keep",
    "content": ""
  },
  {
    "path": "spec/support/rails_test_app/lib/tasks/.keep",
    "content": ""
  },
  {
    "path": "spec/support/rails_test_app/log/.keep",
    "content": ""
  },
  {
    "path": "spec/support/rails_test_app/public/404.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <title>The page you were looking for doesn't exist (404)</title>\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n  <style>\n  body {\n    background-color: #EFEFEF;\n    color: #2E2F30;\n    text-align: center;\n    font-family: arial, sans-serif;\n    margin: 0;\n  }\n\n  div.dialog {\n    width: 95%;\n    max-width: 33em;\n    margin: 4em auto 0;\n  }\n\n  div.dialog > div {\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #BBB;\n    border-top: #B00100 solid 4px;\n    border-top-left-radius: 9px;\n    border-top-right-radius: 9px;\n    background-color: white;\n    padding: 7px 12% 0;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n\n  h1 {\n    font-size: 100%;\n    color: #730E15;\n    line-height: 1.5em;\n  }\n\n  div.dialog > p {\n    margin: 0 0 1em;\n    padding: 1em;\n    background-color: #F7F7F7;\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #999;\n    border-bottom-left-radius: 4px;\n    border-bottom-right-radius: 4px;\n    border-top-color: #DADADA;\n    color: #666;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n  </style>\n</head>\n\n<body>\n  <!-- This file lives in public/404.html -->\n  <div class=\"dialog\">\n    <div>\n      <h1>The page you were looking for doesn't exist.</h1>\n      <p>You may have mistyped the address or the page may have moved.</p>\n    </div>\n    <p>If you are the application owner check the logs for more information.</p>\n  </div>\n</body>\n</html>\n"
  },
  {
    "path": "spec/support/rails_test_app/public/422.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <title>The change you wanted was rejected (422)</title>\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n  <style>\n  body {\n    background-color: #EFEFEF;\n    color: #2E2F30;\n    text-align: center;\n    font-family: arial, sans-serif;\n    margin: 0;\n  }\n\n  div.dialog {\n    width: 95%;\n    max-width: 33em;\n    margin: 4em auto 0;\n  }\n\n  div.dialog > div {\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #BBB;\n    border-top: #B00100 solid 4px;\n    border-top-left-radius: 9px;\n    border-top-right-radius: 9px;\n    background-color: white;\n    padding: 7px 12% 0;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n\n  h1 {\n    font-size: 100%;\n    color: #730E15;\n    line-height: 1.5em;\n  }\n\n  div.dialog > p {\n    margin: 0 0 1em;\n    padding: 1em;\n    background-color: #F7F7F7;\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #999;\n    border-bottom-left-radius: 4px;\n    border-bottom-right-radius: 4px;\n    border-top-color: #DADADA;\n    color: #666;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n  </style>\n</head>\n\n<body>\n  <!-- This file lives in public/422.html -->\n  <div class=\"dialog\">\n    <div>\n      <h1>The change you wanted was rejected.</h1>\n      <p>Maybe you tried to change something you didn't have access to.</p>\n    </div>\n    <p>If you are the application owner check the logs for more information.</p>\n  </div>\n</body>\n</html>\n"
  },
  {
    "path": "spec/support/rails_test_app/public/500.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <title>We're sorry, but something went wrong (500)</title>\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n  <style>\n  body {\n    background-color: #EFEFEF;\n    color: #2E2F30;\n    text-align: center;\n    font-family: arial, sans-serif;\n    margin: 0;\n  }\n\n  div.dialog {\n    width: 95%;\n    max-width: 33em;\n    margin: 4em auto 0;\n  }\n\n  div.dialog > div {\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #BBB;\n    border-top: #B00100 solid 4px;\n    border-top-left-radius: 9px;\n    border-top-right-radius: 9px;\n    background-color: white;\n    padding: 7px 12% 0;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n\n  h1 {\n    font-size: 100%;\n    color: #730E15;\n    line-height: 1.5em;\n  }\n\n  div.dialog > p {\n    margin: 0 0 1em;\n    padding: 1em;\n    background-color: #F7F7F7;\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #999;\n    border-bottom-left-radius: 4px;\n    border-bottom-right-radius: 4px;\n    border-top-color: #DADADA;\n    color: #666;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n  </style>\n</head>\n\n<body>\n  <!-- This file lives in public/500.html -->\n  <div class=\"dialog\">\n    <div>\n      <h1>We're sorry, but something went wrong.</h1>\n    </div>\n    <p>If you are the application owner check the logs for more information.</p>\n  </div>\n</body>\n</html>\n"
  },
  {
    "path": "spec/support/rails_test_app/public/robots.txt",
    "content": "# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file\n#\n# To ban all spiders from the entire site uncomment the next two lines:\n# User-agent: *\n# Disallow: /\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/robot_to_test_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe RobotToTest do\n  let(:robot_to_test) do\n    RobotToTest.new('Emiliano', planets: ['Mars', Human.home])\n  end\n\n  it '#robot_name' do\n    expect(robot_to_test.robot_name('Emiliano')).to eq('Robot_Emiliano')\n  end\n\n  it '#cv' do\n    expect(robot_to_test.cv).to eq(planets: %w(Mars Earth))\n  end\n\n  it '#nested_fun_objects' do\n    expect(robot_to_test.nested_fun_objects([[:array, :in, :array], { hash: { in_hash: { in: ['array'] } } }])).to eq('It was fun')\n  end\n\n  it '#prefix' do\n    expect(RobotToTest.prefix).to eq('Robot')\n  end\nend\n\ndescribe Human do\n  let(:human) do\n    Human.new\n  end\n\n  it '#home' do\n    expect(Human.home).to eq('Earth')\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/test_array_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe TestArray do\n  let(:test_array) do\n    TestArray.new\n  end\n\n  it '#test_in_arg' do\n    expect(test_array.test_in_arg([2, 7.1, 8])).to eq([2, 7.1, 8])\n  end\n\n  it '#test_nested_one_level' do\n    expect(test_array.test_nested_one_level([[2, 7.1, 8], :mexico])).to eq([[2, 7.1, 8], :mexico])\n  end\n\n  it '#test_nested_two_levels' do\n    expect(test_array.test_nested_two_levels([[[2, 7.1, 8], :mexico], [2, 7.1, 8], :mexico])).to eq([[[2, 7.1, 8], :mexico], [2, 7.1, 8], :mexico])\n  end\n\n  it '#test_nested_three_levels' do\n    expect(test_array.test_nested_three_levels([[[[2, 7.1, 8], :mexico], [2, 7.1, 8], :mexico], [[2, 7.1, 8], :mexico], [2, 7.1, 8], :mexico])).to eq([[[[2, 7.1, 8], :mexico], [2, 7.1, 8], :mexico], [[2, 7.1, 8], :mexico], [2, 7.1, 8], :mexico])\n  end\n\n  it '#test_hash_nested' do\n    expect(test_array.test_hash_nested([{ emiliano: [2, 7.1, 8] }])).to eq([{ emiliano: [2, 7.1, 8] }])\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/test_const_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe TestConst do\n  let(:test_const) do\n    TestConst.new\n  end\n\n  it '#test_const_in_arg' do\n    expect(test_const.test_const_in_arg(TestConst)).to eq(TestConst)\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/test_definition_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe TestDefinition do\n  let(:test_definition) do\n    TestDefinition.new\n  end\n\n  it '#in_optional_args' do\n    expect(test_definition.in_optional_args(:audioslave)).to eq(:audioslave)\n  end\n\n  it '#use_optional' do\n    expect(test_definition.use_optional(:audioslave)).to eq(:audioslave)\n  end\n\n  it '#var_in_optional_args' do\n    expect(test_definition.var_in_optional_args('Missing \"fallback\"')).to eq('Missing \"fallback\"')\n  end\n\n  it '#method_in_optional_args' do\n    expect(test_definition.method_in_optional_args('Missing \"fall_meth\"')).to eq('Missing \"fall_meth\"')\n  end\n\n  it '#call_method_result_in_optional_args' do\n    expect(test_definition.call_method_result_in_optional_args('Missing \"fall_meth.first\"')).to eq('Missing \"fall_meth.first\"')\n  end\n\n  it '#recursive_method' do\n    expect(test_definition.recursive_method).to eq('Exception in RSpec')\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/test_float_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe TestFloat do\n  let(:test_float) do\n    TestFloat.new\n  end\n\n  it '#test_float_in_arg' do\n    expect(test_float.test_float_in_arg(2.718)).to eq(2.718)\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/test_hash_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe TestHash do\n  let(:test_hash) do\n    TestHash.new\n  end\n\n  it '#test_in_arg' do\n    expect(test_hash.test_in_arg({ 1 => :one, TestHash => 2.718 })).to eq({ 1 => :one, TestHash => 2.718 })\n  end\n\n  it '#test_nested_one_level' do\n    expect(test_hash.test_nested_one_level({ first_level: { 1 => :one, TestHash => 2.718 } })).to eq({ first_level: { 1 => :one, TestHash => 2.718 } })\n  end\n\n  it '#test_nested_two_levels' do\n    expect(test_hash.test_nested_two_levels({ second_level: { first_level: { 1 => :one, TestHash => 2.718 } } })).to eq({ second_level: { first_level: { 1 => :one, TestHash => 2.718 } } })\n  end\n\n  it '#test_nested_three_levels' do\n    expect(test_hash.test_nested_three_levels({ third_level: { second_level: { first_level: { 1 => :one, TestHash => 2.718 } } } })).to eq({ third_level: { second_level: { first_level: { 1 => :one, TestHash => 2.718 } } } })\n  end\n\n  it '#test_key_as_another_hash' do\n    expect(test_hash.test_key_as_another_hash({ { 1 => :one, TestHash => 2.718 } => :ratm })).to eq({ { 1 => :one, TestHash => 2.718 } => :ratm })\n  end\n\n  it '#test_keys_are_symbols' do\n    expect(test_hash.test_keys_are_symbols({ this: 'should', be: 'pretty' })).to eq({ be: 'pretty', this: 'should' })\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/test_int_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe TestInt do\n  let(:test_int) do\n    TestInt.new\n  end\n\n  it '#test_int_in_arg' do\n    expect(test_int.test_int_in_arg(1)).to eq(1)\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/test_send_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe TestSend do\n  let(:test_send) do\n    TestSend.new\n  end\n\n  it '#another_method_as_arg' do\n    expect(test_send.another_method_as_arg('Help method')).to eq('Help method')\n  end\n\n  it '#second_level_method_chain' do\n    expect(test_send.second_level_method_chain('Missing \"help_method\"')).to eq('Missing \"help_method\"')\n  end\n\n  it '#third_level_method_chain' do\n    expect(test_send.third_level_method_chain('Missing \"second_level_method\"')).to eq('Missing \"second_level_method\"')\n  end\n\n  it '#method_with_calculated_value' do\n    expect(test_send.method_with_calculated_value('Missing \"1 + 3\"')).to eq('Missing \"1 + 3\"')\n  end\n\n  it '#to_another_object' do\n    expect(test_send.to_another_object(AnotherObject.my_name)).to eq('Domas')\n  end\n\n  it '#to_another_object_with_params' do\n    expect(test_send.to_another_object_with_params(AnotherObject.send_with_params(12))).to eq('Id was 12')\n  end\n\n  it '#not_explicit_with_params' do\n    expect(test_send.not_explicit_with_params('Could you find it?')).to eq('Could you find it?')\n  end\n\n  it '#fail_to_understand' do\n    expect(test_send.fail_to_understand('Missing \"failure\"')).to eq('Missing \"failure\"')\n  end\nend\n\ndescribe AnotherObject do\n  let(:another_object) do\n    AnotherObject.new\n  end\n\n  it '#my_name' do\n    expect(AnotherObject.my_name).to eq('Domas')\n  end\n\n  it '#send_with_params' do\n    expect(AnotherObject.send_with_params('Missing \"id\"')).to eq('Id was Missing \"id\"')\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/test_str_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe TestStr do\n  let(:test_str) do\n    TestStr.new\n  end\n\n  it '#test_str_in_arg' do\n    expect(test_str.test_str_in_arg('audioslave')).to eq('audioslave')\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/test_sym_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe TestSym do\n  let(:test_sym) do\n    TestSym.new\n  end\n\n  it '#test_sym_in_arg' do\n    expect(test_sym.test_sym_in_arg(:rock)).to eq(:rock)\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/testing_module/bare_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe TestingModule::Bare do\n  let(:bare) do\n    TestingModule::Bare.new\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/testing_module/klass_methods_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe TestingModule::KlassMethods do\n  let(:klass_methods) do\n    TestingModule::KlassMethods.new\n  end\n\n  it '#defined_with_self' do\n    expect(TestingModule::KlassMethods.defined_with_self(5)).to eq(5)\n  end\n\n  it '#defined_with_back_back_self' do\n    expect(TestingModule::KlassMethods.defined_with_back_back_self(5)).to eq(5)\n  end\n\n  it '#back_to_public_defined_with_self' do\n    expect(TestingModule::KlassMethods.back_to_public_defined_with_self(5)).to eq(5)\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/models/testing_module/nested/inside_spec.rb",
    "content": "require 'rails_helper'\n\ndescribe TestingModule::Nested::Inside do\n  let(:inside) do\n    TestingModule::Nested::Inside.new\n  end\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/rails_helper.rb",
    "content": "# This file is copied to spec/ when you run 'rails generate rspec:install'\nENV['RAILS_ENV'] ||= 'test'\nrequire 'spec_helper'\nrequire File.expand_path('../../config/environment', __FILE__)\nrequire 'rspec/rails'\n\n# Requires supporting ruby files with custom matchers and macros, etc, in\n# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are\n# run as spec files by default. This means that files in spec/support that end\n# in _spec.rb will both be required and run as specs, causing the specs to be\n# run twice. It is recommended that you do not name files matching this glob to\n# end with _spec.rb. You can configure this pattern with the --pattern\n# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.\nDir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }\n\n# Checks for pending migrations before tests are run.\n# If you are not using ActiveRecord, you can remove this line.\nActiveRecord::Migration.maintain_test_schema!\n\nRSpec.configure do |config|\n  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures\n  config.fixture_path = \"#{::Rails.root}/spec/fixtures\"\n\n  # If you're not using ActiveRecord, or you'd prefer not to run each of your\n  # examples within a transaction, remove the following line or assign false\n  # instead of true.\n  config.use_transactional_fixtures = true\n\n  # RSpec Rails can automatically mix in different behaviours to your tests\n  # based on their file location, for example enabling you to call `get` and\n  # `post` in specs under `spec/controllers`.\n  #\n  # You can disable this behaviour by removing the line below, and instead\n  # explicitly tag your specs with their type, e.g.:\n  #\n  #     RSpec.describe UsersController, type: :controller do\n  #       # ...\n  #     end\n  #\n  # The different available types are documented in the features, such as in\n  # https://relishapp.com/rspec/rspec-rails/docs\n  config.infer_spec_type_from_file_location!\nend\n"
  },
  {
    "path": "spec/support/rails_test_app/spec/spec_helper.rb",
    "content": "# This file was generated by the `rails generate rspec:install` command. Conventionally, all\n# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.\n# The generated `.rspec` file contains `--require spec_helper` which will cause this\n# file to always be loaded, without a need to explicitly require it in any files.\n#\n# Given that it is always loaded, you are encouraged to keep this file as\n# light-weight as possible. Requiring heavyweight dependencies from this file\n# will add to the boot time of your test suite on EVERY test run, even for an\n# individual file that may not need all of that loaded. Instead, make a\n# separate helper file that requires this one and then use it only in the specs\n# that actually need it.\n#\n# The `.rspec` file also contains a few flags that are not defaults but that\n# users commonly want.\n#\n# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration\nRSpec.configure do |config|\n  # The settings below are suggested to provide a good initial experience\n  # with RSpec, but feel free to customize to your heart's content.\n  #   # These two settings work together to allow you to limit a spec run\n  #   # to individual examples or groups you care about by tagging them with\n  #   # `:focus` metadata. When nothing is tagged with `:focus`, all examples\n  #   # get run.\n  #   config.filter_run :focus\n  #   config.run_all_when_everything_filtered = true\n  #\n  #   # Many RSpec users commonly either run the entire suite or an individual\n  #   # file, and it's useful to allow more verbose output when running an\n  #   # individual spec file.\n  #   if config.files_to_run.one?\n  #     # Use the documentation formatter for detailed output,\n  #     # unless a formatter has already been configured\n  #     # (e.g. via a command-line flag).\n  #     config.default_formatter = 'doc'\n  #   end\n  #\n  #   # Print the 10 slowest examples and example groups at the\n  #   # end of the spec run, to help surface which specs are running\n  #   # particularly slow.\n  #   config.profile_examples = 10\n  #\n  #   # Run specs in random order to surface order dependencies. If you find an\n  #   # order dependency and want to debug it, you can fix the order by providing\n  #   # the seed, which is printed after each run.\n  #   #     --seed 1234\n  #   config.order = :random\n  #\n  #   # Seed global randomization in this process using the `--seed` CLI option.\n  #   # Setting this allows you to use `--seed` to deterministically reproduce\n  #   # test failures related to randomization by passing the same `--seed` value\n  #   # as the one that triggered the failure.\n  #   Kernel.srand config.seed\n  #\n  #   # rspec-expectations config goes here. You can use an alternate\n  #   # assertion/expectation library such as wrong or the stdlib/minitest\n  #   # assertions if you prefer.\n  #   config.expect_with :rspec do |expectations|\n  #     # Enable only the newer, non-monkey-patching expect syntax.\n  #     # For more details, see:\n  #     #   - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax\n  #     expectations.syntax = :expect\n  #   end\n  #\n  #   # rspec-mocks config goes here. You can use an alternate test double\n  #   # library (such as bogus or mocha) by changing the `mock_with` option here.\n  #   config.mock_with :rspec do |mocks|\n  #     # Enable only the newer, non-monkey-patching expect syntax.\n  #     # For more details, see:\n  #     #   - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/\n  #     mocks.syntax = :expect\n  #\n  #     # Prevents you from mocking or stubbing a method that does not exist on\n  #     # a real object. This is generally recommended.\n  #     mocks.verify_partial_doubles = true\n  #   end\nend\n"
  },
  {
    "path": "zapata.gemspec",
    "content": "# frozen_string_literal: true\n\nlib = File.expand_path('lib', __dir__)\n$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)\nrequire 'zapata/version'\n\nGem::Specification.new do |spec|\n  spec.name          = 'zapata'\n  spec.version       = Zapata::VERSION\n  spec.authors       = ['Domas Bitvinskas']\n  spec.email         = ['domas.bitvinskas@me.com']\n  spec.summary       = 'Automatic automated test writer'\n  spec.description   = 'Who has time to write tests? This is a revolutional ' \\\n                       'tool to make them write themselves.'\n  spec.homepage      = 'https://github.com/Nedomas/zapata'\n  spec.license       = 'MIT'\n\n  spec.files         = `git ls-files -z`.split(\"\\x0\")\n  spec.executables   = ['zapata']\n  spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})\n  spec.require_paths = ['lib']\n\n  spec.add_runtime_dependency 'memoist', '~> 0.16'\n  spec.add_runtime_dependency 'parser'\n  spec.add_runtime_dependency 'rails'\n  spec.add_runtime_dependency 'rspec'\n  spec.add_runtime_dependency 'rspec-rails'\n  spec.add_runtime_dependency 'thor'\n  spec.add_runtime_dependency 'unparser'\n\n  spec.add_development_dependency 'appraisal', '~> 2.2'\n  spec.add_development_dependency 'pry'\n  spec.add_development_dependency 'rake'\n  spec.add_development_dependency 'rubocop', '~> 0.80'\n  spec.add_development_dependency 'sqlite3'\nend\n"
  }
]