Module: Screenplay::Scenarios

Extended by:
Scenarios
Includes:
Enumerable
Included in:
Scenarios
Defined in:
lib/screenplay/scenarios.rb

Instance Method Summary collapse

Instance Method Details

#autoloadObject



18
19
20
21
# File 'lib/screenplay/scenarios.rb', line 18

def autoload
	@path = $SCREENPLAY_SCENARIOS_DIR || Configuration[:general][:scenarios_dir] rescue File.join(Configuration.path, 'scenarios')
	load_path(@path)
end

#eachObject



32
33
34
# File 'lib/screenplay/scenarios.rb', line 32

def each
	@scenarios.each { | k | yield k }
end

#load_path(path) ⇒ Object



23
24
25
26
# File 'lib/screenplay/scenarios.rb', line 23

def load_path(path)
	yml_files = File.join(path, '**', '*.{yaml,yml}')
	Dir[yml_files].each { | filename | register(filename) }
end

#register(filename) ⇒ Object



12
13
14
15
16
# File 'lib/screenplay/scenarios.rb', line 12

def register(filename)
	name = filename.gsub(@path, '').gsub(/^\//, '') unless @path.empty?
	@scenarios.push(Scenario.new(name, filename))
	@scenarios.sort_by{ | actor | actor.name }
end

#sizeObject



28
29
30
# File 'lib/screenplay/scenarios.rb', line 28

def size
	@scenarios.size
end