How to use home method of Platform Package

Best Selenium code snippet using Platform.home

directory_controller.rb

Source:directory_controller.rb Github

copy

Full Screen

...71before_filter :login_required72verify :method => :post, :only => [ :save ],73 :redirect_to => { :action => :index, :controller => :index }74private75 def home76 os = Platform::OS77 impl = Platform::IMPL78 user = current_user79 if "#{os}" != "java"80 if "#{os}" =~ /unix/ && "#{impl}" =~ /macosx/ then81 dir_home = "/Users/#{user.login}"82 else83 dir_home = "/home/#{user.login}"84 end85 else86 require 'java'87 include_class 'java.lang.System'88 home = "#{System.getenv("HOME")}"89 user_tmp = "#{System.getenv("USER")}"90 home = home.sub(user_tmp, '')91 dir_home = home + user.login92 end93 if params[:id]94 session[:path] = Department.find(params[:id]).path95 end96 if !(session[:path])97 session[:path] = session[:user].users_departments.first.department.path98 end99 session[:path] || dir_home100 end101 def protect_dir(dir)102 if dir =~ /\.\./ then103 raise "Protect dir"104 end105 end106 def get_dir(name, rep = true)107 dir = (params[name] || '')108 dir = '/' + dir unless dir.starts_with?('/')109 if rep == true then110 dir += '/' unless dir.ends_with?('/')111 end112 dir = home() + dir113 protect_dir(dir)114 return dir115 end116 117 def can_edit(ext)118 ext = ext.downcase.tr('.','')119 if (%w[html htm phtml xml rhtml rxml rjs rb js css php py c java h txt sh sql].include?(ext))120 'edit_area'121 #elsif (%w[jpg jpeg gif png].include?(ext)) # add image editor122 # 'image'123 else124 'none'125 end126 end127public128 def list129 dir = get_dir(:path)130 return_data = Hash.new()131 if File.exist?(dir) then132 i = 0133 return_data[:Files] = Array.new134 if File.directory?(dir) then135 d = Dir.entries(dir)136 d.each{137 |filename|138 if filename[0,1] != '.' then139 begin140 return_data[:Files][i] = {141 :name => filename,142 :size => File.size(dir + filename),143 :lastChange => File.atime(dir + filename).asctime,144 :path => dir.sub(home, '') + filename,145 :edit => can_edit(File.extname(filename)),146 :cls => ((File.directory?(dir + filename)) ? 'folder' : File.extname(filename).downcase.sub(".", 'file-'))147 }148 rescue149 return_data[:Files][i] = {150 :name => 'Error with ' + filename + ' ',151 :size => 0,152 :lastChange => '',153 :path => '',154 :cls => '',155 :edit => 'none'156 }157 end158 i = i + 1159 end160 }161 end162 end163 if (return_data[:Files] != nil) then164 return_data[:FilesCount] = return_data[:Files].length165 else166 return_data[:FilesCount] = 0167 end168 render :text=>return_data.to_json, :layout=>false169 end170 def get171 dir = get_dir(:path)172 i = 0173 return_data = Array.new174 if File.directory?(dir) then175 d = Dir.entries(dir)176 d.each{177 |filename|178 if File.readable?(dir + filename) && File.executable?(dir + filename) == false && File.writable?(dir + filename) == false then179 readonly = true180 end181 if filename[0,1] != '.' then182 if File.directory?(dir + filename) then183 return_data[i] = {184 :id => dir.sub(home, '') + filename,185 :text => filename,186 :path => filename,187 :cls => "folder",188 :edit => 'none',189 :disabled => readonly,190 :leaf => false191 }192 else193 return_data[i] = {194 :id => dir.sub(home, '') + filename,195 :text => filename,196 :path => filename,197 :edit => can_edit(File.extname(filename)),198 :cls => File.extname(filename).downcase.sub(".", 'file-'),199 :disabled => false,200 :leaf => true201 }202 end203 i = i + 1204 end205 }206 end207 render :text=>return_data.to_json, :layout=>false208 end209 def rename210 newname = get_dir(:newname, false)211 oldname = get_dir(:oldname, false)212 return_data = Object.new213 if File.exist?(oldname) then214 begin215 File.rename(oldname, newname)216 return_data = {:success => true}217 rescue218 return_data = {:success => false, :error => _("Cannot rename file ") + oldname.sub(self.home, '') + _(" to ") + newname.sub(self.home, '')}219 end220 else221 return_data = {:success => false, :error => _("Cannot rename file ") + oldname.sub(self.home, '') + _(" to ") + newname.sub(self.home, '')}222 end223 render :text=>return_data.to_json, :layout=>false224 end225 def newdir226 dir = get_dir(:dir)227 return_data = Object.new228 if File.exist?(dir) == false then229 begin230 Dir.mkdir(dir)231 return_data = {:success => true}232 rescue233 ########################234 end235 else236 return_data = {:success => false, :error => _("Cannot create directory: ") + dir.sub(self.home, '')}237 end238 render :text=>return_data.to_json, :layout=>false239 end240 def delete241 file = get_dir(:file, false)242 return_data = Object.new243 if File.exist?(file) then244 begin245 if File.directory?(file) then246 Dir.delete(file)247 else248 File.delete(file)249 end250 return_data = {:success => true}251 rescue252 return_data = {:success => false, :error => _("Cannot delete: ") + file.sub(self.home, '')}253 end254 else255 return_data = {:success => false, :error => _("Cannot delete: ") + file.sub(self.home, '')}256 end257 render :text=>return_data.to_json, :layout=>false258 end259 def download260 file = get_dir(:file, false)261 if File.exist?(file) then262 begin263 if File.directory?(file) then264 folder = true265 archive = File.basename(file)266 Zip::ZipFile.open(archive + ".zip", Zip::ZipFile::CREATE){267 |zipfile|268 Find.find(file) do269 |f|270 name = File.basename(f)271 if name[0,1] != '.' && f != file then272 zipfile.add(archive + "/" + name, f)273 end274 end275 }276 file = archive + ".zip"277 end278 send_file(file)279 if folder then280 File.delete(file)281 end282 end283 end284 end285 def save286 @filename = get_dir(:filename, false)287 if (File.exist?(@filename))288 File.open(@filename, 'w') {|f| f.write(params[:file])}289 end290 end291 292 def edit293 @filename = get_dir(:file, false)294 @filetype = 'basic'295 @file = ''296 if (File.exist?(@filename))297 ext = File.extname(@filename).downcase.tr('.', '')298 puts ext299 @filetype = 'html' if (%w[html htm phtml rhtml].include?(ext))300 @filetype = 'php' if (%w[php php3 php4 php5 php6 inc].include?(ext))301 @filetype = 'ruby' if (ext == 'rb')302 @filetype = 'python' if (ext == 'py')303 @filetype = 'js' if (ext == 'js')304 @filetype = 'pas' if (ext == 'pas')305 @filetype = 'sql' if (ext == 'sql')306 @filetype = 'c' if (ext == 'c' || ext == 'h')307 @filetype = 'cpp' if (%w[cc cpp hh hpp].include?(ext))308 @filetype = 'vb' if (ext == 'vb')309 @filetype = 'xml' if (ext == 'xml')310 File.open(@filename) {|f| @file = f.read() }311 end312 render :layout => false313 end314 315 def upload316 dir = get_dir(:path)317 return_data = Hash.new318 return_data[:success] = true;319 params.each {320 |key, value|321 if key =~ /ext-gen([0-9]*)/ && value != "" then322 file = dir + (value.original_filename || key)323 if File.exist?(file) then324 return_data[:success] = false;325 return_data[:errors] = Hash.new unless return_data[:errors]326 return_data[:errors][key] = _("File ") + file.sub(self.home, '') + _(" allready exist")327 else328 begin329 File.open(file, "w") { |f| f.write(value.read) }330 rescue331 return_data[:success] = false;332 return_data[:errors] = Hash.new unless return_data[:errors]333 return_data[:errors][key] = _("File ") + file.sub(self.home, '') + _(" can't be uploaded")334 end335 end336 end337 }338 response.headers['Content-type'] = 'text/html, charset=utf-8'339 render :text=>return_data.to_json, :layout=>false340 end341end...

