spec/cert/extensions/basic_constraints_spec.rb in r509-0.10.0 vs spec/cert/extensions/basic_constraints_spec.rb in r509-1.0

- old
+ new

@@ -3,28 +3,28 @@ shared_examples_for "a correct R509 BasicConstraints object" do |critical| before :all do extension_name = "basicConstraints" klass = R509::Cert::Extensions::BasicConstraints ef = OpenSSL::X509::ExtensionFactory.new - openssl_ext = ef.create_extension( extension_name, @extension_value , critical) - @r509_ext = klass.new( openssl_ext ) + openssl_ext = ef.create_extension(extension_name, @extension_value, critical) + @r509_ext = klass.new(openssl_ext) end it "is_ca? should correctly report whether it's a CA certificate (critical:#{critical})" do - @r509_ext.is_ca?.should == @is_ca + expect(@r509_ext.is_ca?).to eq(@is_ca) end it "the path length should be correct (critical:#{critical})" do - @r509_ext.path_length.should == @pathlen + expect(@r509_ext.path_length).to eq(@pathlen) end it "allows_sub_ca? should correctly report whether its path length allows it to issue CA certs (critical:#{critical})" do - @r509_ext.allows_sub_ca?.should == @allows_sub_ca + expect(@r509_ext.allows_sub_ca?).to eq(@allows_sub_ca) end it "reports #critical? properly" do - @r509_ext.critical?.should == critical + expect(@r509_ext.critical?).to eq(critical) end end describe R509::Cert::Extensions::BasicConstraints do @@ -53,84 +53,84 @@ @args = { :ca => true, :critical => true } @bc = R509::Cert::Extensions::BasicConstraints.new(@args) end it "creates extension" do - @bc.is_ca?.should be_true - @bc.path_length.should be_nil + expect(@bc.is_ca?).to be true + expect(@bc.path_length).to be_nil end it "builds yaml" do - YAML.load(@bc.to_yaml).should == @args + expect(YAML.load(@bc.to_yaml)).to eq(@args) end end context "CA:TRUE with path_length" do before :all do @args = { :ca => true, :path_length => 3, :critical => true } @bc = R509::Cert::Extensions::BasicConstraints.new(@args) end it "creates extension" do - @bc.is_ca?.should be_true - @bc.path_length.should == 3 + expect(@bc.is_ca?).to be true + expect(@bc.path_length).to eq(3) end it "builds yaml" do - YAML.load(@bc.to_yaml).should == @args + expect(YAML.load(@bc.to_yaml)).to eq(@args) end end context "CA:FALSE" do before :all do @args = { :ca => false, :critical => true } @bc = R509::Cert::Extensions::BasicConstraints.new(@args) end it "creates extension" do - @bc.is_ca?.should be_false - @bc.path_length.should be_nil + expect(@bc.is_ca?).to be false + expect(@bc.path_length).to be_nil end it "builds yaml" do - YAML.load(@bc.to_yaml).should == @args + expect(YAML.load(@bc.to_yaml)).to eq(@args) end end context "default criticality" do before :all do @args = { :ca => false } @bc = R509::Cert::Extensions::BasicConstraints.new(@args) end it "creates extension" do - @bc.critical?.should be_true + expect(@bc.critical?).to be true end it "builds yaml" do - YAML.load(@bc.to_yaml).should == @args.merge(:critical => true) + expect(YAML.load(@bc.to_yaml)).to eq(@args.merge(:critical => true)) end end context "non-default criticality" do before :all do @args = { :ca => false, :critical => false } @bc = R509::Cert::Extensions::BasicConstraints.new(@args) end it "creates extension" do - @bc.critical?.should be_false + expect(@bc.critical?).to be false end it "builds yaml" do - YAML.load(@bc.to_yaml).should == @args + expect(YAML.load(@bc.to_yaml)).to eq(@args) end end it "errors when supplying path_length if CA:FALSE" do - expect { + expect do R509::Cert::Extensions::BasicConstraints.new(:ca => false, :path_length => 4) - }.to raise_error(ArgumentError, ":path_length is not allowed when :ca is false") + end.to raise_error(ArgumentError, ":path_length is not allowed when :ca is false") end end context "with constraints for a CA certificate" do