Class: TDriver::FixturePluginService
- Defined in:
- lib/tdriver/util/fixture/service.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ FixturePluginService
constructor
TODO: document me.
- #method_missing(fixture_method, arguments = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ FixturePluginService
TODO: document me
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tdriver/util/fixture/service.rb', line 32 def initialize( = {} ) # verify that options is type of hash .check_type Hash, 'wrong argument type $1 for fixture service options (expected $2)' # verify that name is defined in options hash .require_key :name .require_key :arguments .require_key :target .require_key :configuration # store given options @options = # store caller backtrace @caller = caller self end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(fixture_method, arguments = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/tdriver/util/fixture/service.rb', line 56 def method_missing( fixture_method, arguments = {} ) begin arguments.check_type Hash, 'wrong argument type $1 for fixture method arguments (expected $2)' result = nil _async = @options[ :arguments ][ :async ].true? _target = @options[ :target ] _fixture_name = @options[ :name ].to_s _fixture_method = fixture_method.to_s _sut = _target.sut params = { :name => _fixture_name.to_s, :command_name => _fixture_method, :parameters => arguments, :async => _async } if _target.sut? params.merge!( :application_id => nil, :object_id => _target.id, :object_type => :Application ) else params.merge!( :application_id => _target.get_application_id, :object_id => _target.id, :object_type => _target.attribute( 'objectType' ).to_sym ) end result = _sut.execute_command( MobyCommand::Fixture.new( params ) ) rescue $logger.behaviour "FAIL;Failed when calling fixture #{ @options[:arguments ].inspect } with name #{ _fixture_name.inspect }, method #{ _fixture_method.inspect } and parameters #{ arguments.inspect }.;#{ _target.id.to_s };sut;{};fixture;" raise MobyBase::BehaviourError.new("Fixture", "Failed when calling fixture #{ @options[:arguments ].inspect } with name #{ _fixture_name.inspect }, method #{ _fixture_method.inspect } and parameters #{ arguments.inspect }") end $logger.behaviour "PASS;The fixture command (#{ @options[ :arguments ]}) was executed successfully with name #{ _fixture_name.inspect }, method #{ _fixture_method.inspect } and parameters #{ arguments.inspect }.;#{ _target.id.to_s };sut;{};fixture;" result end |