test/app_test_methods.rb in ruboto-0.9.0.rc.1 vs test/app_test_methods.rb in ruboto-0.9.0
- old
+ new
@@ -2,14 +2,15 @@
module AppTestMethods
include RubotoTest
def test_activity_tests
+ assert_code 'Base64Loads', "require 'base64'"
assert_code 'YamlLoads', "with_large_stack{require 'yaml'}"
assert_code 'ReadSourceFile', 'File.read(__FILE__)'
assert_code 'DirListsFilesInApk', 'Dir["#{File.dirname(__FILE__)}/*"].each{|f| raise "File #{f.inspect} not found" unless File.exists?(f)}'
- assert_code 'RepeatRubotoImport', 'ruboto_import :TextView ; ruboto_import :TextView'
+ assert_code 'RepeatRubotoImportWidget', 'ruboto_import_widget :TextView ; ruboto_import_widget :TextView'
run_activity_tests('activity')
end
def test_block_def_activity_tests
run_activity_tests('block_def_activity')
@@ -24,15 +25,15 @@
end
private
def assert_code(activity_name, code)
- snake_name = activity_name.scan(/[A-Z]+[a-z]+/).map { |s| s.downcase }.join('_')
+ snake_name = activity_name.scan(/[A-Z]+[a-z0-9]+/).map { |s| s.downcase }.join('_')
filename = "src/#{snake_name}_activity.rb"
Dir.chdir APP_DIR do
system "#{RUBOTO_CMD} gen class Activity --name #{activity_name}Activity"
s = File.read(filename)
- s.gsub!(/(require 'ruboto')/, "\\1\n#{code}")
+ raise "Code injection failed!" unless s.gsub!(/(require 'ruboto\/widget')/, "\\1\n#{code}")
File.open(filename, 'w') { |f| f << s }
end
end
def run_activity_tests(activity_dir)