#encoding: utf-8 Before do cleanup_working_directory end Before('@cmd_output') do @cmd_output = true end Before('@cmd_debug') do @cmd_debug = true end Given /^the directory '([^']+)' does not exist$/ do |path| result = path_exists?(path) expect(result).to eq(false) end Given /^the directory '([^']+)' exists$/ do |path| create_directory(path) end When /^I successfully run `([^`]+)`$/ do |command| @result = run_this_command command if @cmd_output == true puts "_stdout_:\n" + @result.stdout unless @result.stdout.blank? puts "_stderr_:\n" + @result.stderr unless @result.stderr.blank? end expect(@result.status.success?).to eq(true) end Then /^a directory named '([^']+)' should exist$/ do |path| result = path_exists?(path) expect(result).to eq(true) end When /^I run `([^`]+)`$/ do |command| @result = run_this_command command if @cmd_output == true puts "_stdout_:\n" + @result.stdout unless @result.stdout.blank? puts "_stderr_:\n" + @result.stderr unless @result.stderr.blank? end end Then /^an error occured:$/ do |string| @result = BobTheHelper::Command::CommandResult.new if @result.blank? expect(@result.stderr.chomp[string]).to_not eq(nil) end Given /^pointrb has never been used on this host$/ do result = path_does_not_exist? pointrb_config_directories expect(result).to eq(true) end Given /^pointrb has already been used on this host$/ do create_directory pointrb_config_directories end Then /^a directory named '([^']+)' exists with:$/ do |base_dir,table| directory_entries = table.rows.flatten result = path_exists? directory_entries.map { |e| File.join(base_dir, e) } expect(result).to eq(true) end Given /^a layout file named "([^"]+)" exists with:$/ do |layout_name, layout_definition| layout_directory = File.join(ENV['HOME'],'.config', 'pointrb', 'layouts') create_directory layout_directory layout_file = File.join(layout_directory, layout_name) create_file layout_file, layout_definition end Then /^an information occured:$/ do |output| @result = BobTheHelper::Command::CommandResult.new if @result.blank? expect(@result.stdout.chomp).to eq(output) end Then /^the run is successful$/ do @result = BobTheHelper::Command::CommandResult.new if @result.blank? expect(@result.status.success?).to eq(true) end Then /^a file named '([^']+)' exists with:$/ do |path,content| exists = path_exists?(path) expect(exists).to eq(true) file_content = read_file path expect(file_content).to eq(content) end