ffi 1.9.5 → 1.9.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ffi might be problematic. Click here for more details.

Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +13 -6
  3. data/ext/ffi_c/extconf.rb +2 -2
  4. data/lib/ffi.rb +2 -0
  5. data/lib/ffi/version.rb +1 -1
  6. data/spec/ffi/async_callback_spec.rb +4 -5
  7. data/spec/ffi/bool_spec.rb +9 -8
  8. data/spec/ffi/buffer_spec.rb +64 -37
  9. data/spec/ffi/callback_spec.rb +195 -116
  10. data/spec/ffi/custom_param_type.rb +1 -1
  11. data/spec/ffi/custom_type_spec.rb +5 -6
  12. data/spec/ffi/dup_spec.rb +6 -8
  13. data/spec/ffi/enum_spec.rb +135 -129
  14. data/spec/ffi/errno_spec.rb +2 -2
  15. data/spec/ffi/ffi_spec.rb +4 -6
  16. data/spec/ffi/fixtures/EnumTest.o +0 -0
  17. data/spec/ffi/function_spec.rb +22 -11
  18. data/spec/ffi/io_spec.rb +0 -1
  19. data/spec/ffi/library_spec.rb +71 -36
  20. data/spec/ffi/long_double.rb +3 -4
  21. data/spec/ffi/managed_struct_spec.rb +14 -4
  22. data/spec/ffi/memorypointer_spec.rb +7 -1
  23. data/spec/ffi/number_spec.rb +43 -34
  24. data/spec/ffi/platform_spec.rb +76 -59
  25. data/spec/ffi/pointer_spec.rb +35 -31
  26. data/spec/ffi/rbx/attach_function_spec.rb +3 -4
  27. data/spec/ffi/rbx/memory_pointer_spec.rb +24 -22
  28. data/spec/ffi/rbx/spec_helper.rb +0 -1
  29. data/spec/ffi/rbx/struct_spec.rb +1 -2
  30. data/spec/ffi/spec_helper.rb +5 -2
  31. data/spec/ffi/string_spec.rb +22 -14
  32. data/spec/ffi/strptr_spec.rb +6 -7
  33. data/spec/ffi/struct_by_ref_spec.rb +4 -5
  34. data/spec/ffi/struct_callback_spec.rb +6 -7
  35. data/spec/ffi/struct_initialize_spec.rb +2 -3
  36. data/spec/ffi/struct_packed_spec.rb +12 -14
  37. data/spec/ffi/struct_spec.rb +203 -129
  38. data/spec/ffi/typedef_spec.rb +11 -10
  39. data/spec/ffi/union_spec.rb +8 -7
  40. data/spec/ffi/variadic_spec.rb +13 -10
  41. metadata +2 -2
@@ -4,7 +4,6 @@
4
4
  #
5
5
 
6
6
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
- require 'ffi'
8
7
 
9
8
  describe "functions with custom parameter types" do
10
9
  before :each do
@@ -33,5 +32,6 @@ describe "functions with custom parameter types" do
33
32
  def self.to_native_called?; @to_native_called; end
34
33
  end
35
34
 
35
+ # FIXME add tests
36
36
  end
37
37
  end
@@ -4,7 +4,6 @@
4
4
  #
5
5
 
6
6
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
- require 'ffi'
8
7
 
9
8
  describe "functions with custom types" do
10
9
  class Custom_enum
@@ -32,13 +31,13 @@ describe "functions with custom types" do
32
31
  end
33
32
 
34
33
  it "can attach with custom return type" do
35
- lambda do
34
+ expect do
36
35
  Module.new do
37
36
  extend FFI::Library
38
37
  ffi_lib TestLibrary::PATH
39
38
  attach_function :ret_s32, [ :int ], Custom_enum
40
39
  end
41
- end.should_not raise_error
40
+ end.not_to raise_error
42
41
  end
43
42
 
44
43
  it "should return object of correct type" do
