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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
require "spec_helper"
require 'rspec/core/drb_options'
describe RSpec::Core::DrbOptions, :isolated_directory => true, :isolated_home => true do
include ConfigOptionsHelper
describe "#drb_argv" do
it "preserves extra arguments" do
File.stub(:exist?) { false }
expect(config_options_object(*%w[ a --drb b --color c ]).drb_argv).to match_array %w[ --color a b c ]
end
%w(--color --fail-fast --profile --backtrace --tty).each do |option|
it "includes #{option}" do
expect(config_options_object("#{option}").drb_argv).to include("#{option}")
end
end
it "includes --failure-exit-code" do
expect(config_options_object(*%w[--failure-exit-code 2]).drb_argv).to include("--failure-exit-code", "2")
end
it "includes --options" do
expect(config_options_object(*%w[--options custom.opts]).drb_argv).to include("--options", "custom.opts")
end
it "includes --order" do
expect(config_options_object(*%w[--order random]).drb_argv).to include('--order', 'random')
end
context "with --example" do
it "includes --example" do
expect(config_options_object(*%w[--example foo]).drb_argv).to include("--example", "foo")
end
it "unescapes characters which were escaped upon storing --example originally" do
expect(config_options_object("--example", "foo\\ bar").drb_argv).to include("--example", "foo bar")
end
end
context "with tags" do
it "includes the inclusion tags" do
coo = config_options_object("--tag", "tag")
expect(coo.drb_argv).to eq(["--tag", "tag"])
end
it "includes the inclusion tags with values" do
coo = config_options_object("--tag", "tag:foo")
expect(coo.drb_argv).to eq(["--tag", "tag:foo"])
end
it "leaves inclusion tags intact" do
coo = config_options_object("--tag", "tag")
coo.drb_argv
expect(coo.filter_manager.inclusions).to eq( {:tag=>true} )
end
it "leaves inclusion tags with values intact" do
coo = config_options_object("--tag", "tag:foo")
coo.drb_argv
expect(coo.filter_manager.inclusions).to eq( {:tag=>'foo'} )
end
it "includes the exclusion tags" do
coo = config_options_object("--tag", "~tag")
expect(coo.drb_argv).to eq(["--tag", "~tag"])
end
it "includes the exclusion tags with values" do
coo = config_options_object("--tag", "~tag:foo")
expect(coo.drb_argv).to eq(["--tag", "~tag:foo"])
end
it "leaves exclusion tags intact" do
coo = config_options_object("--tag", "~tag")
coo.drb_argv
expect(coo.filter_manager.exclusions).to include(:tag=>true)
end
it "leaves exclusion tags with values intact" do
coo = config_options_object("--tag", "~tag:foo")
coo.drb_argv
expect(coo.filter_manager.exclusions).to include(:tag=>'foo')
end
end
context "with formatters" do
it "includes the formatters" do
coo = config_options_object("--format", "d")
expect(coo.drb_argv).to eq(["--format", "d"])
end
it "leaves formatters intact" do
coo = config_options_object("--format", "d")
coo.drb_argv
expect(coo.options[:formatters]).to eq([["d"]])
end
it "leaves output intact" do
coo = config_options_object("--format", "p", "--out", "foo.txt", "--format", "d")
coo.drb_argv
expect(coo.options[:formatters]).to eq([["p","foo.txt"],["d"]])
end
end
context "with --out" do
it "combines with formatters" do
coo = config_options_object(*%w[--format h --out report.html])
expect(coo.drb_argv).to eq(%w[--format h --out report.html])
end
end
context "with --line_number" do
it "includes --line_number" do
expect(config_options_object(*%w[--line_number 35]).drb_argv).to eq(%w[--line_number 35])
end
it "includes multiple lines" do
expect(config_options_object(*%w[-l 90 -l 4 -l 55]).drb_argv).to eq(
%w[--line_number 90 --line_number 4 --line_number 55]
)
end
end
context "with -I libs" do
it "includes -I" do
expect(config_options_object(*%w[-I a_dir]).drb_argv).to eq(%w[-I a_dir])
end
it "includes multiple paths" do
expect(config_options_object(*%w[-I dir_1 -I dir_2 -I dir_3]).drb_argv).to eq(
%w[-I dir_1 -I dir_2 -I dir_3]
)
end
end
context "with --require" do
it "includes --require" do
expect(config_options_object(*%w[--require a_path]).drb_argv).to eq(%w[--require a_path])
end
it "includes multiple paths" do
expect(config_options_object(*%w[--require dir/ --require file.rb]).drb_argv).to eq(
%w[--require dir/ --require file.rb]
)
end
end
context "--drb specified in ARGV" do
it "renders all the original arguments except --drb" do
drb_argv = config_options_object(*%w[ --drb --color --format s --example pattern
--line_number 1 --profile --backtrace -I
path/a -I path/b --require path/c --require
path/d]).drb_argv
expect(drb_argv).to eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s -I path/a -I path/b --require path/c --require path/d])
end
end
context "--drb specified in the options file" do
it "renders all the original arguments except --drb" do
File.open("./.rspec", "w") {|f| f << "--drb --color"}
drb_argv = config_options_object(*%w[ --tty --format s --example
pattern --line_number 1 --profile
--backtrace ]).drb_argv
expect(drb_argv).to eq(%w[ --color --profile --backtrace --tty
--example pattern --line_number 1 --format s])
end
end
context "--drb specified in ARGV and the options file" do
it "renders all the original arguments except --drb" do
File.open("./.rspec", "w") {|f| f << "--drb --color"}
drb_argv = config_options_object(*%w[ --drb --format s --example
pattern --line_number 1 --profile
--backtrace]).drb_argv
expect(drb_argv).to eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s])
end
end
context "--drb specified in ARGV and in as ARGV-specified --options file" do
it "renders all the original arguments except --drb and --options" do
File.open("./.rspec", "w") {|f| f << "--drb --color"}
drb_argv = config_options_object(*%w[ --drb --format s --example
pattern --line_number 1 --profile
--backtrace]).drb_argv
expect(drb_argv).to eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s ])
end
end
end
end
|