Sha256: bd4ea2130e4a26f09868db458768908890d7f11bb2e26db64eac9cf81bc13557

Contents?: true

Size: 1.8 KB

Versions: 2

Compression:

Stored size: 1.8 KB

Contents

require "spec_helper"
require "daily_weekly_monthly/cli"

describe DailyWeeklyMonthly::Cli do
  describe "#call" do
    subject { described_class.new ARGV }

    context "when no command is given" do
      before do
        ARGV.replace []
      end

      it "raises an error" do
        expect { subject.call }.to raise_error RuntimeError, "Please supply a command to run"
      end
    end

    context "with arguments and a command" do
      before do
        ARGV.replace [
          "-M", "5",
          "-W", "3",
          "-D", "2",
          "-m", "1",
          "-e", "foo",
          "-w", "2",
          "-d", "bar",
          "-n", "me@example.com",
          "-s", "smpt.example.com",
          "-p", "25",
          "some", "command"
        ]
      end

      it "passes the parsed arguments and command to DbBackup.start" do
        expect(DailyWeeklyMonthly).to receive(:start).with("some command", months_to_keep: 5,
                                                                           weeks_to_keep: 3,
                                                                           days_to_keep: 2,
                                                                           day_of_month: 1,
                                                                           output_extension: "foo",
                                                                           day_of_week: 2,
                                                                           backups_dir: "bar",
                                                                           smtp_server: "smpt.example.com",
                                                                           smtp_port: 25,
                                                                           notify: "me@example.com")
        subject.call
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
daily_weekly_monthly-0.0.4 spec/daily_weekly_monthly/cli_spec.rb
daily_weekly_monthly-0.0.3 spec/daily_weekly_monthly/cli_spec.rb