@@ -50,7 +49,7 @@ describe "functions with custom types" do
50
49
  attach_function :ret_s32, [ :int ], Custom_enum
51
50
  end
52
51
 
53
- m.ret_s32(1).is_a?(Symbol).should be_true
52
+ expect(m.ret_s32(1).is_a?(Symbol)).to be true
54
53
  end
55
54
 
56
55
  it "from_native should be called for result" do
@@ -60,7 +59,7 @@ describe "functions with custom types" do
60
59
  attach_function :ret_s32, [ :int ], Custom_enum
61
60
  end
62
61
  m.ret_s32(1)
63
- Custom_enum.from_native_called?.should be_true
62
+ expect(Custom_enum.from_native_called?).to be true
64
63
  end
65
64
 
66
65
  it "to_native should be called for parameter" do
@@ -70,6 +69,6 @@ describe "functions with custom types" do
70
69
  attach_function :ret_s32, [ Custom_enum ], :int
71
70
  end
72
71
  m.ret_s32(:a)
73
- Custom_enum.to_native_called?.should be_true
72
+ expect(Custom_enum.to_native_called?).to be true
74
73
  end
75
74
  end
@@ -4,7 +4,6 @@
4
4
  #
5
5
 
6
6
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
- require 'ffi'
8
7
 
9
8
  describe "Pointer#dup" do
10
9
  it "clone should be independent" do
@@ -13,7 +12,7 @@ describe "Pointer#dup" do
13
12
  p2 = p1.dup
14
13
  p1.put_string(0, "deadbeef")
15
14
 
16
- p2.get_string(0).should == "test123"
15
+ expect(p2.get_string(0)).to eq("test123")
17
16
  end
18
17
 
19
18
  it "sliced pointer can be cloned" do
@@ -22,8 +21,8 @@ describe "Pointer#dup" do
22
21
  p2 = p1[1].dup
23
22
 
24
23
  # first char will be excised
25
- p2.get_string(0).should == "est123"
26
- p1.get_string(0).should == "test123"
24
+ expect(p2.get_string(0)).to eq("est123")
25
+ expect(p1.get_string(0)).to eq("test123")
27
26
  end
28
27
 
29
28
  it "sliced pointer when cloned is independent" do
@@ -33,7 +32,7 @@ describe "Pointer#dup" do
33
32
 
34
33
  p1.put_string(0, "deadbeef")
35
34
  # first char will be excised
36
- p2.get_string(0).should == "est123"
35
+ expect(p2.get_string(0)).to eq("est123")
37
36
  end
38
37
  end
39
38
 
@@ -47,8 +46,7 @@ describe "Struct#dup" do
47
46
  s1[:i] = 0x12345
48
47
  s2 = s1.dup
49
48
  s1[:i] = 0x98765
50
- s2[:i].should == 0x12345
51
- s1[:i].should == 0x98765
49
+ expect(s2[:i]).to eq(0x12345)
50
+ expect(s1[:i]).to eq(0x98765)
52
51
  end
53
-
54
52
  end
@@ -4,7 +4,6 @@
4
4
  #
5
5
 
6
6
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
- require 'ffi'
8
7
 
9
8
  module TestEnum0
10
9
  extend FFI::Library
@@ -39,183 +38,190 @@ end
39
38
 
40
39
  describe "A library with no enum defined" do
41
40
  it "returns nil when asked for an enum" do
42
- TestEnum0.enum_type(:foo).should == nil
41
+ expect(TestEnum0.enum_type(:foo)).to be_nil
43
42
  end
44
43
  end
45
44
 
46
45
  describe "An untagged enum" do
47
46
  it "constants can be used as function parameters and return value" do
