Skip to content

Commit

Permalink
Fix formatting and code style in specs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrykonchin authored and eregon committed Aug 2, 2023
1 parent 3868409 commit e4bb761
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 0 additions & 2 deletions core/exception/case_compare_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
end

it "returns true if receiver is generic and arg is kind of SystemCallError" do
unknown_error_number = Errno.constants.size
e = SystemCallError.new('foo', @example_errno)
SystemCallError.===(e).should == true
end

it "returns false if receiver is generic and arg is not kind of SystemCallError" do
unknown_error_number = Errno.constants.size
e = Object.new
SystemCallError.===(e).should == false
end
Expand Down
9 changes: 5 additions & 4 deletions optional/capi/exception_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
end

describe "rb_syserr_new" do
it "returns system error with nil message" do
it "returns system error with default message when passed message is NULL" do
exception = @s.rb_syserr_new(Errno::ENOENT::Errno, nil)
exception.class.should == Errno::ENOENT
exception.message.should include("No such file or directory")
Expand All @@ -110,16 +110,17 @@

it "returns system error with custom message" do
exception = @s.rb_syserr_new(Errno::ENOENT::Errno, "custom message")

exception.message.should include("custom message")
exception.class.should == Errno::ENOENT
exception.should.is_a?(SystemCallError)
end
end

describe "rb_syserr_new_str" do
it "returns system error with nil message" do
const = Errno::ENOENT
exception = @s.rb_syserr_new_str(const::Errno, nil)
it "returns system error with default message when passed message is nil" do
exception = @s.rb_syserr_new_str(Errno::ENOENT::Errno, nil)

exception.message.should include("No such file or directory")
exception.class.should == Errno::ENOENT
exception.should.is_a?(SystemCallError)
Expand Down
8 changes: 5 additions & 3 deletions optional/capi/ext/exception_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ VALUE exception_spec_rb_set_errinfo(VALUE self, VALUE exc) {
}

VALUE exception_spec_rb_syserr_new(VALUE self, VALUE num, VALUE msg) {
char *cstr;
if(msg != Qnil) {
int n = NUM2INT(num);
char *cstr = NULL;

if (msg != Qnil) {
cstr = StringValuePtr(msg);
}
int n = NUM2INT(num);

return rb_syserr_new(n, cstr);
}

Expand Down

0 comments on commit e4bb761

Please sign in to comment.