module StaticMock
Constants
- OUTPUT_DIR
- VERSION
Public Class Methods
define_step(step_name, &block)
click to toggle source
# File lib/static_mock.rb, line 22 def self.define_step(step_name, &block) raise StepDefinitionError if block.nil? step_out_file = File.join(OUTPUT_DIR, "#{step_name}.yml") File.delete(step_out_file) if File.exist?(step_out_file) Step.new(step_name, block).tap { |step| @@steps << step } end
init()
click to toggle source
# File lib/static_mock.rb, line 13 def self.init Object.include(ObjectExtension) Dir.mkdir(OUTPUT_DIR) unless Dir.exist?(OUTPUT_DIR) @@steps = [] @@mocks = [] end
load_mocks(step_name)
click to toggle source
# File lib/static_mock.rb, line 43 def self.load_mocks(step_name) ret = [] $/="\n\n" File.open(File.join(OUTPUT_DIR, "#{step_name}.yml"), 'r').each do |obj| ret << YAML::load(obj) end ret end
mock(*mock_list)
click to toggle source
# File lib/static_mock.rb, line 39 def self.mock(*mock_list) @@mocks = mock_list end
run()
click to toggle source
# File lib/static_mock.rb, line 31 def self.run @@steps.each do |step| step.run @@mocks.each { |o| o.static_mock(step.step_name, OUTPUT_DIR) } end end