48
- TestEnum1.test_untagged_enum(:c1).should == 0
49
- TestEnum1.test_untagged_enum(:c2).should == 1
50
- TestEnum1.test_untagged_enum(:c3).should == 2
51
- TestEnum1.test_untagged_enum(:c4).should == 3
52
- TestEnum1.test_untagged_enum(:c5).should == 42
53
- TestEnum1.test_untagged_enum(:c6).should == 43
54
- TestEnum1.test_untagged_enum(:c7).should == 44
55
- TestEnum1.test_untagged_enum(:c8).should == 45
56
- TestEnum1.test_untagged_enum(:c9).should == 42
57
- TestEnum1.test_untagged_enum(:c10).should == 43
58
- TestEnum1.test_untagged_enum(:c11).should == 4242
59
- TestEnum1.test_untagged_enum(:c12).should == 4243
60
- TestEnum1.test_untagged_enum(:c13).should == 42
61
- TestEnum1.test_untagged_enum(:c14).should == 4242
62
- TestEnum1.test_untagged_enum(:c15).should == 424242
63
- TestEnum1.test_untagged_enum(:c16).should == 42424242
47
+ expect(TestEnum1.test_untagged_enum(:c1)).to eq(0)
48
+ expect(TestEnum1.test_untagged_enum(:c2)).to eq(1)
49
+ expect(TestEnum1.test_untagged_enum(:c3)).to eq(2)
50
+ expect(TestEnum1.test_untagged_enum(:c4)).to eq(3)
51
+ expect(TestEnum1.test_untagged_enum(:c5)).to eq(42)
52
+ expect(TestEnum1.test_untagged_enum(:c6)).to eq(43)
53
+ expect(TestEnum1.test_untagged_enum(:c7)).to eq(44)
54
+ expect(TestEnum1.test_untagged_enum(:c8)).to eq(45)
55
+ expect(TestEnum1.test_untagged_enum(:c9)).to eq(42)
56
+ expect(TestEnum1.test_untagged_enum(:c10)).to eq(43)
57
+ expect(TestEnum1.test_untagged_enum(:c11)).to eq(4242)
58
+ expect(TestEnum1.test_untagged_enum(:c12)).to eq(4243)
59
+ expect(TestEnum1.test_untagged_enum(:c13)).to eq(42)
60
+ expect(TestEnum1.test_untagged_enum(:c14)).to eq(4242)
61
+ expect(TestEnum1.test_untagged_enum(:c15)).to eq(424242)
62
+ expect(TestEnum1.test_untagged_enum(:c16)).to eq(42424242)
64
63
  end
65
64
  end
66
65
 
67
66
  describe "A tagged typedef enum" do
68
67
  it "is accessible through its tag" do
69
- TestEnum3.enum_type(:enum_type1).should_not == nil
70
- TestEnum3.enum_type(:enum_type2).should_not == nil
71
- TestEnum3.enum_type(:enum_type3).should_not == nil
72
- TestEnum3.enum_type(:enum_type4).should_not == nil
68
+ expect(TestEnum3.enum_type(:enum_type1)).not_to be_nil
69
+ expect(TestEnum3.enum_type(:enum_type2)).not_to be_nil
70
+ expect(TestEnum3.enum_type(:enum_type3)).not_to be_nil
71
+ expect(TestEnum3.enum_type(:enum_type4)).not_to be_nil
73
72
  end
73
+
74
74
  it "contains enum constants" do
75
- TestEnum3.enum_type(:enum_type1).symbols.length.should == 4
76
- TestEnum3.enum_type(:enum_type2).symbols.length.should == 4
77
- TestEnum3.enum_type(:enum_type3).symbols.length.should == 4
78
- TestEnum3.enum_type(:enum_type4).symbols.length.should == 4
75
+ expect(TestEnum3.enum_type(:enum_type1).symbols.length).to eq(4)
76
+ expect(TestEnum3.enum_type(:enum_type2).symbols.length).to eq(4)
77
+ expect(TestEnum3.enum_type(:enum_type3).symbols.length).to eq(4)
78
+ expect(TestEnum3.enum_type(:enum_type4).symbols.length).to eq(4)
79
79
  end
80
+
80
81
  it "constants can be used as function parameters and return value" do