Full Screen

Full Screen

android.rake

Source:android.rake Github

copy

Full Screen

...19 class AndroidNDKHomeNotFound < StandardError20 def message21 <<-EOM22Couldn't find Android NDK Home.23Set ANDROID_NDK_HOME environment variable or set :ndk_home parameter24 EOM25 end26 end27 class PlatformDirNotFound < StandardError28 def message29 <<-EOM30Couldn't find Android NDK platform directories.31Set ANDROID_PLATFORM environment variable or set :platform parameter32 EOM33 end34 end35 attr_reader :params36 def initialize(params)37 @params = params38 end39 def bin_gcc(command)40 command = command.to_s41 command = case arch42 when /armeabi/ then 'arm-linux-androideabi-'43 when /arm64-v8a/ then 'aarch64-linux-android-'44 when /x86_64/ then 'x86_64-linux-android-'45 when /x86/ then 'i686-linux-android-'46 when /mips64/ then 'mips64el-linux-android-'47 when /mips/ then 'mipsel-linux-android-'48 end + command49 gcc_toolchain_path.join('bin', command).to_s50 end51 def bin(command)52 command = command.to_s53 toolchain_path.join('bin', command).to_s54 end55 def home_path56 @home_path ||= Pathname(57 params[:ndk_home] ||58 ENV['ANDROID_NDK_HOME'] ||59 DEFAULT_NDK_HOMES.find { |path|60 path.gsub! '%LOCALAPPDATA%', ENV['LOCALAPPDATA'] || '%LOCALAPPDATA%'61 path.gsub! '\\', '/'62 path.gsub! '~', Dir.home || '~'63 File.directory?(path)64 } || raise(AndroidNDKHomeNotFound)65 )66 end67 def toolchain68 @toolchain ||= params.fetch(:toolchain){ DEFAULT_TOOLCHAIN }69 end70 def toolchain_path71 @toolchain_path ||= case toolchain72 when :gcc73 gcc_toolchain_path74 when :clang75 home_path.join('toolchains', 'llvm' , 'prebuilt', host_platform)76 end77 end78 def gcc_toolchain_path79 if @gcc_toolchain_path === nil then80 prefix = case arch81 when /armeabi/ then 'arm-linux-androideabi-'82 when /arm64-v8a/ then 'aarch64-linux-android-'83 when /x86_64/ then 'x86_64-'84 when /x86/ then 'x86-'85 when /mips64/ then 'mips64el-linux-android-'86 when /mips/ then 'mipsel-linux-android-'87 end88 test = case arch89 when /armeabi/ then 'arm-linux-androideabi-*'90 when /arm64-v8a/ then 'aarch64-linux-android-*'91 when /x86_64/ then 'x86_64-*'92 when /x86/ then 'x86-*'93 when /mips64/ then 'mips64el-linux-android-*'94 when /mips/ then 'mipsel-linux-android-*'95 end96 gcc_toolchain_version = Dir[home_path.join('toolchains', test)].map{|t| t.match(/-(\d+\.\d+)$/); $1.to_f }.max97 @gcc_toolchain_path = home_path.join('toolchains', prefix + gcc_toolchain_version.to_s, 'prebuilt', host_platform)98 end99 @gcc_toolchain_path100 end101 def host_platform102 @host_platform ||= case RUBY_PLATFORM103 when /cygwin|mswin|mingw|bccwin|wince|emx/i104 path = home_path.join('toolchains', 'llvm' , 'prebuilt', 'windows*')105 Dir.glob(path.to_s){ |item|106 next if File.file?(item)107 path = Pathname(item)108 break109 }110 path.basename111 when /x86_64-darwin/i112 'darwin-x86_64'113 when /darwin/i114 'darwin-x86'115 when /x86_64-linux/i116 'linux-x86_64'117 when /linux/i118 'linux-x86'119 else120 raise NotImplementedError, "Unknown host platform (#{RUBY_PLATFORM})"121 end122 end123 def arch124 @arch ||= (params[:arch] || ENV['ANDROID_ARCH'] || DEFAULT_ARCH).to_s125 end126 def sysroot127 @sysroot ||= home_path.join('platforms', platform,128 case arch129 when /armeabi/ then 'arch-arm'130 when /arm64-v8a/ then 'arch-arm64'131 when /x86_64/ then 'arch-x86_64'132 when /x86/ then 'arch-x86'133 when /mips64/ then 'arch-mips64'134 when /mips/ then 'arch-mips'135 end136 ).to_s137 end138 def platform139 if @platform === nil then140 @platform = params[:platform] || ENV['ANDROID_PLATFORM'] || nil141 if @platform === nil142 Dir.glob(home_path.join('platforms/android-*').to_s){ |item|143 next if File.file?(item)144 if @platform === nil145 @platform = Integer(item.rpartition('-')[2])146 else147 platform = Integer(item.rpartition('-')[2])148 @platform = platform > @platform ? platform : @platform149 end150 }151 if @platform === nil152 raise(PlatformDirNotFound)153 else154 @platform = "android-#{@platform}"155 end156 end...

