features/step_definitions/pinpress_steps.rb in pinpress-1.2.2 vs features/step_definitions/pinpress_steps.rb in pinpress-1.2.3

- old
+ new

@@ -1,12 +1,37 @@ +def create_config_file(version) + config = YAML.load_file(File.join(LIB_DIR, '..', 'support/sample_config.yaml')) + config['pinpress'].merge!('version' => version) + File.open('/tmp/pp/.pinpress', 'w') { |f| f.write(config.to_yaml) } +end + +Given(/^no file located at "(.*?)"$/) do |filepath| + step %(the file "#{ filepath }" should not exist) +end + +Given(/^an existing current configuration file located at "(.*?)"$/) do |filepath| + create_config_file(PinPress::VERSION) +end + +Given(/^an existing old configuration file located at "(.*?)"$/) do |filepath| + create_config_file('0.0.1') +end + When /^I get help for "([^"]*)"$/ do |app_name| @app_name = app_name step %(I run `#{app_name} help`) end -Given(/^no file located at "(.*?)"$/) do |filepath| - step %(the file "#{ filepath }" should not exist) +Then(/^the following files should not be empty:$/) do |table| + table.cell_matrix.flatten.each do |file| + expect(File.file?(file.value)).to eq(true) + expect(File.read(file.value)).not_to be_empty + end end -Given(/^a file located at "(.*?)" with the contents:$/) do |filepath, contents| - File.open(filepath, 'w') { |f| f.write(contents) } -end \ No newline at end of file +Then(/^a valid configuration file should exist at "(.*?)"$/) do |filepath| + expect(File.file?(filepath)).to eq(true) + stub_data = YAML.load_file(File.join(LIB_DIR, '..', 'support/sample_config.yaml')) + config_data = YAML.load_file(filepath) + config_data['pinpress'].delete('version') + expect(config_data).to eq(stub_data) +end