Class: Taza::Fixture

Inherits:
Object show all
Defined in:
lib/taza/fixture.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializeFixture

:nodoc:



4
5
6
# File 'lib/taza/fixture.rb', line 4

def initialize # :nodoc:
  @fixtures = {}
end

Instance Method Details

#base_pathObject

:nodoc:



34
35
36
# File 'lib/taza/fixture.rb', line 34

def base_path # :nodoc:
  File.join('.','spec')
end

#fixture_namesObject

:nodoc:



18
19
20
# File 'lib/taza/fixture.rb', line 18

def fixture_names # :nodoc:
  @fixtures.keys
end

#fixtures_patternObject

:nodoc:



30
31
32
# File 'lib/taza/fixture.rb', line 30

def fixtures_pattern # :nodoc:
  File.join(base_path, 'fixtures','*.yml')
end

#get_fixture_entity(fixture_file_key, entity_key) ⇒ Object

:nodoc:



22
23
24
# File 'lib/taza/fixture.rb', line 22

def get_fixture_entity(fixture_file_key,entity_key) # :nodoc:
  @fixtures[fixture_file_key][entity_key]
end

#load_allObject

:nodoc:



8
9
10
11
12
13
14
15
16
# File 'lib/taza/fixture.rb', line 8

def load_all # :nodoc:
  Dir.glob(fixtures_pattern) do |file|
    entitized_fixture = {}
    YAML.load_file(file).each do |key, value|
      entitized_fixture[key] = value.convert_hash_keys_to_methods(self)
    end
    @fixtures[File.basename(file,'.yml').to_sym] = entitized_fixture
  end
end

#pluralized_fixture_exists?(singularized_fixture_name) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


26
27
28
# File 'lib/taza/fixture.rb', line 26

def pluralized_fixture_exists?(singularized_fixture_name) # :nodoc:
  fixture_names.include?(singularized_fixture_name.pluralize_to_sym)
end