Sha256: 7bf39bc8fce51b47a86f2744d3ceac39f63d6c37d34fc7c9d73093131236fc8f

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe Snuffle::LatentObject do

  let(:program_2) { Snuffle::SourceFile.new(path_to_file: "spec/fixtures/latent_object_fixture.rb") }

  describe ".from" do

    let(:results) { Snuffle::LatentObject.from(program_2.nodes) }

    it "returns an array of LatentObject instances" do
      expect(results.first.class.name).to eq "Snuffle::LatentObject"
    end

    it "returns instances with object candidates" do
      expect(results.first.object_candidate).to eq "user"
    end

    it "returns instances with source methods" do
      expect(results.first.source_methods).to eq ["user_name", "user_address", "user_email"]
    end

  end

  describe ".potential_objects_with_methods" do

    let(:results) { Snuffle::LatentObject.potential_objects_with_methods(program_2.nodes) }

    it "finds repeated words " do
      expect(results.keys).to eq(["user"])
    end

    it "finds methods that repeated words appear in" do
      expect(results['user']).to eq(["user_name", "user_address", "user_email"])
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
snuffle-0.12.2 spec/snuffle/latent_object_spec.rb
snuffle-0.12.1 spec/snuffle/latent_object_spec.rb
snuffle-0.12.0 spec/snuffle/latent_object_spec.rb
snuffle-0.11.1 spec/snuffle/latent_object_spec.rb
snuffle-0.10.1 spec/snuffle/latent_object_spec.rb