lib/snapshot/snapshot_file.rb in snapshot-0.2.4 vs lib/snapshot/snapshot_file.rb in snapshot-0.3.0

- old
+ new

@@ -14,11 +14,15 @@ eval(File.read(self.path)) end def method_missing(method_sym, *arguments, &block) - value = arguments.first || (block.call if block_given?) + if ["setup", "teardown"].any?{|a| method_sym.to_s.include?a } + value = nil # this is a block + else + value = arguments.first || (block.call if block_given?) # this is either a block or a value + end case method_sym when :devices self.verify_devices(value) when :languages @@ -49,9 +53,14 @@ if File.exists?value and (value.end_with?".xcworkspace" or value.end_with?".xcodeproj") @config.project_path = value.gsub("~", ENV['HOME']) else raise "The given project_path '#{value}' could not be found. Make sure to include the extension as well.".red end + + # Blocks + when :setup_for_device_change, :teardown_device, :setup_for_language_change, :teardown_language + raise "#{method_sym} needs to have a block provided." unless block_given? + @config.blocks[method_sym] = block else Helper.log.error "Unknown method #{method_sym}" end end \ No newline at end of file