Sha256: 4cbfcf1716c217ea1b73116031a5a8db0350db107b4ea85a270f05232c1d8129

Contents?: true

Size: 1.77 KB

Versions: 33

Compression:

Stored size: 1.77 KB

Contents

# -*- Encoding: utf-8 -*-
#
# Copyright 2013 whiteleaf. All rights reserved.
#

require_relative "../lib/commandline"
require_relative "../lib/logger"

describe "exit code" do
  before do
    $stdout.silent = true
    $stderr.silent = true
  end

  describe "download command" do
    describe "return mistook count" do
      context "when novel is nothing" do
        it { expect(CommandLine.run!(%w(download foo))).to eq 1 }
        it { expect(CommandLine.run!(%w(download foo bar))).to eq 2 }
        it { expect(CommandLine.run!(%w(download foo bar baz))).to eq 3 }
      end

      context "when novel is alrady existed" do
        before do
          # 事前に最低3つは凍結している小説を用意しておく
          @ids = `narou l -f nonfrozen`.split
        end

        it "got 3" do
          expect(CommandLine.run!(["download"] + @ids[0,3])).to eq 3
        end
      end

      context "when novel is alrady frozen" do
        before do
          # 事前に最低2つは凍結している小説を用意しておく
          @ids = `narou l -f frozen`.split
        end

        it "got 2" do
          expect(CommandLine.run!(["download"] + @ids[0,2])).to eq 2
        end
      end
    end
  end

  describe "update command" do
    describe "return mistook count" do
      context "when novel is nothing" do
        it { expect(CommandLine.run!(%w(update foo))).to eq 1 }
        it { expect(CommandLine.run!(%w(update foo bar))).to eq 2 }
        it { expect(CommandLine.run!(%w(update foo bar baz))).to eq 3 }
      end

      context "when novel is alrady frozen" do
        before do
          @ids = `narou l -f frozen`.split
        end

        it "got 2" do
          expect(CommandLine.run!(["update"] + @ids[0,2])).to eq 2
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
narou-2.9.5 spec/exit_code_spec.rb
narou-2.9.4 spec/exit_code_spec.rb
narou-2.9.3.1 spec/exit_code_spec.rb
narou-2.9.3 spec/exit_code_spec.rb
narou-2.9.2 spec/exit_code_spec.rb
narou-2.9.1 spec/exit_code_spec.rb
narou-2.9.0 spec/exit_code_spec.rb
narou-2.8.3.1 spec/exit_code_spec.rb
narou-2.8.3 spec/exit_code_spec.rb
narou-2.8.2 spec/exit_code_spec.rb
narou-2.8.1 spec/exit_code_spec.rb
narou-2.8.0 spec/exit_code_spec.rb
narou-2.7.2 spec/exit_code_spec.rb
narou-2.7.1 spec/exit_code_spec.rb
narou-2.7.0 spec/exit_code_spec.rb
narou-2.6.1 spec/exit_code_spec.rb
narou-2.6.0 spec/exit_code_spec.rb
narou-2.5.2 spec/exit_code_spec.rb
narou-2.5.1 spec/exit_code_spec.rb
narou-2.4.2 spec/exit_code_spec.rb