lib/tryouts.rb in tryouts-0.7.1 vs lib/tryouts.rb in tryouts-0.7.2
- old
+ new
@@ -28,13 +28,22 @@
# = Exception
# A generic exception which all other Tryouts exceptions inherit from.
class Exception < RuntimeError; end
# = BadDreams
# Raised when there is a problem loading or parsing a Tryouts::Drill::Dream object
- class BadDreams < Exception; end
+ class BadDream < Exception; end
- VERSION = "0.7.1"
+ class NoDrillType < Exception
+ attr_accessor :tname
+ def initialize(t); @tname = t; end
+ def message
+ vdt = Tryouts::Drill.valid_dtypes
+ "Tryout '#{@tname}' has no drill type. Should be: #{vdt.join(', ')}"
+ end
+ end
+
+ VERSION = "0.7.2"
require 'tryouts/mixins'
require 'tryouts/tryout'
require 'tryouts/drill'
require 'tryouts/stats'
@@ -165,21 +174,21 @@
raise "Group is already set: #{@@instances.last.group}"
end
# Create a new Tryout object and add it to the list for this Tryouts class.
# * +name+ is the name of the Tryout
- # * +type+ is the default drill type for the Tryout. One of: :cli, :api
+ # * +dtype+ is the default drill type for the Tryout.
# * +command+ when type is :cli, this is the name of the Rye::Box method that we're testing. Otherwise ignored.
# * +b+ is a block definition for the Tryout. See Tryout#from_block
#
# NOTE: This is a DSL-only method and is not intended for OO use.
def tryout(name, dtype=nil, command=nil, &block)
return if name.nil?
dtype ||= @dtype
command ||= @command if dtype == :cli
- raise "No drill type specified for #{name}." if dtype.nil?
+ raise NoDrillType, name if dtype.nil?
to = find_tryout(name, dtype)
if to.nil?
to = Tryouts::Tryout.new(name, dtype, command)
@tryouts[name] = to
@@ -238,18 +247,18 @@
def self.parse_file(fpath)
raise "No such file: #{fpath}" unless File.exists?(fpath)
file_content = File.read(fpath)
to = Tryouts.new
begin
+ to.paths << fpath
to.instance_eval file_content, fpath
# After parsing the DSL, we'll know the group name.
# If a Tryouts object already exists for that group
# we'll use that instead and re-parse the DSL.
if @@instances.has_key? to.group
to = @@instances[to.group]
to.instance_eval file_content, fpath
end
- to.paths << fpath
rescue SyntaxError, LoadError, Exception, TypeError,
RuntimeError, NoMethodError, NameError => ex
to.errors << ex
Tryouts.failed = true
end