81
- TestEnum3.test_tagged_typedef_enum1(:c1).should == :c1
82
- TestEnum3.test_tagged_typedef_enum1(:c2).should == :c2
83
- TestEnum3.test_tagged_typedef_enum1(:c3).should == :c3
84
- TestEnum3.test_tagged_typedef_enum1(:c4).should == :c4
85
- TestEnum3.test_tagged_typedef_enum2(:c5).should == :c5
86
- TestEnum3.test_tagged_typedef_enum2(:c6).should == :c6
87
- TestEnum3.test_tagged_typedef_enum2(:c7).should == :c7
88
- TestEnum3.test_tagged_typedef_enum2(:c8).should == :c8
89
- TestEnum3.test_tagged_typedef_enum3(:c9).should == :c9
90
- TestEnum3.test_tagged_typedef_enum3(:c10).should == :c10
91
- TestEnum3.test_tagged_typedef_enum3(:c11).should == :c11
92
- TestEnum3.test_tagged_typedef_enum3(:c12).should == :c12
93
- TestEnum3.test_tagged_typedef_enum4(:c13).should == :c13
94
- TestEnum3.test_tagged_typedef_enum4(:c14).should == :c14
95
- TestEnum3.test_tagged_typedef_enum4(:c15).should == :c15
96
- TestEnum3.test_tagged_typedef_enum4(:c16).should == :c16
82
+ expect(TestEnum3.test_tagged_typedef_enum1(:c1)).to be :c1
83
+ expect(TestEnum3.test_tagged_typedef_enum1(:c2)).to be :c2
84
+ expect(TestEnum3.test_tagged_typedef_enum1(:c3)).to be :c3
85
+ expect(TestEnum3.test_tagged_typedef_enum1(:c4)).to be :c4
86
+ expect(TestEnum3.test_tagged_typedef_enum2(:c5)).to be :c5
87
+ expect(TestEnum3.test_tagged_typedef_enum2(:c6)).to be :c6
88
+ expect(TestEnum3.test_tagged_typedef_enum2(:c7)).to be :c7
89
+ expect(TestEnum3.test_tagged_typedef_enum2(:c8)).to be :c8
90
+ expect(TestEnum3.test_tagged_typedef_enum3(:c9)).to be :c9
91
+ expect(TestEnum3.test_tagged_typedef_enum3(:c10)).to be :c10
92
+ expect(TestEnum3.test_tagged_typedef_enum3(:c11)).to be :c11
93
+ expect(TestEnum3.test_tagged_typedef_enum3(:c12)).to be :c12
94
+ expect(TestEnum3.test_tagged_typedef_enum4(:c13)).to be :c13
95
+ expect(TestEnum3.test_tagged_typedef_enum4(:c14)).to be :c14
96
+ expect(TestEnum3.test_tagged_typedef_enum4(:c15)).to be :c15
97
+ expect(TestEnum3.test_tagged_typedef_enum4(:c16)).to be :c16
97
98
  end
98
99
 
99
100
  it "integers can be used instead of constants" do
