spec/lib/formats/plain_spec.rb in hieracles-0.1.7 vs spec/lib/formats/plain_spec.rb in hieracles-0.2.0
- old
+ new
@@ -51,29 +51,55 @@
expect(plain_format.send :build_head, true).to eq expected
end
end
describe ".build_params_line" do
- let(:expected) {
- "[1] params.this.var value2\n"+
- " [0] params.this.var value1\n"
- }
- let(:params) {
- [
- { file: 'path1', value: 'value1', merged: 'value1'},
- { file: 'path2', value: 'value2', merged: 'value2'},
- ]
- }
- before {
- plain_format.instance_variable_set(:@index,
- {'path1' => 0, 'path2' => 1}
- )
- }
- it "outputs proper text" do
- expect(plain_format.send :build_params_line,
- "params.this.var",
- params,
- nil).to eq expected
+ context "when not merged" do
+ let(:expected) {
+ "[1] params.this.var value2\n"+
+ " [0] params.this.var value1\n"
+ }
+ let(:params) {
+ [
+ { file: 'path1', value: 'value1', merged: 'value1'},
+ { file: 'path2', value: 'value2', merged: 'value2'},
+ ]
+ }
+ before {
+ plain_format.instance_variable_set(:@index,
+ {'path1' => 0, 'path2' => 1}
+ )
+ }
+ it "outputs proper text" do
+ expect(plain_format.send :build_params_line,
+ "params.this.var",
+ params,
+ nil).to eq expected
+ end
+ end
+ context "when merged" do
+ let(:expected) {
+ "[-] params.this.var [\"value1\", \"value2\"]\n"+
+ " [1] params.this.var [\"value2\"]\n"+
+ " [0] params.this.var [\"value1\"]\n"
+ }
+ let(:params) {
+ [
+ { file: 'path1', value: ['value1'], merged: ['value1'] },
+ { file: 'path2', value: ['value2'], merged: ['value1','value2'] },
+ ]
+ }
+ before {
+ plain_format.instance_variable_set(:@index,
+ {'path1' => 0, 'path2' => 1}
+ )
+ }
+ it "outputs proper text" do
+ expect(plain_format.send :build_params_line,
+ "params.this.var",
+ params,
+ nil).to eq expected
+ end
end
end
describe ".build_modules_line" do
before {