Skip to content

Commit d51883e

Browse files
committed
Enclose in ruby_version_is blocks
1 parent 5f6a4ed commit d51883e

File tree

2 files changed

+64
-68
lines changed

2 files changed

+64
-68
lines changed

spec/ruby/optional/capi/data_spec.rb

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,53 @@
11
require_relative 'spec_helper'
2-
ruby_version_is "3.4" do
3-
return
4-
end
5-
6-
load_extension("data")
7-
8-
describe "CApiAllocSpecs (a class with an alloc func defined)" do
9-
it "calls the alloc func" do
10-
@s = CApiAllocSpecs.new
11-
@s.wrapped_data.should == 42 # not defined in initialize
12-
end
13-
end
14-
15-
describe "CApiWrappedStruct" do
16-
before :each do
17-
@s = CApiWrappedStructSpecs.new
18-
end
2+
ruby_version_is ""..."3.4" do
3+
load_extension("data")
194

20-
it "wraps with Data_Wrap_Struct and Data_Get_Struct returns data" do
21-
a = @s.wrap_struct(1024)
22-
@s.get_struct(a).should == 1024
5+
describe "CApiAllocSpecs (a class with an alloc func defined)" do
6+
it "calls the alloc func" do
7+
@s = CApiAllocSpecs.new
8+
@s.wrapped_data.should == 42 # not defined in initialize
9+
end
2310
end
2411

25-
describe "RDATA()" do
26-
it "returns the struct data" do
27-
a = @s.wrap_struct(1024)
28-
@s.get_struct_rdata(a).should == 1024
12+
describe "CApiWrappedStruct" do
13+
before :each do
14+
@s = CApiWrappedStructSpecs.new
2915
end
3016

31-
it "allows changing the wrapped struct" do
17+
it "wraps with Data_Wrap_Struct and Data_Get_Struct returns data" do
3218
a = @s.wrap_struct(1024)
33-
@s.change_struct(a, 100)
34-
@s.get_struct(a).should == 100
19+
@s.get_struct(a).should == 1024
3520
end
3621

37-
it "raises a TypeError if the object does not wrap a struct" do
38-
-> { @s.get_struct(Object.new) }.should raise_error(TypeError)
22+
describe "RDATA()" do
23+
it "returns the struct data" do
24+
a = @s.wrap_struct(1024)
25+
@s.get_struct_rdata(a).should == 1024
26+
end
27+
28+
it "allows changing the wrapped struct" do
29+
a = @s.wrap_struct(1024)
30+
@s.change_struct(a, 100)
31+
@s.get_struct(a).should == 100
32+
end
33+
34+
it "raises a TypeError if the object does not wrap a struct" do
35+
-> { @s.get_struct(Object.new) }.should raise_error(TypeError)
36+
end
3937
end
40-
end
4138

42-
describe "rb_check_type" do
43-
it "does not raise an exception when checking data objects" do
44-
a = @s.wrap_struct(1024)
45-
@s.rb_check_type(a, a).should == true
39+
describe "rb_check_type" do
40+
it "does not raise an exception when checking data objects" do
41+
a = @s.wrap_struct(1024)
42+
@s.rb_check_type(a, a).should == true
43+
end
4644
end
47-
end
4845

49-
describe "DATA_PTR" do
50-
it "returns the struct data" do
51-
a = @s.wrap_struct(1024)
52-
@s.get_struct_data_ptr(a).should == 1024
46+
describe "DATA_PTR" do
47+
it "returns the struct data" do
48+
a = @s.wrap_struct(1024)
49+
@s.get_struct_data_ptr(a).should == 1024
50+
end
5351
end
5452
end
5553
end

spec/ruby/optional/capi/rbasic_spec.rb

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,35 @@
1414
it_should_behave_like :rbasic
1515
end
1616

17-
ruby_version_is "3.4" do
18-
return
19-
end
20-
21-
describe "RBasic support for RData" do
22-
before :all do
23-
@specs = CApiRBasicRDataSpecs.new
24-
@wrapping = CApiWrappedStructSpecs.new
25-
@data = -> { [@wrapping.wrap_struct(1024), @wrapping.wrap_struct(1025)] }
26-
end
27-
it_should_behave_like :rbasic
17+
ruby_version_is ""..."3.4" do
18+
describe "RBasic support for RData" do
19+
before :all do
20+
@specs = CApiRBasicRDataSpecs.new
21+
@wrapping = CApiWrappedStructSpecs.new
22+
@data = -> { [@wrapping.wrap_struct(1024), @wrapping.wrap_struct(1025)] }
23+
end
24+
it_should_behave_like :rbasic
2825

29-
it "supports user flags" do
30-
obj, _ = @data.call
31-
initial = @specs.get_flags(obj)
32-
@specs.set_flags(obj, 1 << 14 | 1 << 16 | initial).should == 1 << 14 | 1 << 16 | initial
33-
@specs.get_flags(obj).should == 1 << 14 | 1 << 16 | initial
34-
@specs.set_flags(obj, initial).should == initial
35-
end
26+
it "supports user flags" do
27+
obj, _ = @data.call
28+
initial = @specs.get_flags(obj)
29+
@specs.set_flags(obj, 1 << 14 | 1 << 16 | initial).should == 1 << 14 | 1 << 16 | initial
30+
@specs.get_flags(obj).should == 1 << 14 | 1 << 16 | initial
31+
@specs.set_flags(obj, initial).should == initial
32+
end
3633

37-
it "supports copying the flags from one object over to the other" do
38-
obj1, obj2 = @data.call
39-
initial = @specs.get_flags(obj1)
40-
@specs.get_flags(obj2).should == initial
41-
@specs.set_flags(obj1, 1 << 14 | 1 << 16 | initial)
42-
@specs.get_flags(obj1).should == 1 << 14 | 1 << 16 | initial
34+
it "supports copying the flags from one object over to the other" do
35+
obj1, obj2 = @data.call
36+
initial = @specs.get_flags(obj1)
37+
@specs.get_flags(obj2).should == initial
38+
@specs.set_flags(obj1, 1 << 14 | 1 << 16 | initial)
39+
@specs.get_flags(obj1).should == 1 << 14 | 1 << 16 | initial
4340

44-
@specs.copy_flags(obj2, obj1)
45-
@specs.get_flags(obj2).should == 1 << 14 | 1 << 16 | initial
46-
@specs.set_flags(obj1, initial)
47-
@specs.copy_flags(obj2, obj1)
48-
@specs.get_flags(obj2).should == initial
41+
@specs.copy_flags(obj2, obj1)
42+
@specs.get_flags(obj2).should == 1 << 14 | 1 << 16 | initial
43+
@specs.set_flags(obj1, initial)
44+
@specs.copy_flags(obj2, obj1)
45+
@specs.get_flags(obj2).should == initial
46+
end
4947
end
5048
end

0 commit comments

Comments
 (0)