Full Screen

Full Screen

expand_path_spec.rb

Source:expand_path_spec.rb Github

copy

Full Screen

...46 File.expand_path("../a", "#{@tmpdir}/xxx").should == "#{@tmpdir}/a"47 File.expand_path(".", "#{@rootdir}").should == "#{@rootdir}"48 end49 # FIXME: do not use conditionals like this around #it blocks50 unless not home = ENV['HOME']51 platform_is_not :windows do52 it "converts a pathname to an absolute pathname, using ~ (home) as base" do53 File.expand_path('~').should == home54 File.expand_path('~', '/tmp/gumby/ddd').should == home55 File.expand_path('~/a', '/tmp/gumby/ddd').should == File.join(home, 'a')56 end57 it "does not return a frozen string" do58 File.expand_path('~').frozen?.should == false59 File.expand_path('~', '/tmp/gumby/ddd').frozen?.should == false60 File.expand_path('~/a', '/tmp/gumby/ddd').frozen?.should == false61 end62 end63 platform_is :windows do64 it "converts a pathname to an absolute pathname, using ~ (home) as base" do65 File.expand_path('~').should == home.tr("\\", '/')66 File.expand_path('~', '/tmp/gumby/ddd').should == home.tr("\\", '/')67 File.expand_path('~/a', '/tmp/gumby/ddd').should == File.join(home.tr("\\", '/'), 'a')68 end69 it "does not return a frozen string" do70 File.expand_path('~').frozen?.should == false71 File.expand_path('~', '/tmp/gumby/ddd').frozen?.should == false72 File.expand_path('~/a', '/tmp/gumby/ddd').frozen?.should == false73 end74 end75 end76 platform_is_not :windows do77 before do78 @home = ENV['HOME'].chomp('/')79 end80 # FIXME: these are insane!81 it "expand path with" do82 File.expand_path("../../bin", "/tmp/x").should == "/bin"83 File.expand_path("../../bin", "/tmp").should == "/bin"84 File.expand_path("../../bin", "/").should == "/bin"85 File.expand_path("../bin", "tmp/x").should == File.join(@base, 'tmp', 'bin')86 File.expand_path("../bin", "x/../tmp").should == File.join(@base, 'bin')87 end88 it "expand_path for commoms unix path give a full path" do89 File.expand_path('/tmp/').should =='/tmp'90 File.expand_path('/tmp/../../../tmp').should == '/tmp'91 File.expand_path('').should == Dir.pwd92 File.expand_path('./////').should == Dir.pwd93 File.expand_path('.').should == Dir.pwd94 File.expand_path(Dir.pwd).should == Dir.pwd95 File.expand_path('~/').should == @home96 File.expand_path('~/..badfilename').should == "#{@home}/..badfilename"97 File.expand_path('..').should == Dir.pwd.split('/')[0...-1].join("/")98 File.expand_path('~/a','~/b').should == "#{@home}/a"99 end100 it "does not replace multiple '/' at the beginning of the path" do101 File.expand_path('////some/path').should == "////some/path"102 end103 it "replaces multiple '/' with a single '/'" do104 File.expand_path('/some////path').should == "/some/path"105 end106 it "raises an ArgumentError if the path is not valid" do107 lambda { File.expand_path("~a_not_existing_user") }.should raise_error(ArgumentError)108 end109 it "expands ~ENV['USER'] to the user's home directory" do110 File.expand_path("~#{ENV['USER']}").should == @home111 File.expand_path("~#{ENV['USER']}/a").should == "#{@home}/a"112 end113 it "does not expand ~ENV['USER'] when it's not at the start" do114 File.expand_path("/~#{ENV['USER']}/a").should == "/~#{ENV['USER']}/a"115 end116 it "expands ../foo with ~/dir as base dir to /path/to/user/home/foo" do117 File.expand_path('../foo', '~/dir').should == "#{@home}/foo"118 end119 end120 it "accepts objects that have a #to_path method" do121 File.expand_path(mock_to_path("a"), mock_to_path("#{@tmpdir}"))122 end123 it "raises a TypeError if not passed a String type" do124 lambda { File.expand_path(1) }.should raise_error(TypeError)125 lambda { File.expand_path(nil) }.should raise_error(TypeError)126 lambda { File.expand_path(true) }.should raise_error(TypeError)127 end128 platform_is_not :windows do129 it "expands /./dir to /dir" do130 File.expand_path("/./dir").should == "/dir"131 end132 end133 platform_is :windows do134 it "expands C:/./dir to C:/dir" do135 File.expand_path("C:/./dir").should == "C:/dir"136 end137 end138 with_feature :encoding do139 it "returns a String in the same encoding as the argument" do140 Encoding.default_external = Encoding::SHIFT_JIS141 path = "./a".force_encoding Encoding::CP1251142 File.expand_path(path).encoding.should equal(Encoding::CP1251)143 weird_path = [222, 173, 190, 175].pack('C*')144 File.expand_path(weird_path).encoding.should equal(Encoding::ASCII_8BIT)145 end146 platform_is_not :windows do147 it "expands a path when the default external encoding is ASCII-8BIT" do148 Encoding.default_external = Encoding::ASCII_8BIT149 path_8bit = [222, 173, 190, 175].pack('C*')150 File.expand_path( path_8bit, @rootdir).should == "#{@rootdir}" + path_8bit151 end152 end153 it "expands a path with multi-byte characters" do154 File.expand_path("Ångström").should == "#{@base}/Ångström"155 end156 platform_is_not :windows do157 it "raises an Encoding::CompatibilityError if the external encoding is not compatible" do158 Encoding.default_external = Encoding::UTF_16BE159 lambda { File.expand_path("./a") }.should raise_error(Encoding::CompatibilityError)160 end161 end162 end163 it "does not modify the string argument" do164 str = "./a/b/../c"165 File.expand_path(str, @base).should == "#{@base}/a/c"166 str.should == "./a/b/../c"167 end168 it "does not modify a HOME string argument" do169 str = "~/a"170 File.expand_path(str).should == "#{home_directory}/a"171 str.should == "~/a"172 end173 it "returns a String when passed a String subclass" do174 str = FileSpecs::SubString.new "./a/b/../c"175 path = File.expand_path(str, @base)176 path.should == "#{@base}/a/c"177 path.should be_an_instance_of(String)178 end179end180platform_is_not :windows do181 describe "File.expand_path when HOME is not set" do182 before :each do183 @home = ENV["HOME"]184 end185 after :each do186 ENV["HOME"] = @home187 end188 ruby_version_is ''...'2.4' do189 it "raises an ArgumentError when passed '~' if HOME is nil" do190 ENV.delete "HOME"191 lambda { File.expand_path("~") }.should raise_error(ArgumentError)192 end193 it "raises an ArgumentError when passed '~/' if HOME is nil" do194 ENV.delete "HOME"195 lambda { File.expand_path("~/") }.should raise_error(ArgumentError)196 end197 end198 it "raises an ArgumentError when passed '~' if HOME == ''" do199 ENV["HOME"] = ""200 lambda { File.expand_path("~") }.should raise_error(ArgumentError)...

