spec/software_spec.rb in ronin-1.5.0 vs spec/software_spec.rb in ronin-1.5.1
- old
+ new
@@ -1,33 +1,46 @@
require 'spec_helper'
+
require 'ronin/software'
describe Software do
- it "should require name and version attributes" do
- software = Software.new
- software.should_not be_valid
+ let(:name) { 'Test' }
+ let(:version) { '0.1.0' }
+ let(:vendor) { 'TestCo' }
- software.name = 'Test'
- software.should_not be_valid
+ subject do
+ described_class.new(
+ :name => name,
+ :version => version,
+ :vendor => {:name => vendor}
+ )
+ end
- software.version = '0.1.0'
- software.should be_valid
+ describe "validations" do
+ it "should require name and version attributes" do
+ software = described_class.new
+ expect(software).not_to be_valid
+
+ software.name = name
+ expect(software).not_to be_valid
+
+ software.version = version
+ expect(software).to be_valid
+ end
end
describe "#to_s" do
it "should be convertable to a String" do
- software = Software.new(
- :name => 'Test',
- :version => '0.1.0',
- :vendor => {:name => 'TestCo'}
- )
-
- software.to_s.should == 'TestCo Test 0.1.0'
+ expect(subject.to_s).to eq("#{vendor} #{name} #{version}")
end
- it "should ignore the missing vendor information" do
- software = Software.new(:name => 'Test', :version => '0.1.0')
+ context "without a vendor" do
+ subject do
+ described_class.new(:name => name, :version => version)
+ end
- software.to_s.should == 'Test 0.1.0'
+ it "should ignore the missing vendor information" do
+ expect(subject.to_s).to eq("#{name} #{version}")
+ end
end
end
end