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
41
42
43
44
45
46
47
48
49
describe "The -n, --name RUBY_NAME option" do
  before :each do
    @verbose, $VERBOSE = $VERBOSE, nil
    @options = new_option
  end

  after :each do
    $VERBOSE = @verbose
  end

  it "is enabled with #add_name" do
    @options.should_receive(:on).with("-n", "--name RUBY_NAME", :anything, :string)
    @options.add_name
  end

  it "sets RUBY_NAME when invoked" do
    Object.should_receive(:const_set).with(:RUBY_NAME, "name").twice
    @options.add_name
    @options.parse ["-n", "name"]
    @options.parse ["--name", "name"]
  end
end

describe MSpecOptions, "#add_targets" do
  before :each do
    @options = MSpecOptions.new MOSConfig.new, "spec"
    @options.add_targets
  end

  it "adds -t, --target TARGET option" do
    @options.parse ["-t", "ruby"]
    @options.parse ["--target", "ruby"]
  end

  it "adds -T, --target-opt OPT option" do
    @options.parse ["-T", "--ps"]
    @options.parse ["--target-opt", "--ps"]
  end

  it "adds -I, --include DIR option" do
    @options.parse ["-I", "include"]
    @options.parse ["--include", "include"]
  end

  it "adds -r, --require LIBRARY option" do
    @options.parse ["-r", "library"]
    @options.parse ["--require", "library"]
  end
end