split up answer validation test into themed files
This commit is contained in:
25
test/test_helpers/README.txt
Normal file
25
test/test_helpers/README.txt
Normal file
@ -0,0 +1,25 @@
|
||||
Use this folder to store mocks, stubs, etc to make isolated testing possible.
|
||||
|
||||
Some definitions borrowed from:
|
||||
http://martinfowler.com/articles/mocksArentStubs.html
|
||||
|
||||
* Dummy
|
||||
objects are passed around but never actually used.
|
||||
Usually they are just used to fill parameter lists.
|
||||
|
||||
* Fake
|
||||
objects actually have working implementations, but usually
|
||||
take some shortcut which makes them not suitable for
|
||||
production (an in memory database is a good example).
|
||||
|
||||
* Stubs
|
||||
provide canned answers to calls made during the test,
|
||||
usually not responding at all to anything outside what's
|
||||
programmed in for the test. Stubs may also record information
|
||||
about calls, such as an email gateway stub that remembers the
|
||||
messages it 'sent', or maybe only how many messages it 'sent'.
|
||||
|
||||
* Mocks
|
||||
objects pre-programmed with expectations which form a
|
||||
specification of the calls they are expected to receive.
|
||||
|
18
test/test_helpers/answer_validatable.rb
Normal file
18
test/test_helpers/answer_validatable.rb
Normal file
@ -0,0 +1,18 @@
|
||||
class AnswerValidatable
|
||||
include ActiveModel::Validations
|
||||
|
||||
attr_accessor :answer
|
||||
attr_accessor :question
|
||||
|
||||
validates :answer, answer_format: true
|
||||
|
||||
MockQuestion = Struct.new(:input_type)
|
||||
|
||||
def initialize input_type
|
||||
@input_type = input_type
|
||||
end
|
||||
|
||||
def question
|
||||
MockQuestion.new(@input_type)
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user