Sha256: 58ffa8077b0d2765bd670b870801999ba0d80351227acd89b1f11bf27e146b7e
Contents?: true
Size: 1.95 KB
Versions: 5
Compression:
Stored size: 1.95 KB
Contents
def use_fanforce_test_helpers(browser_method) include Fanforce::Test::RakeHelpers load_helper_methods(browser_method) end def enable_fanforce_test(base_dir) Fanforce::Test.setup_env(base_dir) end module Fanforce::Test::RakeHelpers def load_helper_methods(browser_method) @@api_browser_method = browser_method end def api_browser method(@@api_browser_method).call end def last_api_response(response) @last_api_response = response end def reset_fanforce_db @supercore_api_key = api_post('/test/clean_dbs', show_error_details: 'text')[:supercore_api_key] end def reset_fanforce_db_with_plugins reset_fanforce_db api_post('/test/setup_plugins', show_error_details: 'text') end def supercore_api_key @supercore_api_key end def ff @ff ||= Fanforce::API.new end def api_get(path, query={}, rack_env={}) query.update(api_key: supercore_api_key) if rack_env[:access_type] == :supercore last_api_response ff.get(path, query) end def api_post(path, query={}, rack_env={}) query.update(api_key: supercore_api_key) if rack_env[:access_type] == :supercore last_api_response ff.post path, query end def api_put(path, query={}, rack_env={}) query.update(api_key: supercore_api_key) if rack_env[:access_type] == :supercore last_api_response ff.put path, query end def api_delete(path, query={}, rack_env={}) query.update(api_key: supercore_api_key) if rack_env[:access_type] == :supercore last_api_response ff.delete path, query end def method_missing(method, *args, &block) return @last_api_response if method == :last_response super end end ######################################################################################################################## class Rack::MockResponse def to_hash @hash ||= MultiJson.load(body, :symbolize_keys => true) end def to_json body.to_s end def to_s body.to_s end def [](key) to_hash[key] end end
Version data entries
5 entries across 5 versions & 1 rubygems