Full Screen

Full Screen

Vagrantfile

Source:Vagrantfile Github

copy

Full Screen

...23 echoed=true24 puts("Memory", mem)25 puts("CPUs", cpus)26 end27 #v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/home_vagrant_lbry-android", "1"]28 #v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]29 v.customize ["modifyvm", :id, "--memory", mem]30 v.customize ["modifyvm", :id, "--cpus", cpus]31 end32 config.vm.synced_folder "./", "/home/vagrant/lbry-android"33 config.vm.provision "shell", inline: <<-SHELL34 dpkg --add-architecture i38635 apt-get update36 apt-get install -y libssl-dev37 apt-get install -y python3.6 python3.6-dev python3-pip autoconf libffi-dev pkg-config libtool build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386 python-pip38 pip install -f --upgrade setuptools pyopenssl39 git clone https://github.com/lbryio/buildozer.git40 cd buildozer41 python2.7 setup.py install42 cd ../43 rm -rf ./buildozer44 # Install additonal buildozer dependencies45 sudo apt-get install cython46 # Install node47 curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -48 sudo apt-get install -y nodejs49 export HOME=/home/vagrant50 cp $HOME/lbry-android/buildozer.spec.vagrant $HOME/lbry-android/buildozer.spec51 mkdir -p cd $HOME/.buildozer/android/platform/52 wget -q 'https://us.crystax.net/download/crystax-ndk-10.3.2-linux-x86_64.tar.xz' -P $HOME/.buildozer/android/53 wget -q 'https://dl.google.com/android/android-sdk_r23-linux.tgz' -P $HOME/.buildozer/android/platform/54 wget -q 'https://dl.google.com/android/repository/platform-27_r01.zip' -P $HOME/.buildozer/android/platform/55 wget -q 'https://dl.google.com/android/repository/build-tools_r26.0.1-linux.zip' -P $HOME/.buildozer/android/platform/56 tar -xf ~/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz -C $HOME/.buildozer/android/57 rm $HOME/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz58 ln -s $HOME/.buildozer/android/crystax-ndk-10.3.2/platforms/android-21 $HOME/.buildozer/android/crystax-ndk-10.3.2/platforms/android-959 cp -f $HOME/lbry-android/scripts/build-target-python.sh $HOME/.buildozer/android/crystax-ndk-10.3.2/build/tools/build-target-python.sh60 rm -rf $HOME/.buildozer/android/crystax-ndk-10.3.2/platforms/android-961 tar -xf $HOME/.buildozer/android/platform/android-sdk_r23-linux.tgz -C $HOME/.buildozer/android/platform/62 rm $HOME/.buildozer/android/platform/android-sdk_r23-linux.tgz63 mv $HOME/.buildozer/android/platform/android-sdk-linux $HOME/.buildozer/android/platform/android-sdk-23...

