spec/unit/set_spec.rb in ayadn-1.7.2 vs spec/unit/set_spec.rb in ayadn-1.7.3

- old
+ new

@@ -25,11 +25,14 @@ show_real_name: true, show_date: true, show_spinner: true, show_debug: false }, - formats: {table: {width: 75}}, + formats: { + table: {width: 75}, + list: {reverse: true} + }, counts: { default: 50, unified: 100, global: 100, checkins: 100, @@ -102,14 +105,10 @@ expect(Ayadn::Settings.options[:scroll][:timer]).to eq 4 Ayadn::SetScroll.new.timer('0') expect(Ayadn::Settings.options[:scroll][:timer]).to eq 3 Ayadn::SetScroll.new.timer('johnson') expect(Ayadn::Settings.options[:scroll][:timer]).to eq 3 - Ayadn::SetScroll.new.timer('-666') - expect(Ayadn::Settings.options[:scroll][:timer]).to eq 3 - Ayadn::SetScroll.new.timer('0') - expect(Ayadn::Settings.options[:scroll][:timer]).to eq 3 end end after do File.delete('spec/mock/ayadn.log') @@ -128,9 +127,47 @@ command = meth.to_sym color = colors_list.sample Ayadn::SetColor.new.send(command, color) expect(Ayadn::Settings.options[:colors][command]).to eq color.to_sym end + end + end + + after do + File.delete('spec/mock/ayadn.log') + end +end + +describe Ayadn::SetFormats do + before do + init_stubs + end + + describe "#table" do + it "creates a default table width" do + Ayadn::SetFormats.new.send(:table, ['width', '80']) + expect(Ayadn::Settings.options[:formats][:table][:width]).to eq 80 + end + it "creates a default table width" do + Ayadn::SetFormats.new.send(:table, ['width', '33']) + expect(Ayadn::Settings.options[:formats][:table][:width]).to eq 75 + end + it "creates a default table width" do + Ayadn::SetFormats.new.send(:table, ['width', 'yolo']) + expect(Ayadn::Settings.options[:formats][:table][:width]).to eq 75 + end + end + + describe "#list" do + it "creates a default list order" do + Ayadn::SetFormats.new.send(:list, ['reverse', 'false']) + expect(Ayadn::Settings.options[:formats][:list][:reverse]).to eq false + end + it "raises an error" do + printed = capture_stderr do + expect(lambda {Ayadn::SetFormats.new.send(:list, ['reverse', 'yolo'])}).to raise_error(SystemExit) + end + expect(printed).to include 'You have to submit valid items' end end after do File.delete('spec/mock/ayadn.log')