100
- TestEnum3.test_tagged_typedef_enum1(0).should == :c1
101
- TestEnum3.test_tagged_typedef_enum1(1).should == :c2
102
- TestEnum3.test_tagged_typedef_enum1(2).should == :c3
103
- TestEnum3.test_tagged_typedef_enum1(3).should == :c4
104
- TestEnum3.test_tagged_typedef_enum2(42).should == :c5
105
- TestEnum3.test_tagged_typedef_enum2(43).should == :c6
106
- TestEnum3.test_tagged_typedef_enum2(44).should == :c7
107
- TestEnum3.test_tagged_typedef_enum2(45).should == :c8
108
- TestEnum3.test_tagged_typedef_enum3(42).should == :c9
109
- TestEnum3.test_tagged_typedef_enum3(43).should == :c10
110
- TestEnum3.test_tagged_typedef_enum3(4242).should == :c11
111
- TestEnum3.test_tagged_typedef_enum3(4243).should == :c12
112
- TestEnum3.test_tagged_typedef_enum4(42).should == :c13
113
- TestEnum3.test_tagged_typedef_enum4(4242).should == :c14
114
- TestEnum3.test_tagged_typedef_enum4(424242).should == :c15
115
- TestEnum3.test_tagged_typedef_enum4(42424242).should == :c16
101
+ expect(TestEnum3.test_tagged_typedef_enum1(0)).to be :c1
102
+ expect(TestEnum3.test_tagged_typedef_enum1(1)).to be :c2
103
+ expect(TestEnum3.test_tagged_typedef_enum1(2)).to be :c3
104
+ expect(TestEnum3.test_tagged_typedef_enum1(3)).to be :c4
105
+ expect(TestEnum3.test_tagged_typedef_enum2(42)).to be :c5
106
+ expect(TestEnum3.test_tagged_typedef_enum2(43)).to be :c6
107
+ expect(TestEnum3.test_tagged_typedef_enum2(44)).to be :c7
108
+ expect(TestEnum3.test_tagged_typedef_enum2(45)).to be :c8
109
+ expect(TestEnum3.test_tagged_typedef_enum3(42)).to be :c9
110
+ expect(TestEnum3.test_tagged_typedef_enum3(43)).to be :c10
111
+ expect(TestEnum3.test_tagged_typedef_enum3(4242)).to be :c11
112
+ expect(TestEnum3.test_tagged_typedef_enum3(4243)).to be :c12
113
+ expect(TestEnum3.test_tagged_typedef_enum4(42)).to be :c13
114
+ expect(TestEnum3.test_tagged_typedef_enum4(4242)).to be :c14
115
+ expect(TestEnum3.test_tagged_typedef_enum4(424242)).to be :c15
116
+ expect(TestEnum3.test_tagged_typedef_enum4(42424242)).to be :c16
116
117
  end
117
118
  end
118
119
 
119
120
  describe "All enums" do
120
121
  it "have autonumbered constants when defined with names only" do
121
- TestEnum1.enum_value(:c1).should == 0
122
- TestEnum1.enum_value(:c2).should == 1
123
- TestEnum1.enum_value(:c3).should == 2
124
- TestEnum1.enum_value(:c4).should == 3
125
-
126
- TestEnum3.enum_value(:c1).should == 0
127
- TestEnum3.enum_value(:c2).should == 1
128
- TestEnum3.enum_value(:c3).should == 2
129
- TestEnum3.enum_value(:c4).should == 3
122
+ expect(TestEnum1.enum_value(:c1)).to eq(0)
123
+ expect(TestEnum1.enum_value(:c2)).to eq(1)
124
+ expect(TestEnum1.enum_value(:c3)).to eq(2)
125
+ expect(TestEnum1.enum_value(:c4)).to eq(3)
126
+
127
+ expect(TestEnum3.enum_value(:c1)).to eq(0)
128
+ expect(TestEnum3.enum_value(:c2)).to eq(1)
129
+ expect(TestEnum3.enum_value(:c3)).to eq(2)
130
+ expect(TestEnum3.enum_value(:c4)).to eq(3)
130
131
  end
132
+
131
133
  it "can have an explicit first constant and autonumbered subsequent constants" do
132
- TestEnum1.enum_value(:c5).should == 42
133
- TestEnum1.enum_value(:c6).should == 43
134
- TestEnum1.enum_value(:c7).should == 44
135
- TestEnum1.enum_value(:c8).should == 45
136
-
137
- TestEnum3.enum_value(:c5).should == 42
138
- TestEnum3.enum_value(:c6).should == 43
139
- TestEnum3.enum_value(:c7).should == 44
140
- TestEnum3.enum_value(:c8).should == 45
134
+ expect(TestEnum1.enum_value(:c5)).to eq(42)
135
+ expect(TestEnum1.enum_value(:c6)).to eq(43)
136
+ expect(TestEnum1.enum_value(:c7)).to eq(44)
137
+ expect(TestEnum1.enum_value(:c8)).to eq(45)
138
+
139
+ expect(TestEnum3.enum_value(:c5)).to eq(42)
140
+ expect(TestEnum3.enum_value(:c6)).to eq(43)
141
+ expect(TestEnum3.enum_value(:c7)).to eq(44)
142
+ expect(TestEnum3.enum_value(:c8)).to eq(45)
141
143
  end