Full Screen

Full Screen

platform_admin_can_approve_or_decline_new_homes_spec.rb

Source:platform_admin_can_approve_or_decline_new_homes_spec.rb Github

copy

Full Screen

1require 'rails_helper'2require 'features_helper'3RSpec.feature "platform admin can approve or decline new homes" do4 include FeaturesHelper5 scenario "platform admin can approve a new home" do6 user = User.create(first_name: "Tim", last_name: "Allan", email: "email@gmail.com", password: "password")7 city = City.create(name: "Los Angeles", state: "CA")8 platform_admin = create(:user, email: "pa@admin.co", password: "password")9 platform_admin.roles << Role.create(name: "platform_admin")10 user_login(user)11 expect(current_path).to eq dashboard_path12 click_on "Be a host today!"13 expect(current_path).to eq new_home_path14 fill_in "Title", with: "Tiny LA Home"15 fill_in "Description", with: "My house is beautiful."16 fill_in "Image Link", with: "https://s-media-cache-ak0.pinimg.com/736x/1e/c5/eb/1ec5eb28f7580c245d571fcb8be7560e.jpg"17 fill_in "Address", with: "123 Lane Street"18 fill_in "Zip Code", with: "80203"19 fill_in "Daily Rate", with: "16"20 select('Los Angeles, CA')21 click_button "Submit"22 expect(current_path).to eq dashboard_path23 expect("Tiny LA Home").to eq Home.all.last.title24 expect("My house is beautiful.").to eq Home.all.last.description25 expect("https://s-media-cache-ak0.pinimg.com/736x/1e/c5/eb/1ec5eb28f7580c245d571fcb8be7560e.jpg").to eq Home.all.last.image_url26 expect("123 Lane Street").to eq Home.all.last.address27 expect("80203").to eq Home.all.last.zip_code28 expect(16.to_d).to eq Home.all.last.daily_rate29 expect("Los Angeles").to eq Home.all.last.city.name30 expect(page).to have_content "Your request has been submitted for approval."31 click_link "Logout"32 expect(current_path).to eq root_path33 platform_admin_login(platform_admin)34 expect(current_path).to eq dashboard_path35 click_link "Pending Homes"36 click_button "Accept "37 expect(current_path).to eq city_home_path(Home.all.last.city.slug, Home.all.last.id)38 expect(page).to have_content "Success! Your home updated."39 expect(page).to have_content "Tiny LA Home"40 visit '/dashboard'41 click_link "Pending Homes"42 expect(page).to_not have_content "Tiny LA Home"43 end44 scenario "platform admin can decline a new home" do45 user = User.create(first_name: "Tim", last_name: "Allan", email: "email@gmail.com", password: "password")46 city = City.create(name: "Los Angeles", state: "CA")47 platform_admin = create(:user, email: "pa@admin.co", password: "password")48 platform_admin.roles << Role.create(name: "platform_admin")49 user_login(user)50 expect(current_path).to eq dashboard_path51 click_on "Be a host today!"52 expect(current_path).to eq new_home_path53 fill_in "Title", with: "Tiny LA Home"54 fill_in "Description", with: "My house is ugly."55 fill_in "Image Link", with: "https://s-media-cache-ak0.pinimg.com/736x/1e/c5/eb/1ec5eb28f7580c245d571fcb8be7560e.jpg"56 fill_in "Address", with: "123 Lane Street"57 fill_in "Zip Code", with: "80203"58 fill_in "Daily Rate", with: "16"59 select('Los Angeles, CA')60 click_button "Submit"61 expect(current_path).to eq dashboard_path62 expect("Tiny LA Home").to eq Home.all.last.title63 expect("My house is ugly.").to eq Home.all.last.description64 expect("https://s-media-cache-ak0.pinimg.com/736x/1e/c5/eb/1ec5eb28f7580c245d571fcb8be7560e.jpg").to eq Home.all.last.image_url65 expect("123 Lane Street").to eq Home.all.last.address66 expect("80203").to eq Home.all.last.zip_code67 expect(16.to_d).to eq Home.all.last.daily_rate68 expect("Los Angeles").to eq Home.all.last.city.name69 expect(page).to have_content "Your request has been submitted for approval."70 click_link "Logout"71 expect(current_path).to eq root_path72 platform_admin_login(platform_admin)73 expect(current_path).to eq dashboard_path74 click_link "Pending Homes"75 click_button "Decline"76 expect(current_path).to eq city_home_path(Home.all.last.city.slug, Home.all.last.id)77 expect(page).to have_content "The page you were looking for doesn't exist"78 visit '/dashboard'79 click_link "Pending Homes"80 expect(page).to_not have_content "Tiny LA Home"81 end82end...

