File: command_option_module_spec.rb

package info (click to toggle)
ruby-clamp 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 364 kB
  • sloc: ruby: 2,851; makefile: 4
file content (40 lines) | stat: -rw-r--r-- 648 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true

require "spec_helper"

describe Clamp::Command do

  include OutputCapture

  context "with included module" do

    let(:command) do

      shared_options = Module.new do
        extend Clamp::Option::Declaration

        option "--size", "SIZE", default: 4
      end

      command_class = Class.new(Clamp::Command) do

        include shared_options

        def execute
          puts "size = #{size}"
        end

      end

      command_class.new("foo")

    end

    it "accepts options from included module" do
      command.run(["--size", "42"])
      expect(stdout).to eq "size = 42\n"
    end

  end

end