Module: Ritsu::TestCaseWithFileTestData
- Defined in:
- lib/ritsu/test_helpers.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #assert_data_file_exists(filename) ⇒ Object
- #assert_data_file_not_exist(filename) ⇒ Object
- #assert_file_compare(expected_file, actual_file) ⇒ Object
- #assert_file_content(content, filename) ⇒ Object
- #assert_file_exists(filename) ⇒ Object
- #assert_file_not_exist(filename) ⇒ Object
- #assert_output_file_compare_to_static(path) ⇒ Object
- #assert_output_file_content(content, path) ⇒ Object
- #assert_output_file_exists(filename) ⇒ Object
- #assert_output_file_not_exist(filename) ⇒ Object
- #data_dir ⇒ Object
- #data_path(path) ⇒ Object
- #init_data_dir ⇒ Object
- #output_dir ⇒ Object
- #output_path(path) ⇒ Object
- #static_dir ⇒ Object
- #static_path(path) ⇒ Object
Class Method Details
.included(base) ⇒ Object
43 44 45 |
# File 'lib/ritsu/test_helpers.rb', line 43 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#assert_data_file_exists(filename) ⇒ Object
90 91 92 |
# File 'lib/ritsu/test_helpers.rb', line 90 def assert_data_file_exists(filename) assert_file_exists(data_path(filename)) end |
#assert_data_file_not_exist(filename) ⇒ Object
94 95 96 |
# File 'lib/ritsu/test_helpers.rb', line 94 def assert_data_file_not_exist(filename) assert_file_not_exist(data_path(filename)) end |
#assert_file_compare(expected_file, actual_file) ⇒ Object
111 112 113 114 |
# File 'lib/ritsu/test_helpers.rb', line 111 def assert_file_compare(expected_file, actual_file) assert_equal IO.read(expected_file), IO.read(actual_file), "content of #{actual_file} differs from #{expected_file}" end |
#assert_file_content(content, filename) ⇒ Object
106 107 108 109 |
# File 'lib/ritsu/test_helpers.rb', line 106 def assert_file_content(content, filename) assert_equal content, IO.read(filename) "content of #{filename} differs from expected" end |
#assert_file_exists(filename) ⇒ Object
78 79 80 81 82 |
# File 'lib/ritsu/test_helpers.rb', line 78 def assert_file_exists(filename) assert_block "#{filename} must exists" do File.exists?(filename) end end |
#assert_file_not_exist(filename) ⇒ Object
84 85 86 87 88 |
# File 'lib/ritsu/test_helpers.rb', line 84 def assert_file_not_exist(filename) assert_block "#{filename} must not exist" do !File.exists?(filename) end end |
#assert_output_file_compare_to_static(path) ⇒ Object
116 117 118 |
# File 'lib/ritsu/test_helpers.rb', line 116 def assert_output_file_compare_to_static(path) assert_file_compare(static_path(path), output_path(path)) end |
#assert_output_file_content(content, path) ⇒ Object
120 121 122 |
# File 'lib/ritsu/test_helpers.rb', line 120 def assert_output_file_content(content, path) assert_file_content(content, output_path(path)) end |
#assert_output_file_exists(filename) ⇒ Object
98 99 100 |
# File 'lib/ritsu/test_helpers.rb', line 98 def assert_output_file_exists(filename) assert_file_exists(output_path(filename)) end |
#assert_output_file_not_exist(filename) ⇒ Object
102 103 104 |
# File 'lib/ritsu/test_helpers.rb', line 102 def assert_output_file_not_exist(filename) assert_file_not_exist(output_path(filename)) end |
#data_dir ⇒ Object
54 55 56 |
# File 'lib/ritsu/test_helpers.rb', line 54 def data_dir raise NotImplementedError.new end |
#data_path(path) ⇒ Object
58 59 60 |
# File 'lib/ritsu/test_helpers.rb', line 58 def data_path(path) data_dir + '/' + path end |
#init_data_dir ⇒ Object
47 48 49 50 51 52 |
# File 'lib/ritsu/test_helpers.rb', line 47 def init_data_dir FileUtils.mkdir_p(data_dir) FileUtils.mkdir_p(static_dir) FileUtils.mkdir_p(output_dir) FileUtils.rm_r(Dir.glob(output_dir + '/*'), :force=>true) end |
#output_dir ⇒ Object
62 63 64 |
# File 'lib/ritsu/test_helpers.rb', line 62 def output_dir data_dir + '/output' end |
#output_path(path) ⇒ Object
66 67 68 |
# File 'lib/ritsu/test_helpers.rb', line 66 def output_path(path) output_dir + '/' + path end |
#static_dir ⇒ Object
70 71 72 |
# File 'lib/ritsu/test_helpers.rb', line 70 def static_dir data_dir + '/static' end |
#static_path(path) ⇒ Object
74 75 76 |
# File 'lib/ritsu/test_helpers.rb', line 74 def static_path(path) static_dir + '/' + path end |