144
+
142
145
  it "can have a mix of explicit and autonumbered constants" do
143
- TestEnum1.enum_value(:c9).should == 42
144
- TestEnum1.enum_value(:c10).should == 43
145
- TestEnum1.enum_value(:c11).should == 4242
146
- TestEnum1.enum_value(:c12).should == 4243
147
-
148
- TestEnum3.enum_value(:c9).should == 42
149
- TestEnum3.enum_value(:c10).should == 43
150
- TestEnum3.enum_value(:c11).should == 4242
151
- TestEnum3.enum_value(:c12).should == 4243
146
+ expect(TestEnum1.enum_value(:c9)).to eq(42)
147
+ expect(TestEnum1.enum_value(:c10)).to eq(43)
148
+ expect(TestEnum1.enum_value(:c11)).to eq(4242)
149
+ expect(TestEnum1.enum_value(:c12)).to eq(4243)
150
+
151
+ expect(TestEnum3.enum_value(:c9)).to eq(42)
152
+ expect(TestEnum3.enum_value(:c10)).to eq(43)
153
+ expect(TestEnum3.enum_value(:c11)).to eq(4242)
154
+ expect(TestEnum3.enum_value(:c12)).to eq(4243)
152
155
  end
156
+
153
157
  it "can have all its constants explicitely valued" do
154
- TestEnum1.enum_value(:c13).should == 42
155
- TestEnum1.enum_value(:c14).should == 4242
156
- TestEnum1.enum_value(:c15).should == 424242
157
- TestEnum1.enum_value(:c16).should == 42424242
158
+ expect(TestEnum1.enum_value(:c13)).to eq(42)
159
+ expect(TestEnum1.enum_value(:c14)).to eq(4242)
160
+ expect(TestEnum1.enum_value(:c15)).to eq(424242)
161
+ expect(TestEnum1.enum_value(:c16)).to eq(42424242)
158
162
 
159
- TestEnum3.enum_value(:c13).should == 42
160
- TestEnum3.enum_value(:c14).should == 4242
161
- TestEnum3.enum_value(:c15).should == 424242
162
- TestEnum3.enum_value(:c16).should == 42424242
163
+ expect(TestEnum3.enum_value(:c13)).to eq(42)
164
+ expect(TestEnum3.enum_value(:c14)).to eq(4242)
165
+ expect(TestEnum3.enum_value(:c15)).to eq(424242)
166
+ expect(TestEnum3.enum_value(:c16)).to eq(42424242)
163
167
  end
168
+
164
169
  it "return the constant corresponding to a specific value" do
165
170
  enum = TestEnum3.enum_type(:enum_type1)
166
- enum[0].should == :c1
167
- enum[1].should == :c2
168
- enum[2].should == :c3
169
- enum[3].should == :c4
171
+ expect(enum[0]).to be :c1
172
+ expect(enum[1]).to be :c2
173
+ expect(enum[2]).to be :c3
174
+ expect(enum[3]).to be :c4
170
175
 
171
176
  enum = TestEnum3.enum_type(:enum_type2)
172
- enum[42].should == :c5
173
- enum[43].should == :c6
174
- enum[44].should == :c7
175
- enum[45].should == :c8
177
+ expect(enum[42]).to be :c5
178
+ expect(enum[43]).to be :c6
179
+ expect(enum[44]).to be :c7
180
+ expect(enum[45]).to be :c8
176
181
 