Full Screen

Full Screen

openjdk.rb

Source:openjdk.rb Github

copy

Full Screen

...16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.17# See the License for the specific language governing permissions and18# limitations under the License.19jdk_version = node['java']['jdk_version'].to_i20java_home = node['java']['java_home']21java_home_parent = ::File.dirname java_home22jdk_home = ""23pkgs = value_for_platform(24 ["centos","redhat","fedora","scientific","amazon","oracle"] => {25 "default" => ["java-1.#{jdk_version}.0-openjdk","java-1.#{jdk_version}.0-openjdk-devel"]26 },27 ["debian","ubuntu"] => {28 "default" => ["openjdk-#{jdk_version}-jdk","default-jre-headless"]29 },30 ["arch","freebsd"] => {31 "default" => ["openjdk#{jdk_version}"]32 },33 "default" => ["openjdk-#{jdk_version}-jdk"]34 )35# done by special request for rberger36ruby_block "set-env-java-home" do37 block do38 ENV["JAVA_HOME"] = java_home39 end40 not_if { ENV["JAVA_HOME"] == java_home }41end42file "/etc/profile.d/jdk.sh" do43 content <<-EOS44 export JAVA_HOME=#{node['java']['java_home']}45 EOS46 mode 075547end48if platform?("ubuntu","debian","redhat","centos","fedora","scientific","amazon","oracle")49 ruby_block "update-java-alternatives" do50 block do51 arch = node['kernel']['machine'] =~ /x86_64/ ? "x86_64" : "i386"52 arch = 'amd64' if arch == 'x86_64' && platform?("ubuntu") && node["platform_version"].to_f >= 12.0453 if platform?("ubuntu", "debian") and jdk_version == 654 java_name = if node["platform_version"].to_f >= 11.1055 "java-1.6.0-openjdk"56 else57 "java-6-openjdk"58 end59 java_name += "-i386" if arch == "i386" && node['platform_version'].to_f >= 12.0460 Chef::ShellOut.new("update-java-alternatives","-s", java_name, :returns => [0,2]).run_command61 else62 # have to do this on ubuntu for version 7 because Ubuntu does63 # not currently set jdk 7 as the default jvm on installation64 require "fileutils"65 Chef::Log.debug("glob is #{java_home_parent}/java*#{jdk_version}*openjdk*#{arch}")66 jdk_home = Dir.glob("#{java_home_parent}/java*#{jdk_version}*openjdk*#{arch}").first67 Chef::Log.debug("jdk_home is #{jdk_home}")68 if jdk_home69 FileUtils.rm_f java_home if ::File.exists? java_home70 FileUtils.ln_sf jdk_home, java_home71 end72 cmd = Chef::ShellOut.new(73 %Q[ update-alternatives --install /usr/bin/java java #{java_home}/bin/java 1;74 update-alternatives --set java #{java_home}/bin/java ]75 ).run_command76 unless cmd.exitstatus == 0 or cmd.exitstatus == 277 Chef::Application.fatal!("Failed to update-alternatives for openjdk!")78 end79 end80 end81 action :nothing82 end83end84pkgs.each do |pkg|85 package pkg do86 action :install87 notifies :create, "ruby_block[update-java-alternatives]", :immediately if platform?("ubuntu","debian","redhat","centos","fedora","scientific","amazon","oracle")88 end...

