Class: Pinspec::FactoryIndex

Inherits:
Data
  • Object
show all
Defined in:
lib/pinspec/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#factoriesObject (readonly)

Returns the value of attribute factories

Returns:

  • (Object)

    the current value of factories



345
346
347
# File 'lib/pinspec/types.rb', line 345

def factories
  @factories
end

#legacy_dslObject (readonly)

Returns the value of attribute legacy_dsl

Returns:

  • (Object)

    the current value of legacy_dsl



345
346
347
# File 'lib/pinspec/types.rb', line 345

def legacy_dsl
  @legacy_dsl
end

#skippedObject (readonly)

Returns the value of attribute skipped

Returns:

  • (Object)

    the current value of skipped



345
346
347
# File 'lib/pinspec/types.rb', line 345

def skipped
  @skipped
end

Instance Method Details

#dsl_moduleObject



357
358
359
# File 'lib/pinspec/types.rb', line 357

def dsl_module
  legacy_dsl ? "FactoryGirl" : "FactoryBot"
end

#factory(name) ⇒ Object



346
347
348
349
350
351
# File 'lib/pinspec/types.rb', line 346

def factory(name)
  wanted = name.to_sym

  factories.find { |f| f.name == wanted } ||
    factories.find { |f| f.aliases.include?(wanted) }
end

#for_model(model) ⇒ Object



353
354
355
# File 'lib/pinspec/types.rb', line 353

def for_model(model)
  factories.select { |f| f.model == model.to_s }
end