Module: BotAway::TestCase

Defined in:
lib/bot-away/test_case.rb

Defined Under Namespace

Modules: ControllerTestCase, InstanceTagTestCase, Matchers Classes: MockObject

Instance Method Summary collapse

Instance Method Details

#builderObject



7
8
9
# File 'lib/bot-away/test_case.rb', line 7

def builder
  @builder ||= ActionView::Base.default_form_builder.new(object_name, mock_object, view, {}, proc {})
end

#disable_forgery_protectionObject



20
21
22
23
# File 'lib/bot-away/test_case.rb', line 20

def disable_forgery_protection
  Rails.application.config.allow_forgery_protection = false
  ActionController::Base.allow_forgery_protection = false
end

#dumpObject



53
54
55
56
57
# File 'lib/bot-away/test_case.rb', line 53

def dump
  result = yield
  puts result if ENV['DUMP']
  result
end

#enable_forgery_protectionObject



11
12
13
14
15
16
17
18
# File 'lib/bot-away/test_case.rb', line 11

def enable_forgery_protection
  # BotAway doesn't work without forgery protection, and RSpec-Rails 2 disables it.
  # Lost way too many hours on this.
  # Note: This has to happen in spec file because RSpec2 sets a before block, which runs
  # after the ones set by config.
  Rails.application.config.allow_forgery_protection = true
  ActionController::Base.allow_forgery_protection = true
end

#method_nameObject



41
42
43
# File 'lib/bot-away/test_case.rb', line 41

def method_name
  "method_name"
end

#mock_objectObject



25
26
27
# File 'lib/bot-away/test_case.rb', line 25

def mock_object
  @mock_object ||= MockObject.new
end

#obfuscated_idObject



29
30
31
# File 'lib/bot-away/test_case.rb', line 29

def obfuscated_id
  "f51a02a636f507f1bd64722451b71297"
end

#obfuscated_nameObject



33
34
35
# File 'lib/bot-away/test_case.rb', line 33

def obfuscated_name
  "cd538a9170613d6dedbcc54a0aa24881"
end

#object_nameObject



37
38
39
# File 'lib/bot-away/test_case.rb', line 37

def object_name
  "object_name"
end

#tag_idObject



45
46
47
# File 'lib/bot-away/test_case.rb', line 45

def tag_id
  "#{object_name}_#{method_name}"
end

#tag_nameObject



49
50
51
# File 'lib/bot-away/test_case.rb', line 49

def tag_name
  "#{object_name}[#{method_name}]"
end