Full Screen

Full Screen

android_environment.rb

Source:android_environment.rb Github

copy

Full Screen

1require_relative 'module'2require 'fastlane_core/command_executor'3module Screengrab4 class AndroidEnvironment5 attr_reader :android_home6 attr_reader :build_tools_version7 # android_home - the String path to the install location of the Android SDK8 # build_tools_version - the String version of the Android build tools that should be used9 def initialize(android_home, build_tools_version)10 @android_home = android_home11 @build_tools_version = build_tools_version12 end13 def platform_tools_path14 @platform_tools_path ||= find_platform_tools(android_home)15 end16 def build_tools_path17 @build_tools_path ||= find_build_tools(android_home, build_tools_version)18 end19 def adb_path20 @adb_path ||= find_adb(platform_tools_path)21 end22 def aapt_path23 @aapt_path ||= find_aapt(build_tools_path)24 end25 private26 def find_platform_tools(android_home)27 return nil unless android_home28 platform_tools_path = File.join(android_home, 'platform-tools')29 File.directory?(platform_tools_path) ? platform_tools_path : nil30 end31 def find_build_tools(android_home, build_tools_version)32 return nil unless android_home33 build_tools_dir = File.join(android_home, 'build-tools')34 return nil unless build_tools_dir && File.directory?(build_tools_dir)35 return File.join(build_tools_dir, build_tools_version) if build_tools_version36 version = select_build_tools_version(build_tools_dir)37 return version ? File.join(build_tools_dir, version) : nil38 end39 def select_build_tools_version(build_tools_dir)40 # Collect the sub-directories of the build_tools_dir, rejecting any that start with '.' to remove . and ..41 dir_names = Dir.entries(build_tools_dir).select { |e| !e.start_with?('.') && File.directory?(File.join(build_tools_dir, e)) }42 # Collect a sorted array of Version objects from the directory names, handling the possibility that some43 # entries may not be valid version names44 versions = dir_names.map do |d|45 begin46 Gem::Version.new(d)47 rescue...

