Best Spinach_ruby code snippet using Filesystem.current_dir
directory_spec.rb
Source:directory_spec.rb
...29 @dir_path = 'child'30 @directory = Directory.new(@dir_path)31 end32 it 'should parse the root' do33 current_dir = ''34 tree = @directory.parse_filesystem_tree(["1subsub", "1other"], current_dir)35 expect(tree.size).to eql 236 tree.each do |t|37 #puts t38 end39 end40 it 'should parse the child dir' do41 current_dir = '1child'42 tree = @directory.parse_filesystem_tree([current_dir, "#{current_dir}/2subsub", "#{current_dir}/2other"], current_dir)43 expect(tree.size).to eql 344 tree.each do |t|45 #puts t46 end47 end48 it 'should parse the child child dir' do49 current_dir = '1child/2subchild'50 tree = @directory.parse_filesystem_tree([current_dir, "#{current_dir}/3subsub", "#{current_dir}/3other"], current_dir)51 expect(tree.size).to eql 352 tree.each do |t|53 #puts t54 end55 end56 end57end...
step_definitions.rb
Source:step_definitions.rb
1require 'aruba/api'2Then(/^the file "(.*?)" should be (\d+) bytes$/) do |img, size|3 expect(File.size(File.join(current_dir, img))).to eql(size.to_i)4end5Then(/^the file "(.*?)" should be less than (\d+) bytes$/) do |img, size|6 expect(File.size(File.join(current_dir, img))).to be < size.to_i7end8Then(/^the manifest should have the right timestamp for "(.*?)"$/) do |file|9 manifest = YAML.load(File.read(manifest_path))10 file_stamp = File.mtime(File.join(current_dir, file))11 expect(manifest[file]).to eql(file_stamp)12end13Given(/^a primed manifest for "(.*?)"$/) do |file|14 manifest = { file: File.mtime(File.join(current_dir, file)) }15 File.open(path, 'w') do |manifest_file|16 manifest_file.write(YAML.dump(manifest))17 end18end19Given(/^some time has passed$/) do20 # this needs to be > 1 to get out of the single second resolution of a21 # file timestamp22 sleep(1.5)23end24Given(/^an updated file at "(.*?)"$/) do |file|25 FileUtils.touch(File.join(current_dir, file))26end27Given(/^the file "([^"]*)" has mode "([^"]*)"$/) do |file_name, file_mode|28 filesystem_permissions(file_mode, file_name)29end30Then(/^the file "([^\"]*)" should have been updated$/) do |file|31 target = File.join(current_dir, file)32 expect(File.mtime(target)).not_to eql(@modification_times[target])33end34def manifest_path35 File.join(current_dir, 'build', 'imageoptim.manifest.yml')36end...
file_system_spec.rb
Source:file_system_spec.rb
1require 'spec_helper'2describe 'FileSystem' do 3 4 before :each do 5 @current_dir = "#{Dir.pwd}/"6 end7 it 'has file path' do 8 Skytech::FileSystem.current_directory.should == @current_dir9 end10 it 'has a site path' do 11 Skytech::FileSystem.site_directory.should == @current_dir + '_site/'12 end13 it 'has a source path' do 14 Skytech::FileSystem.source_directory.should == @current_dir + '_source/'15 end16 it 'has a assets path' do 17 Skytech::FileSystem.assets_directory.should == @current_dir + '_assets/'18 end19 it 'has a js path' do 20 Skytech::FileSystem.js_directory.should == @current_dir + '_js/'21 end22 it 'has a css path' do 23 Skytech::FileSystem.css_directory.should == @current_dir + '_css/'24 end25 it 'creates a directory' do26 path = @current_dir + '_dir_test'27 Skytech::FileSystem.create_directory(path)28 File.directory?(path).should be_true29 Dir.rmdir path30 end31end...
current_dir
Using AI Code Generation
1FileUtils.copy('/path/to/source', '/path/to/destination')2FileUtils.copy_entry('/path/to/source', '/path/to/destination')3FileUtils.copy_file('/path/to/source', '/path/to/destination')4FileUtils.ln_s('/path/to/source', '/path/to/destination')5FileUtils.mv('/path/to/source', '/path/to/destination')6FileUtils.rm('/path/to/file')7FileUtils.rm_r('/path/to/directory')8FileUtils.mkdir('/path/to/directory')9FileUtils.mkdir_p('/path/to/directory')10FileUtils.chmod(
current_dir
Using AI Code Generation
1FileUtils.copy('/path/to/source', '/path/to/destination')2FileUtils.copy_entry('/path/to/source', '/path/to/destination')3FileUtils.copy_file('/path/to/source', '/path/to/destination')4FileUtils.ln_s('/path/to/source', '/path/to/destination')5FileUtils.mv('/path/to/source', '/path/to/destination')6FileUtils.rm('/path/to/file')7FileUtils.rm_r('/path/to/directory')8FileUtils.mkdir('/path/to/directory')9FileUtils.mkdir_p('/path/to/directory')10FileUtils.chmod(
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!!