177
182
  enum = TestEnum3.enum_type(:enum_type3)
178
- enum[42].should == :c9
179
- enum[43].should == :c10
180
- enum[4242].should == :c11
181
- enum[4243].should == :c12
183
+ expect(enum[42]).to be :c9
184
+ expect(enum[43]).to be :c10
185
+ expect(enum[4242]).to be :c11
186
+ expect(enum[4243]).to be :c12
182
187
 
183
188
  enum = TestEnum3.enum_type(:enum_type4)
184
- enum[42].should == :c13
185
- enum[4242].should == :c14
186
- enum[424242].should == :c15
187
- enum[42424242].should == :c16
189
+ expect(enum[42]).to be :c13
190
+ expect(enum[4242]).to be :c14
191
+ expect(enum[424242]).to be :c15
192
+ expect(enum[42424242]).to be :c16
188
193
  end
194
+
189
195
  it "return nil for values that don't have a symbol" do
190
196
  enum = TestEnum3.enum_type(:enum_type1)
191
- enum[-1].should == nil
192
- enum[4].should == nil
197
+ expect(enum[-1]).to be_nil
198
+ expect(enum[4]).to be_nil
193
199
 
194
200
  enum = TestEnum3.enum_type(:enum_type2)
195
- enum[0].should == nil
196
- enum[41].should == nil
197
- enum[46].should == nil
201
+ expect(enum[0]).to be_nil
202
+ expect(enum[41]).to be_nil
203
+ expect(enum[46]).to be_nil
198
204
 
199
205
  enum = TestEnum3.enum_type(:enum_type3)
200
- enum[0].should == nil
201
- enum[41].should == nil
202
- enum[44].should == nil
203
- enum[4241].should == nil
204
- enum[4244].should == nil
206
+ expect(enum[0]).to be_nil
207
+ expect(enum[41]).to be_nil
208
+ expect(enum[44]).to be_nil
209
+ expect(enum[4241]).to be_nil
210
+ expect(enum[4244]).to be_nil
205
211
 
206
212
  enum = TestEnum3.enum_type(:enum_type4)
207
- enum[0].should == nil
208
- enum[41].should == nil
209
- enum[43].should == nil
210
- enum[4241].should == nil
211
- enum[4243].should == nil
212
- enum[424241].should == nil
213
- enum[424243].should == nil
214
- enum[42424241].should == nil
215
- enum[42424243].should == nil
213
+ expect(enum[0]).to be_nil
214
+ expect(enum[41]).to be_nil
215
+ expect(enum[43]).to be_nil
216
+ expect(enum[4241]).to be_nil
217
+ expect(enum[4243]).to be_nil
218
+ expect(enum[424241]).to be_nil
219
+ expect(enum[424243]).to be_nil
220
+ expect(enum[42424241]).to be_nil
221
+ expect(enum[42424243]).to be_nil
216
222
  end
217
223
 
218
224
  it "duplicate enum keys rejected" do
219
- lambda { enum [ :a, 0xfee1dead, :b, 0xdeadbeef, :a, 0 ] }.should raise_error
225
+ expect { enum [ :a, 0xfee1dead, :b, 0xdeadbeef, :a, 0 ] }.to raise_error
220
226
  end
221
227
  end
@@ -4,7 +4,6 @@
4
4
  #
5
5
 
6
6
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
- require 'ffi'
8
7
 
9
8
  describe "FFI.errno" do
10
9
  module LibTest
@@ -12,9 +11,10 @@ describe "FFI.errno" do
12
11
  ffi_lib TestLibrary::PATH
13
12
  attach_function :setLastError, [ :int ], :void
14
13
  end
14
+
15
15
  it "FFI.errno contains errno from last function" do
16
16
  LibTest.setLastError(0)
17
17
  LibTest.setLastError(0x12345678)
18
- FFI.errno.should == 0x12345678
18
+ expect(FFI.errno).to eq(0x12345678)
19
19
  end
20
20
  end