Full Screen

Full Screen

default_spec.rb

Source:default_spec.rb Github

copy

Full Screen

...17 describe "for #{platform} platform" do18 let(:ohai_data) do19 { :platform => platform, :platform_version => '666' }20 end21 it "sets default home root" do22 @node[attr_ns]['home_root'].must_equal "/home"23 end24 it "sets default shell" do25 @node[attr_ns]['default_shell'].must_equal "/bin/bash"26 end27 end28 end29 %w{openbsd}.each do |platform|30 describe "for #{platform} platform" do31 let(:ohai_data) do32 { :platform => platform, :platform_version => '666' }33 end34 it "sets default home root" do35 @node[attr_ns]['home_root'].must_equal "/home"36 end37 it "sets default shell" do38 @node[attr_ns]['default_shell'].must_equal "/bin/ksh"39 end40 end41 end42 %w{mac_os_x mac_os_x_server}.each do |platform|43 describe "for #{platform} platform" do44 let(:ohai_data) do45 { :platform => platform, :platform_version => '666' }46 end47 it "sets default home root" do48 @node[attr_ns]['home_root'].must_equal "/Users"49 end50 it "sets default shell" do51 @node[attr_ns]['default_shell'].must_equal "/bin/bash"52 end53 end54 end55 %w{bogus_os}.each do |platform|56 describe "for #{platform} platform" do57 let(:ohai_data) do58 { :platform => platform, :platform_version => '666' }59 end60 it "sets default home root" do61 @node[attr_ns]['home_root'].must_equal "/home"62 end63 it "sets a nil default shell" do64 @node[attr_ns]['default_shell'].must_be_nil65 end66 end67 end68 describe "for all platforms" do69 it "sets default manage home" do70 @node[attr_ns]['manage_home'].must_equal "true"71 end72 it "sets default non unique" do73 @node[attr_ns]['non_unique'].must_equal "false"74 end75 it "sets default create user group" do76 @node[attr_ns]['create_user_group'].must_equal "true"77 end78 it "sets default ssh keygen" do79 @node[attr_ns]['ssh_keygen'].must_equal "true"80 end81 it "sets default data bag name" do82 @node[attr_ns]['data_bag_name'].must_equal "users"83 end84 end...

Full Screen

Full Screen

home

Using AI Code Generation

copy

Full Screen

1require File.dirname(__FILE__) + '/platform'2require File.dirname(__FILE__) + '/platform.rb'3require File.dirname(__FILE__) + '/platform'4require File.dirname(__FILE__) + '/platform.rb'5require File.dirname(__FILE__) + '/platform'6require File.dirname(__FILE__) + '/platform.rb'7require File.dirname(__FILE__) + '/platform'8require File.dirname(__FILE__) + '/platform.rb'9require File.dirname(__FILE__) + '/platform'10require File.dirname(__FILE__) + '/platform.rb'11require File.dirname(__FILE__) + '/platform'12require File.dirname(__FILE__) + '/platform.rb'13require File.dirname(__FILE__) + '/platform'14require File.dirname(__FILE__) + '/platform.rb'15require File.dirname(__FILE__) + '/platform'16require File.dirname(__FILE__) +

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful