Sha256: 6a553a65dfeef373cfd626cb14cf27612499ffb471b28e059003088a16f1177e

Contents?: true

Size: 820 Bytes

Versions: 20

Compression:

Stored size: 820 Bytes

Contents

class ExpectationMatcher
  require 'result'
  require 'checker'

  # dynamically load plugins
  dir = File.dirname(__FILE__) + '/plugins/'
  $LOAD_PATH.unshift(dir)
  Dir[File.join(dir, "*.rb")].each {|file| require File.basename(file) }

  def initialize(excludes=nil)
    @excludes = excludes || []
  end

  # dispatches incoming matching requests
  def check(plugin, response, testcase)
    self.send(plugin.underscore, response, testcase)
  end

  # dynamically generates methods that invoke "check" on all available plugins
  def self.initialize_plugins
    Checker.available_plugins.each do |plugin|
      define_method(plugin.underscore) do |response, testcase|
        eval(plugin).new(testcase, response, @excludes).check
      end
      private plugin.underscore.to_sym
    end
  end

  initialize_plugins
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
apirunner-0.5.5 lib/expectation_matcher.rb
apirunner-0.5.0 lib/expectation_matcher.rb
apirunner-0.4.10 lib/expectation_matcher.rb
apirunner-0.4.9 lib/expectation_matcher.rb
apirunner-0.4.8 lib/expectation_matcher.rb
apirunner-0.4.7 lib/expectation_matcher.rb
apirunner-0.4.6 lib/expectation_matcher.rb
apirunner-0.4.5 lib/expectation_matcher.rb
apirunner-0.4.4 lib/expectation_matcher.rb
apirunner-0.4.3 lib/expectation_matcher.rb
apirunner-0.4.2 lib/expectation_matcher.rb
apirunner-0.4.1 lib/expectation_matcher.rb
apirunner-0.4.0 lib/expectation_matcher.rb
apirunner-0.3.10 lib/expectation_matcher.rb
apirunner-0.3.9 lib/expectation_matcher.rb
apirunner-0.3.8 lib/expectation_matcher.rb
apirunner-0.3.7 lib/expectation_matcher.rb
apirunner-0.3.6 lib/expectation_matcher.rb
apirunner-0.3.5 lib/expectation_matcher.rb
apirunner-0.3.4 lib/expectation_matcher.rb