File: option_module_spec.rb

package info (click to toggle)
ruby-clamp 1.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 312 kB
  • sloc: ruby: 2,359; makefile: 4
file content (37 lines) | stat: -rw-r--r-- 620 bytes parent folder | download | duplicates (3)
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
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 eql "size = 42\n"
    end

  end

end