=begin = new_backup_spec.rb *Copyright*:: (C) 2013 by Novu, LLC *Author(s)*:: Tamara Temple *Since*:: 2013-05-01 *License*:: GPLv3 *Version*:: 0.0.1 == Description Test base library module. =end require 'spec_helper' require 'new_backup/main' def check_keys(h,klist) (h.keys <=> klist) == 0 end module NewBackup describe Main do describe "processing options and initializing" do let(:dogger) {double('dogger')} it "no options specified" do expect {NewBackup::Main.new()}.to raise_error(RuntimeError) end describe "full options" do let(:options) {{ 'fog_timeout' => 3600, 'dump_directory' => '/tmp', 'dump_ttl' => 20, 'aws_region' => 'us-west-1', 'db_instance_type' => 'db.t1.micro', 'timestamp_format' => "%FT%T-%Z", 'rds_instance_id' => 'myrds', 'db_subnet_group_name' => 'yolo', 'backup_bucket' => 'raw_backups', 's3_bucket' => 'clean_backups', 's3_prefix' => 'felix', 'aws_s3_region' => 'outermars', 'mysql_username' => 'despereaux', 'mysql_database' => 'gollywogs', 'mysql_password' => 'nutz', 'obfuscate_script' => 'nolocontendre', 'datadog_apikey' => 'youdthink', 'aws_access_key_id' => 'bogus aws key', 'aws_secret_access_key' => 'bogus aws secret' }} let(:main) { NewBackup::Main.new(options) } let(:actual_options) { main.options } it {main.should be_a(NewBackup::Main)} it {check_keys(actual_options, %w{fog aws rds s3 mysql datadog dump_directory timestamp debug nords nos3}.map(&:to_sym)).should be_true} it {check_keys(actual_options[:fog], %w{timeout}.map(&:to_sym)).should be_true} it {check_keys(actual_options[:aws], %w{access_key secret_key region}.map(&:to_sym)).should be_true} it {check_keys(actual_options[:rds], %w{instance_id subnet_group instance_type}.map(&:to_sym)).should be_true} it {check_keys(actual_options[:s3], %w{raw_bucket clean_bucket prefix region dump_ttl}.map(&:to_sym)).should be_true} it {check_keys(actual_options[:mysql], %w{username password database obfuscate_script}.map(&:to_sym)).should be_true} it {check_keys(actual_options[:datadog], %w{api_key}.map(&:to_sym)).should be_true} it { main.should respond_to(:run) } end end end end