Module: Erlash::Testing
- Defined in:
- lib/erlash/testing.rb
Defined Under Namespace
Classes: FileAlreadyWrittenError, MessageNotRegisteredError, OverrideFileNotAllowedError
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.messages_path ⇒ Object
27 28 29 |
# File 'lib/erlash/testing.rb', line 27 def self. @messages_path end |
.messages_path=(path) ⇒ Object
23 24 25 |
# File 'lib/erlash/testing.rb', line 23 def self.(path) @messages_path = path end |
Instance Method Details
#erlash_messages_path ⇒ Object
31 32 33 |
# File 'lib/erlash/testing.rb', line 31 def @erlash_messages_path ||= Pathname.new(Erlash::Testing.) end |
#expected_message(name, message = nil, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/erlash/testing.rb', line 35 def (name, = nil, &block) filename = erlash_filename(name) file_exists = File.exists?(filename) if if file_exists raise OverrideFileNotAllowedError, { filename: filename } else File.open(filename, 'w') { |f| f.write() } raise FileAlreadyWrittenError, { filename: filename } end else if file_exists block.call(File.read(filename)) else raise MessageNotRegisteredError, { filename: filename } end end end |