Sha256: 161cfaa9eb9f3dfbef1ce3e677cc804e3dfc3af54552dd71a8e0a62ebd6e1ee1
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
require 'rspec' When /^I run the configure-s3-website command with parameters$/ do |table| options, optparse = ConfigureS3Website::CLI.optparse_and_options optparse.parse! args_array_from_cucumber_table(table) @reset = create_reset_config_file_function options[:config_source].description @console_output = capture_stdout { ConfigureS3Website::Runner.run(options, stub_stdin) } end Given /^I answer 'yes' to 'do you want to use CloudFront'$/ do @first_stdin_answer = 'y' end Then /^the output should be$/ do |expected_console_output| @console_output.should eq(expected_console_output) end Then /^the output should include$/ do |expected_console_output| @console_output.should include(expected_console_output) end def args_array_from_cucumber_table(table) args = [] table.hashes.map do |entry| { entry[:option] => entry[:value] } end.each do |opt| args << opt.keys.first args << opt.values.first if opt.values.first end args end def stub_stdin stdin = stub('std_in') stdin.stub(:gets).and_return { first_stdin_answer } stdin end # A function for bringing back the original config file # (in case we modified it during the test) def create_reset_config_file_function(yaml_file_path) original_contents = File.open(yaml_file_path, 'r').read -> { File.open(yaml_file_path, 'w') { |yaml_file| yaml_file.puts(original_contents) } } end # The first prompt asks "do you want to create a CloudFront distro" def first_stdin_answer @first_stdin_answer || 'n' end module Kernel require 'stringio' def capture_stdout out = StringIO.new $stdout = out yield out.string ensure $stdout = STDOUT end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
configure-s3-website-1.3.0 | features/step_definitions/steps.rb |