Module: Safubot::Test

Defined in:
lib/safubot/test_helper.rb

Overview

Helpful methods for testing either via RSpec or IRB.

Class Method Summary collapse

Class Method Details

.clean_environmentObject

Switches to the “safubot_testing” database and clears all data.



22
23
24
25
26
27
28
29
30
# File 'lib/safubot/test_helper.rb', line 22

def clean_environment
		MongoMapper.database = "safubot_testing"
  Request.destroy_all
		Query.destroy_all
  Response.destroy_all
		KnownUser.destroy_all
		Safubot::mode = :testing
  $bot = Safubot::Bot.new(:database => "safubot_testing")
end

.request(text) ⇒ Object

Creates a Query-sourced testing Request.

Parameters:

  • text

    The body of the Request.



34
35
36
# File 'lib/safubot/test_helper.rb', line 34

def request(text)
		Query.create(:user => KnownUser.by_name('testing'), :text => text).make_request
end