spec/topic_spec.rb in howzit-2.0.15 vs spec/topic_spec.rb in howzit-2.0.16

- old
+ new

@@ -5,57 +5,87 @@ describe Howzit::Topic do title = 'Test Title' content = 'Test Content' subject(:topic) { Howzit::Topic.new(title, content) } - describe ".new" do - it "makes a new topic instance" do + describe '.new' do + it 'makes a new topic instance' do expect(topic).to be_a Howzit::Topic end - it "has the correct title" do + it 'has the correct title' do expect(topic.title).to eq title end - it "has the correct content" do + it 'has the correct content' do expect(topic.content).to eq content end end end describe Howzit::Topic do subject(:topic) { @hz.find_topic('Topic Balogna')[0] } - describe ".title" do - it "has the correct title" do - expect(topic.title).to match /Topic Balogna/ + describe '.title' do + it 'has the correct title' do + expect(topic.title).to match(/Topic Balogna/) end end - describe ".tasks" do - it "has 2 tasks" do + describe '.tasks' do + it 'has 2 tasks' do expect(topic.tasks.count).to eq 2 end end - describe ".prereqs" do - it "has prereq" do + describe '.prereqs' do + it 'has prereq' do expect(topic.prereqs.count).to eq 1 end - it "has postreq" do + end + + describe '.postreqs' do + it 'has postreq' do expect(topic.postreqs.count).to eq 1 end end - describe ".run" do + describe '.grep' do + it 'returns true for matching pattern in content' do + expect(topic.grep('prereq.*?ite')).to be_truthy + end + it 'returns true for matching pattern in title' do + expect(topic.grep('bal.*?na')).to be_truthy + end + it 'fails on bad pattern' do + expect(topic.grep('xxx+')).to_not be_truthy + end + end + + describe '.run' do Howzit.options[:default] = true - it "shows prereq and postreq" do + it 'shows prereq and postreq' do expect { topic.run }.to output(/prerequisite/).to_stdout expect { topic.run }.to output(/postrequisite/).to_stdout end - it "Copies to clipboard" do + it 'Copies to clipboard' do expect { ENV['RUBYOPT'] = '-W1' Howzit.options[:log_level] = 0 topic.run }.to output(/Copied/).to_stderr + end + end + + describe '.print_out' do + Howzit.options[:header_format] = :block + Howzit.options[:color] = false + it 'prints the topic title' do + expect(topic.print_out({single: true, header: true}).join("\n").uncolor).to match(/▌Topic Balogna/) + end + it 'prints a task title' do + expect(topic.print_out({single: true, header: true}).join("\n").uncolor).to match(/▶ Null Output/) + end + it 'prints task action with --show-code' do + Howzit.options[:show_all_code] = true + expect(topic.print_out({single: true, header: true}).join("\n").uncolor).to match(/▶ ls -1/) end end end