Best Rr_ruby code snippet using Project.Ruby.setup
test_app_config.rb
Source:test_app_config.rb
...23 DEFAULT_CONFIG =24 "env: flex\nruntime: ruby\nentrypoint: bundle exec ruby start.rb\n"25 CASES_DIR = ::File.join __dir__, "app_config"26 TMP_DIR = ::File.join __dir__, "tmp"27 def setup_test dir: nil, config: DEFAULT_CONFIG,28 config_file: nil, project: nil29 ::Dir.chdir __dir__ do30 ::FileUtils.rm_rf TMP_DIR31 if dir32 full_dir = ::File.join CASES_DIR, dir33 ::FileUtils.cp_r full_dir, TMP_DIR34 else35 ::FileUtils.mkdir TMP_DIR36 end37 ::ENV["GAE_APPLICATION_YAML_PATH"] = config_file38 ::ENV["PROJECT_ID"] = project39 if config40 config_path = ::File.join TMP_DIR, config_file || "app.yaml"41 ::File.open config_path, "w" do |file|42 file.write config43 end44 end45 ::Bundler.with_unbundled_env { @app_config = AppConfig.new TMP_DIR }46 end47 end48 def test_empty_directory_with_config49 setup_test50 assert_equal TMP_DIR, @app_config.workspace_dir51 assert_equal "./app.yaml", @app_config.app_yaml_path52 assert_nil @app_config.project_id53 assert_equal "(unknown)", @app_config.project_id_for_display54 assert_equal "my-project-id", @app_config.project_id_for_example55 assert_equal "default", @app_config.service_name56 assert_equal EMPTY_HASH, @app_config.env_variables57 assert_equal EMPTY_ARRAY, @app_config.cloud_sql_instances58 assert_equal EMPTY_ARRAY, @app_config.build_scripts59 assert_equal EMPTY_HASH, @app_config.runtime_config60 assert_equal "exec bundle exec ruby start.rb", @app_config.entrypoint61 assert_equal EMPTY_ARRAY, @app_config.install_packages62 assert_equal EMPTY_STRING, @app_config.ruby_version63 refute @app_config.has_gemfile64 end65 def test_basic_app_yaml66 config = <<~CONFIG67 env: flex68 runtime: ruby69 entrypoint: bundle exec bin/rails s70 env_variables:71 VAR1: value172 VAR2: value273 VAR3: 12374 beta_settings:75 cloud_sql_instances: cloud-sql-instance-name,instance276 runtime_config:77 foo: bar78 packages: libgeos79 build: bundle exec rake hello80 CONFIG81 setup_test config: config82 assert_equal({"VAR1" => "value1", "VAR2" => "value2", "VAR3" => "123"},83 @app_config.env_variables)84 assert_equal ["cloud-sql-instance-name", "instance2"],85 @app_config.cloud_sql_instances86 assert_equal ["bundle exec rake hello"], @app_config.build_scripts87 assert_equal "exec bundle exec bin/rails s", @app_config.entrypoint88 assert_equal ["libgeos"], @app_config.install_packages89 assert_equal "bar", @app_config.runtime_config["foo"]90 end91 def test_complex_entrypoint92 config = <<~CONFIG93 env: flex94 runtime: ruby95 entrypoint: cd myapp; bundle exec bin/rails s96 CONFIG97 setup_test config: config98 assert_equal "cd myapp; bundle exec bin/rails s", @app_config.entrypoint99 end100 def test_entrypoint_with_env101 config = <<~CONFIG102 env: flex103 runtime: ruby104 entrypoint: RAILS_ENV=staging bundle exec bin/rails s105 CONFIG106 setup_test config: config107 assert_equal "RAILS_ENV=staging bundle exec bin/rails s",108 @app_config.entrypoint109 end110 def test_entrypoint_already_exec111 config = <<~CONFIG112 env: flex113 runtime: ruby114 entrypoint: exec bundle exec bin/rails s115 CONFIG116 setup_test config: config117 assert_equal "exec bundle exec bin/rails s", @app_config.entrypoint118 end119 def test_rails_default_build120 setup_test dir: "rails"121 assert_equal ["bundle exec rake assets:precompile || true"],122 @app_config.build_scripts123 end124 def test_rails_and_dotenv_default_build125 config = <<~CONFIG126 env: flex127 runtime: ruby128 entrypoint: bundle exec bin/rails s129 runtime_config:130 dotenv_config: my-config131 CONFIG132 setup_test dir: "rails", config: config133 assert_equal \134 [135 "gem install rcloadenv && rbenv rehash && rcloadenv my-config >> .env",136 "bundle exec rake assets:precompile || true"137 ],138 @app_config.build_scripts139 end140 def test_ruby_version141 setup_test dir: "ruby-version"142 assert_equal "2.0.99", @app_config.ruby_version143 end144 def test_bundler_ruby_version145 setup_test dir: "gemfile-ruby"146 assert_equal "2.0.98", @app_config.ruby_version147 end148 def test_gemfile_old_name149 setup_test dir: "gemfile-old"150 assert @app_config.has_gemfile151 end152 def test_gemfile_configru153 setup_test dir: "gemfile-rack", config: DEFAULT_CONFIG_NO_ENTRYPOINT154 assert @app_config.has_gemfile155 assert_equal "exec bundle exec rackup -p $PORT", @app_config.entrypoint156 end157 def test_config_missing158 ex = assert_raises AppConfig::Error do159 setup_test config: nil160 end161 assert_match %r{Could not read app engine config file:}, ex.message162 end163 def test_needs_entrypoint164 ex = assert_raises AppConfig::Error do165 setup_test config: DEFAULT_CONFIG_NO_ENTRYPOINT166 end167 assert_match %r{Please specify an entrypoint}, ex.message168 end169 def test_illegal_env_name170 config = <<~CONFIG171 env: flex172 runtime: ruby173 entrypoint: bundle exec ruby hello.rb174 env_variables:175 VAR-1: value1176 CONFIG177 ex = assert_raises AppConfig::Error do178 setup_test config: config179 end180 assert_equal "Illegal environment variable name: \"VAR-1\"",181 ex.message182 end183 def test_illegal_build_command184 config = <<~CONFIG185 env: flex186 runtime: ruby187 entrypoint: bundle exec ruby hello.rb188 runtime_config:189 build: "multiple\\nlines"190 CONFIG191 ex = assert_raises AppConfig::Error do192 setup_test config: config193 end194 assert_equal "Illegal newline in build command: \"multiple\\nlines\"",195 ex.message196 end197 def test_dotenv_clashes_with_custom_build198 config = <<~CONFIG199 env: flex200 runtime: ruby201 entrypoint: bundle exec ruby hello.rb202 runtime_config:203 build: ["bundle exec rake hello"]204 dotenv_config: my-config205 CONFIG206 ex = assert_raises AppConfig::Error do207 setup_test config: config208 end209 assert_match(/^The `dotenv_config` setting conflicts with the `build`/,210 ex.message)211 end212 def test_illegal_sql_instances213 config = <<~CONFIG214 env: flex215 runtime: ruby216 entrypoint: bundle exec ruby hello.rb217 beta_settings:218 cloud_sql_instances: bad!instance219 CONFIG220 ex = assert_raises AppConfig::Error do221 setup_test config: config222 end223 assert_equal "Illegal cloud sql instance name: \"bad!instance\"",224 ex.message225 end226 def test_illegal_entrypoint227 config = <<~CONFIG228 env: flex229 runtime: ruby230 entrypoint: "multiple\\nlines"231 CONFIG232 ex = assert_raises AppConfig::Error do233 setup_test config: config234 end235 assert_equal "Illegal newline in entrypoint: \"multiple\\nlines\"",236 ex.message237 end238 def test_illegal_debian_packages239 config = <<~CONFIG240 env: flex241 runtime: ruby242 entrypoint: bundle exec ruby hello.rb243 runtime_config:244 packages: bad!package245 CONFIG246 ex = assert_raises AppConfig::Error do247 setup_test config: config248 end249 assert_equal "Illegal debian package name: \"bad!package\"",250 ex.message251 end252 def test_illegal_ruby_version253 ex = assert_raises AppConfig::Error do254 setup_test dir: "bad-ruby-version"255 end256 assert_equal "Illegal ruby version: \"bad!version\"",257 ex.message258 end259end...
rubyforge_tasks.rb
Source:rubyforge_tasks.rb
...49 jeweler.release_gem_to_rubyforge50 rescue NoRubyForgeProjectInGemspecError => e51 abort "Setting up RubyForge requires that you specify a 'rubyforge_project' in your Jeweler::Tasks declaration"52 rescue MissingRubyForgePackageError => e53 abort "Rubyforge reported that the #{e.message} package isn't setup. Run rake rubyforge:setup to do so."54 rescue RubyForgeProjectNotConfiguredError => e55 abort "RubyForge reported that #{e.message} wasn't configured. This means you need to run 'rubyforge setup', 'rubyforge login', and 'rubyforge configure', or maybe the project doesn't exist on RubyForge"56 end57 end58 if publish_documentation?59 desc "Publish docs to RubyForge."60 task :docs => doc_task do61 config = YAML.load(62 File.read(File.expand_path('~/.rubyforge/user-config.yml'))63 )64 host = "#{config['username']}@rubyforge.org"65 remote_dir = "/var/www/gforge-projects/#{project}/#{remote_doc_path}"66 local_dir = case self.doc_task.to_sym67 when :rdoc then 'rdoc'68 when :yardoc then 'doc'69 else70 raise "Unsure what to run to generate documentation. Please set doc_task and re-run."71 end72 sh %{rsync --archive --verbose --delete #{local_dir}/ #{host}:#{remote_dir}}73 end74 end75 end76 desc "Release gem and RDoc documentation to RubyForge"77 task :release => "rubyforge:release:gem"78 task :release => "rubyforge:release:docs" if publish_documentation?79 80 desc "Setup a rubyforge project for this gem"81 task :setup do82 $stderr.puts "DEPRECATION: Releasing gems to RubyForge is deprecated. You should see about releasing to Gemcutter instead: http://wiki.github.com/technicalpickles/jeweler/gemcutter"83 begin 84 jeweler.setup_rubyforge85 rescue NoRubyForgeProjectInGemspecError => e86 abort "Setting up RubyForge requires that you specify a 'rubyforge_project' in your Jeweler::Tasks declaration"87 rescue RubyForgeProjectNotConfiguredError => e88 abort "The RubyForge reported that #{e.message} wasn't configured. This means you need to run 'rubyforge setup', 'rubyforge login', and 'rubyforge configure', or maybe the project doesn't exist on RubyForge"89 end90 end91 end92 task :release => 'rubyforge:release'93 end94 def publish_documentation?95 ! (doc_task == false || doc_task == :none)96 end97 end98end...
setup.rb
Source:setup.rb
...8 system 'git submodule init && git submodule update'9 if $CHILD_STATUS.exitstatus != 010 abort('Failed to initialize or update git submodules. ' \11 'Please make sure git is in path and ' \12 'you have an ssh key setup for your github account')13 end14else15 # Make sure RubySetupSystem is up to date16 # This may make debugging RubySetupSystem harder so feel free to comment out17 system 'git submodule update'18end19require 'fileutils'20require_relative 'RubySetupSystem/RubyCommon.rb'21def checkRunFolder(suggested)22 random_file = File.join(suggested, 'setup.rb')23 onError('Not ran from base directory!') unless File.exist?(random_file)24 thirdPartyFolder = File.join suggested, 'ThirdParty'25 FileUtils.mkdir_p thirdPartyFolder26 FileUtils.mkdir_p File.join suggested, 'build', 'ThirdParty'27 thirdPartyFolder28end29def projectFolder(baseDir)30 File.expand_path File.join(baseDir, '../')31end32require_relative 'RubySetupSystem/RubySetupSystem.rb'33require_relative 'stack_walk_dependencies.rb'34# All the objects35installer = Installer.new(36 @libs_list37)38installer.run39onError "'StackWalk' folder is missing" unless File.exist? ProjectDir40Dir.chdir(ProjectDir) do41 FileUtils.mkdir_p 'build'42end43success 'StackWalk folder and assets are good to go'44info 'Compiling StackWalk'45# Build directory is made earlier46Dir.chdir(File.join(ProjectDir, 'build')) do47 onError 'Failed to configure main project' unless runCMakeConfigure []48 onError 'Failed to compile main project' unless TC.runCompiler49end50success 'Done compiling StackWalk'51success 'All done.'52if OS.linux?53 info "To compile again just run 'make' in ./build"54 puts 'You may need to run this setup again from time to time'55else56 info 'Open build/StackWalkAsAService.sln and start coding'57end58exit 0...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!