treequel 1.11.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/ChangeLog +135 -12
  5. data/{History.rdoc → History.md} +46 -34
  6. data/Manifest.txt +6 -5
  7. data/{README.rdoc → README.md} +58 -44
  8. data/Rakefile +40 -18
  9. data/examples/ldap-rack-auth.rb +1 -1
  10. data/examples/ldap_state.rb +5 -5
  11. data/lib/treequel.rb +10 -9
  12. data/lib/treequel/behavior/control.rb +7 -8
  13. data/lib/treequel/branch.rb +29 -28
  14. data/lib/treequel/branchcollection.rb +8 -7
  15. data/lib/treequel/branchset.rb +22 -21
  16. data/lib/treequel/constants.rb +23 -24
  17. data/lib/treequel/control.rb +15 -15
  18. data/lib/treequel/controls/contentsync.rb +17 -16
  19. data/lib/treequel/controls/pagedresults.rb +13 -12
  20. data/lib/treequel/controls/sortedresults.rb +11 -10
  21. data/lib/treequel/directory.rb +35 -34
  22. data/lib/treequel/exceptions.rb +2 -1
  23. data/lib/treequel/filter.rb +10 -9
  24. data/lib/treequel/mixins.rb +4 -4
  25. data/lib/treequel/model.rb +23 -13
  26. data/lib/treequel/model/errors.rb +10 -9
  27. data/lib/treequel/model/objectclass.rb +9 -8
  28. data/lib/treequel/model/schemavalidations.rb +5 -4
  29. data/lib/treequel/monkeypatches.rb +5 -4
  30. data/lib/treequel/schema.rb +19 -18
  31. data/lib/treequel/schema/attributetype.rb +9 -8
  32. data/lib/treequel/schema/ldapsyntax.rb +2 -1
  33. data/lib/treequel/schema/matchingrule.rb +2 -1
  34. data/lib/treequel/schema/matchingruleuse.rb +2 -1
  35. data/lib/treequel/schema/objectclass.rb +23 -22
  36. data/lib/treequel/schema/table.rb +3 -2
  37. data/lib/treequel/sequel_integration.rb +2 -1
  38. data/lib/treequel/utils.rb +183 -0
  39. data/misc/ruby-ldap-controlsfix.patch +50 -0
  40. data/spec/{lib/constants.rb → spec_constants.rb} +7 -6
  41. data/spec/{lib/helpers.rb → spec_helpers.rb} +31 -53
  42. data/spec/treequel/branch_spec.rb +196 -223
  43. data/spec/treequel/branchcollection_spec.rb +73 -113
  44. data/spec/treequel/branchset_spec.rb +102 -161
  45. data/spec/treequel/control_spec.rb +5 -21
  46. data/spec/treequel/controls/contentsync_spec.rb +3 -17
  47. data/spec/treequel/controls/pagedresults_spec.rb +40 -62
  48. data/spec/treequel/controls/sortedresults_spec.rb +37 -59
  49. data/spec/treequel/directory_spec.rb +171 -190
  50. data/spec/treequel/filter_spec.rb +106 -131
  51. data/spec/treequel/mixins_spec.rb +47 -81
  52. data/spec/treequel/model/errors_spec.rb +11 -35
  53. data/spec/treequel/model/objectclass_spec.rb +99 -131
  54. data/spec/treequel/model/schemavalidations_spec.rb +36 -60
  55. data/spec/treequel/model_spec.rb +164 -167
  56. data/spec/treequel/monkeypatches_spec.rb +20 -41
  57. data/spec/treequel/schema/attributetype_spec.rb +84 -107
  58. data/spec/treequel/schema/ldapsyntax_spec.rb +10 -36
  59. data/spec/treequel/schema/matchingrule_spec.rb +23 -47
  60. data/spec/treequel/schema/matchingruleuse_spec.rb +18 -42
  61. data/spec/treequel/schema/objectclass_spec.rb +73 -94
  62. data/spec/treequel/schema/table_spec.rb +58 -86
  63. data/spec/treequel/schema_spec.rb +47 -59
  64. data/spec/treequel_spec.rb +131 -156
  65. metadata +68 -42
  66. metadata.gz.sig +0 -0
  67. data/spec/lib/matchers.rb +0 -55
@@ -1,19 +1,8 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
2
3
 
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
4
+ require_relative '../../spec_helpers'
6
5
 
7
- libdir = basedir + "lib"
8
-
9
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
- $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
11
- }
12
-
13
- require 'rspec'
14
-
15
- require 'spec/lib/constants'
16
- require 'spec/lib/helpers'
17
6
 
18
7
  require 'yaml'
19
8
  require 'ldap'
@@ -21,126 +10,109 @@ require 'ldap/schema'
21
10
  require 'treequel/schema'
22
11
 
23
12
 
24
- include Treequel::TestConstants
25
- include Treequel::Constants
26
-
27
- #####################################################################
28
- ### C O N T E X T S
29
- #####################################################################
30
-
31
13
  describe Treequel::Schema::Table do
32
14
  include Treequel::SpecHelpers
33
15
 
34
16
 
35
- before( :all ) do
36
- setup_logging( :fatal )
37
- end
38
-
39
- before( :each ) do
40
- @table = Treequel::Schema::Table.new
41
- end
42
-
43
- after( :all ) do
44
- reset_logging()
45
- end
17
+ let( :table ) { described_class.new }
46
18
 
47
19
 
48
20
  it "allows setting/fetching case-insensitively" do
49
- @table['organizationalRole'] = :or
50
- @table["apple-preset-computer-list"] = :applepreset
51
- @table.deltaCRL = :deltacrl
52
-
53
- @table['organizationalrole'].should == :or
54
- @table[:organizationalrole].should == :or
55
- @table.organizationalRole.should == :or
56
- @table.organizationalrole.should == :or
57
-
58
- @table[:"apple-preset-computer-list"].should == :applepreset
59
- @table['apple-preset-computer-list'].should == :applepreset
60
- @table[:apple_preset_computer_list].should == :applepreset
61
- @table.apple_preset_computer_list.should == :applepreset
62
-
63
- @table['deltacrl'].should == :deltacrl
64
- @table[:deltaCRL].should == :deltacrl
65
- @table[:deltacrl].should == :deltacrl
66
- @table.deltaCRL.should == :deltacrl
67
- @table.deltacrl.should == :deltacrl
21
+ table['organizationalRole'] = :or
22
+ table["apple-preset-computer-list"] = :applepreset
23
+ table.deltaCRL = :deltacrl
24
+
25
+ expect( table['organizationalrole'] ).to eq( :or )
26
+ expect( table[:organizationalrole] ).to eq( :or )
27
+ expect( table.organizationalRole ).to eq( :or )
28
+ expect( table.organizationalrole ).to eq( :or )
29
+
30
+ expect( table[:"apple-preset-computer-list"] ).to eq( :applepreset )
31
+ expect( table['apple-preset-computer-list'] ).to eq( :applepreset )
32
+ expect( table[:apple_preset_computer_list] ).to eq( :applepreset )
33
+ expect( table.apple_preset_computer_list ).to eq( :applepreset )
34
+
35
+ expect( table['deltacrl'] ).to eq( :deltacrl )
36
+ expect( table[:deltaCRL] ).to eq( :deltacrl )
37
+ expect( table[:deltacrl] ).to eq( :deltacrl )
38
+ expect( table.deltaCRL ).to eq( :deltacrl )
39
+ expect( table.deltacrl ).to eq( :deltacrl )
68
40
 
69
41
  end
70
42
 
71
43
 
72
44
  it "doesn't try to normalize numeric OIDs" do
73
- @table['1.3.6.1.4.1.4203.666.11.1.4.2.1.2'] = :an_oid
74
- @table['1.3.6.1.4.1.4203.666.11.1.4.2.1.2'].should == :an_oid
75
- @table['13614142036661114212'].should_not == :an_oid
76
- @table.keys.should include( '1.3.6.1.4.1.4203.666.11.1.4.2.1.2' )
45
+ table['1.3.6.1.4.1.4203.666.11.1.4.2.1.2'] = :an_oid
46
+ expect( table['1.3.6.1.4.1.4203.666.11.1.4.2.1.2'] ).to eq( :an_oid )
47
+ expect( table['13614142036661114212'] ).to_not eq( :an_oid )
48
+ expect( table.keys ).to include( '1.3.6.1.4.1.4203.666.11.1.4.2.1.2' )
77
49
  end
78
50
 
79
51
 
80
52
  it "merges other Tables" do
81
53
  othertable = Treequel::Schema::Table.new
82
54
 
83
- @table['ou'] = 'thing'
84
- @table['cn'] = 'chunker'
55
+ table['ou'] = 'thing'
56
+ table['cn'] = 'chunker'
85
57
 
86
58
  othertable['cn'] = 'phunker'
87
59
 
88
- ot = @table.merge( othertable )
89
- ot['ou'].should == 'thing'
90
- ot['cn'].should == 'phunker'
60
+ ot = table.merge( othertable )
61
+ expect( ot['ou'] ).to eq( 'thing' )
62
+ expect( ot['cn'] ).to eq( 'phunker' )
91
63
  end
92
64
 
93
65
 
94
66
  it "merges hashes after normalizing keys" do
95
- @table['ou'] = 'thing'
96
- @table['apple-computer-list'] = 'trishtrash'
67
+ table['ou'] = 'thing'
68
+ table['apple-computer-list'] = 'trishtrash'
97
69
 
98
70
  hash = { 'apple-computer-list' => 'pinhash' }
99
71
 
100
- ot = @table.merge( hash )
101
- ot['ou'].should == 'thing'
102
- ot['apple-computer-list'].should == 'pinhash'
72
+ ot = table.merge( hash )
73
+ expect( ot['ou'] ).to eq( 'thing' )
74
+ expect( ot['apple-computer-list'] ).to eq( 'pinhash' )
103
75
  end
104
76
 
105
77
 
106
78
  it "dupes its inner hash when duped" do
107
- newtable = @table.dup
79
+ newtable = table.dup
108
80
 
109
81
  newtable[:cn] = 'god'
110
- @table.should_not include( :cn )
111
- @table.should be_empty()
82
+ expect( table ).to_not include( :cn )
83
+ expect( table ).to be_empty()
112
84
  end
113
85
 
114
86
 
115
87
  it "provides a case-insensitive version of #values_at" do
116
- @table[:cn] = 'contra_rules'
117
- @table[:d] = 'ghosty'
118
- @table[:porntipsGuzzardo] = 'cha-ching'
119
-
120
- results = @table.values_at( :CN, 'PornTipsGuzzARDO' )
121
- results.should include( 'contra_rules' )
122
- results.should include( 'cha-ching' )
123
- results.should_not include( 'ghosty' )
88
+ table[:cn] = 'contra_rules'
89
+ table[:d] = 'ghosty'
90
+ table[:porntipsGuzzardo] = 'cha-ching'
91
+
92
+ results = table.values_at( :CN, 'PornTipsGuzzARDO' )
93
+ expect( results ).to include( 'contra_rules' )
94
+ expect( results ).to include( 'cha-ching' )
95
+ expect( results ).to_not include( 'ghosty' )
124
96
  end
125
97
 
126
98
  it "can iterate over its members" do
127
- @table[:cn] = 'contra_rules'
128
- @table[:d] = 'ghosty'
129
- @table[:porntipsGuzzardo] = 'cha-ching'
99
+ table[:cn] = 'contra_rules'
100
+ table[:d] = 'ghosty'
101
+ table[:porntipsGuzzardo] = 'cha-ching'
130
102
 
131
103
  collection = []
132
- @table.each {|k,v| collection << [k,v] }
133
- collection.transpose[0].should include( :cn, :d, :porntipsguzzardo )
134
- collection.transpose[1].should include( 'contra_rules', 'ghosty', 'cha-ching' )
104
+ table.each {|k,v| collection << [k,v] }
105
+ expect( collection.transpose[0] ).to include( :cn, :d, :porntipsguzzardo )
106
+ expect( collection.transpose[1] ).to include( 'contra_rules', 'ghosty', 'cha-ching' )
135
107
  end
136
108
 
137
109
  it "is Enumerable" do
138
- @table[:cn] = 'contra_rules'
139
- @table[:d] = 'ghosty'
140
- @table[:porntipsGuzzardo] = 'cha-ching'
110
+ table[:cn] = 'contra_rules'
111
+ table[:d] = 'ghosty'
112
+ table[:porntipsGuzzardo] = 'cha-ching'
141
113
 
142
114
  collection = []
143
- @table.any? {|k,v| v.index('o') }.should == true
115
+ expect( table.any? {|k,v| v.index('o') } ).to eq( true )
144
116
  end
145
117
 
146
118
  end
@@ -1,18 +1,8 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
2
3
 
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
4
+ require_relative '../spec_helpers'
6
5
 
7
- libdir = basedir + "lib"
8
-
9
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
- $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
11
- }
12
-
13
- require 'rspec'
14
-
15
- require 'spec/lib/helpers'
16
6
 
17
7
  require 'yaml'
18
8
  require 'ldap'
@@ -24,7 +14,6 @@ describe Treequel::Schema do
24
14
  include Treequel::SpecHelpers
25
15
 
26
16
  before( :all ) do
27
- setup_logging( :warn )
28
17
  @datadir = Pathname( __FILE__ ).dirname.parent + 'data'
29
18
  end
30
19
 
@@ -36,10 +25,6 @@ describe Treequel::Schema do
36
25
  Treequel::Schema.strict_parse_mode = @strict_flag
37
26
  end
38
27
 
39
- after( :all ) do
40
- reset_logging()
41
- end
42
-
43
28
  ### Constants
44
29
 
45
30
  # Some simple parser-testing values
@@ -67,23 +52,23 @@ describe Treequel::Schema do
67
52
  ### Examples
68
53
 
69
54
  it "defaults to lenient schema-parsing" do
70
- Treequel::Schema.should be_lenient()
55
+ expect( Treequel::Schema ).to be_lenient()
71
56
  end
72
57
 
73
58
  it "can be told to propagate schema-parsing failures for easier problem-detection" do
74
59
  Treequel::Schema.strict_parse_mode = true
75
- Treequel::Schema.should_not be_lenient()
60
+ expect( Treequel::Schema ).to_not be_lenient()
76
61
  end
77
62
 
78
63
 
79
64
  it "doesn't propagate parse errors while in lenient schema-parsing mode" do
80
65
  schema = Treequel::Schema.new( 'objectClasses' => [BAD_OBJECTCLASS],
81
- 'attributeTypes' => [],
82
- 'ldapSyntaxes' => [],
83
- 'matchingRules' => [],
66
+ 'attributeTypes' => [],
67
+ 'ldapSyntaxes' => [],
68
+ 'matchingRules' => [],
84
69
  'matchingRuleUse' => [] )
85
- schema.should be_a( Treequel::Schema )
86
- schema.object_classes.keys.should_not include( 'slpService' )
70
+ expect( schema ).to be_a( Treequel::Schema )
71
+ expect( schema.object_classes.keys ).to_not include( 'slpService' )
87
72
  end
88
73
 
89
74
  it "propagates parse errors while in strict schema-parsing mode" do
@@ -95,12 +80,12 @@ describe Treequel::Schema do
95
80
 
96
81
  it "can parse a valid oidlist" do
97
82
  oids = Treequel::Schema.parse_oids( TEST_OIDLIST )
98
- oids.should have(3).members
99
- oids.should == [ :objectClass, :objectCaste, TEST_NUMERICOID ]
83
+ expect( oids.length ).to eq( 3 )
84
+ expect( oids ).to eq( [ :objectClass, :objectCaste, TEST_NUMERICOID ] )
100
85
  end
101
86
 
102
87
  it "returns an empty Array if oidlist it's asked to parse is nil" do
103
- Treequel::Schema.parse_oids( nil ).should == []
88
+ expect( Treequel::Schema.parse_oids( nil ) ).to eq( [] )
104
89
  end
105
90
 
106
91
  it "raises an exception if it's asked to parse an invalid oidlist" do
@@ -111,13 +96,13 @@ describe Treequel::Schema do
111
96
 
112
97
 
113
98
  it "keeps a numeric OID as a String when parsing it" do
114
- Treequel::Schema.parse_oid( TEST_NUMERICOID ).should be_a( String )
115
- Treequel::Schema.parse_oid( TEST_NUMERICOID ).should == TEST_NUMERICOID
99
+ expect( Treequel::Schema.parse_oid( TEST_NUMERICOID ) ).to be_a( String )
100
+ expect( Treequel::Schema.parse_oid( TEST_NUMERICOID ) ).to eq( TEST_NUMERICOID )
116
101
  end
117
102
 
118
103
  it "transforms a named OID as a Symbol when parsing it" do
119
- Treequel::Schema.parse_oid( TEST_DESCR ).should be_a( Symbol )
120
- Treequel::Schema.parse_oid( TEST_DESCR ).should == TEST_DESCR.to_sym
104
+ expect( Treequel::Schema.parse_oid( TEST_DESCR ) ).to be_a( Symbol )
105
+ expect( Treequel::Schema.parse_oid( TEST_DESCR ) ).to eq( TEST_DESCR.to_sym )
121
106
  end
122
107
 
123
108
 
@@ -132,11 +117,11 @@ describe Treequel::Schema do
132
117
  end
133
118
 
134
119
  it "can parse the schema structure returned from LDAP::Conn#schema" do
135
- @schema.object_classes.values.uniq.should have( @hash['objectClasses'].length ).members
136
- @schema.attribute_types.values.uniq.should have( @hash['attributeTypes'].length ).members
137
- @schema.matching_rules.values.uniq.should have( @hash['matchingRules'].length ).members
138
- @schema.matching_rule_uses.values.uniq.should have( @hash['matchingRuleUse'].length ).members
139
- @schema.ldap_syntaxes.values.uniq.should have( @hash['ldapSyntaxes'].length ).members
120
+ expect( @schema.object_classes.values.uniq.length ).to eq( @hash['objectClasses'].length )
121
+ expect( @schema.attribute_types.values.uniq.length ).to eq( @hash['attributeTypes'].length )
122
+ expect( @schema.matching_rules.values.uniq.length ).to eq( @hash['matchingRules'].length )
123
+ expect( @schema.matching_rule_uses.values.uniq.length ).to eq( @hash['matchingRuleUse'].length )
124
+ expect( @schema.ldap_syntaxes.values.uniq.length ).to eq( @hash['ldapSyntaxes'].length )
140
125
 
141
126
  dirop_count = @hash['attributeTypes'].
142
127
  count {|type| type.index('USAGE directoryOperation') }
@@ -146,7 +131,7 @@ describe Treequel::Schema do
146
131
  count {|type| type.index('USAGE distributedOperation') }
147
132
  op_attrcount = dirop_count + dsaop_count + distop_count
148
133
 
149
- @schema.operational_attribute_types.should have( op_attrcount ).members
134
+ expect( @schema.operational_attribute_types.length ).to eq( op_attrcount )
150
135
  end
151
136
 
152
137
 
@@ -160,7 +145,7 @@ describe Treequel::Schema do
160
145
  schema = Treequel::Schema.new( schemahash )
161
146
  end.join
162
147
 
163
- schema.should be_an_instance_of( Treequel::Schema )
148
+ expect( schema ).to be_an_instance_of( Treequel::Schema )
164
149
  end
165
150
  end
166
151
 
@@ -174,14 +159,14 @@ describe Treequel::Schema do
174
159
  end
175
160
 
176
161
  it "can parse an ActiveDirectory schema structure, too" do
177
- @schema.object_classes.values.uniq.should have( @hash['objectClasses'].length ).members
178
- @schema.attribute_types.values.uniq.should have( @hash['attributeTypes'].length ).members
162
+ expect( @schema.object_classes.values.uniq.length ).to eq( @hash['objectClasses'].length )
163
+ expect( @schema.attribute_types.values.uniq.length ).to eq( @hash['attributeTypes'].length )
179
164
 
180
165
  # AD doesn't have these in its subSchema
181
- @schema.matching_rules.should be_empty()
182
- @schema.matching_rule_uses.should be_empty()
183
- @schema.ldap_syntaxes.should be_empty()
184
- @schema.operational_attribute_types.should be_empty()
166
+ expect( @schema.matching_rules ).to be_empty()
167
+ expect( @schema.matching_rule_uses ).to be_empty()
168
+ expect( @schema.ldap_syntaxes ).to be_empty()
169
+ expect( @schema.operational_attribute_types ).to be_empty()
185
170
  end
186
171
 
187
172
  end
@@ -189,7 +174,7 @@ describe Treequel::Schema do
189
174
 
190
175
  # Dumped from an OpenDS 2.2 server with the included 'test data' -- dunno if that's
191
176
  # representative of schemas one would find in the wild, but it doesn't parse as-is
192
- # currently because of (at least) the objectClasses from RFCs 2696, 3112, 3712, and
177
+ # currently because of (at least) the objectClasses from RFCs 2696, 3112, 3712, and
193
178
  # draft-howard-rfc2307bi
194
179
  context "OpenDS schema" do
195
180
 
@@ -202,17 +187,20 @@ describe Treequel::Schema do
202
187
  it "can parse an OpenDS schema structure, too" do
203
188
  @schema = Treequel::Schema.new( @schemahash )
204
189
 
205
- @schema.object_classes.values.uniq.should have( @hash['objectClasses'].length ).members
206
- @schema.attribute_types.values.uniq.should have( @hash['attributeTypes'].length ).members
207
- @schema.matching_rules.values.uniq.should have( @hash['matchingRules'].length ).members
208
- @schema.ldap_syntaxes.values.uniq.should have( @hash['ldapSyntaxes'].length ).members
190
+ expect( @schema.object_classes.values.uniq.length ).to eq( @hash['objectClasses'].length )
191
+ expect( @schema.attribute_types.values.uniq.length ).to eq( @hash['attributeTypes'].length )
192
+ expect( @schema.matching_rules.values.uniq.length ).to eq( @hash['matchingRules'].length )
193
+ expect( @schema.ldap_syntaxes.values.uniq.length ).to eq( @hash['ldapSyntaxes'].length )
209
194
 
210
- @schema.matching_rule_uses.should be_empty()
195
+ expect( @schema.matching_rule_uses ).to be_empty()
211
196
 
212
- # Not yet supported
213
- # @schema.dit_structure_rules.values.uniq.should have( @hash['dITStructureRules'].length ).members
214
- # @schema.dit_content_rules.values.uniq.should have( @hash['dITContentRules'].length ).members
215
- # @schema.name_forms.values.uniq.should have( @hash['nameForms'].length ).members
197
+ # Not yet supported
198
+ # expect( @schema.dit_structure_rules.values.uniq.length ).
199
+ # to eq( @hash['dITStructureRules'].length )
200
+ # expect( @schema.dit_content_rules.values.uniq.length ).
201
+ # to eq( @hash['dITContentRules'].length )
202
+ # expect( @schema.name_forms.values.uniq.length ).
203
+ # to eq( @hash['nameForms'].length )
216
204
 
217
205
  dirop_count = @hash['attributeTypes'].
218
206
  count {|type| type.index('USAGE directoryOperation') }
@@ -222,7 +210,7 @@ describe Treequel::Schema do
222
210
  count {|type| type.index('USAGE distributedOperation') }
223
211
  op_attrcount = dirop_count + dsaop_count + distop_count
224
212
 
225
- @schema.operational_attribute_types.should have( op_attrcount ).members
213
+ expect( @schema.operational_attribute_types.length ).to eq( op_attrcount )
226
214
  end
227
215
 
228
216
  end
@@ -239,13 +227,13 @@ describe Treequel::Schema do
239
227
  end
240
228
 
241
229
  it "can parse schema artifacts from ticket 11" do
242
- @schema.attribute_types.values.uniq.should have( @hash['attributeTypes'].length ).members
243
- @schema.matching_rules.values.uniq.should have( @hash['matchingRules'].length ).members
230
+ expect( @schema.attribute_types.values.uniq.length ).to eq( @hash['attributeTypes'].length )
231
+ expect( @schema.matching_rules.values.uniq.length ).to eq( @hash['matchingRules'].length )
244
232
 
245
233
  dsaop_count = @hash['attributeTypes'].
246
234
  count {|type| type.index('USAGE dsaOperation') }
247
235
 
248
- @schema.operational_attribute_types.should have( dsaop_count ).members
236
+ expect( @schema.operational_attribute_types.length ).to eq( dsaop_count )
249
237
  end
250
238
 
251
239
  end
@@ -1,47 +1,21 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
2
3
 
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname.new( __FILE__ ).dirname.parent
6
-
7
- libdir = basedir + "lib"
8
-
9
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
- $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
11
- }
12
-
13
- require 'rspec'
14
-
15
- require 'spec/lib/constants'
16
- require 'spec/lib/helpers'
4
+ require_relative 'spec_helpers'
17
5
 
18
6
  require 'treequel'
19
7
  require 'treequel/directory'
20
8
 
21
- include Treequel::TestConstants
22
-
23
-
24
- #####################################################################
25
- ### C O N T E X T S
26
- #####################################################################
27
9
 
28
10
  describe Treequel do
29
11
  include Treequel::SpecHelpers
30
12
 
31
- before( :all ) do
32
- setup_logging( :fatal )
33
- end
34
-
35
- after( :all ) do
36
- reset_logging()
37
- end
38
-
39
13
  it "should know if its default logger is replaced" do
40
14
  begin
41
15
  Treequel.reset_logger
42
- Treequel.should be_using_default_logger
16
+ expect( Treequel ).to be_using_default_logger
43
17
  Treequel.logger = Logger.new( $stderr )
44
- Treequel.should_not be_using_default_logger
18
+ expect( Treequel ).to_not be_using_default_logger
45
19
  ensure
46
20
  Treequel.reset_logger
47
21
  end
@@ -49,65 +23,70 @@ describe Treequel do
49
23
 
50
24
 
51
25
  it "returns a version string if asked" do
52
- Treequel.version_string.should =~ /\w+ [\d.]+/
26
+ expect( Treequel.version_string ).to match( /\w+ [\d.]+/ )
53
27
  end
54
28
 
55
29
 
56
30
  it "returns a version string with a build number if asked" do
57
- Treequel.version_string(true).should =~ /\w+ [\d.]+ \(build [[:xdigit:]]+\)/
31
+ expect( Treequel.version_string(true) ).to match( /\w+ [\d.]+ \(build [[:xdigit:]]+\)/ )
58
32
  end
59
33
 
60
34
 
61
35
  it "provides a convenience method for creating directory objects" do
62
- Treequel::Directory.should_receive( :new ).and_return( :a_directory )
63
- Treequel.directory.should == :a_directory
36
+ expect( Treequel::Directory ).to receive( :new ).and_return( :a_directory )
37
+ expect( Treequel.directory ).to eq( :a_directory )
64
38
  end
65
39
 
66
40
  it "accepts an LDAP url as the argument to the directory convenience method" do
67
- Treequel::Directory.should_receive( :new ).
41
+ expect( Treequel::Directory ).to receive( :new ).
68
42
  with({ :host => 'ldap.example.com', :base_dn => 'dc=example,dc=com', :port => 389 }).
69
43
  and_return( :a_directory )
70
- Treequel.directory( 'ldap://ldap.example.com/dc=example,dc=com' ).should == :a_directory
44
+ expect( Treequel.directory( 'ldap://ldap.example.com/dc=example,dc=com' ) ).to eq( :a_directory )
71
45
  end
72
46
 
73
47
  it "raises an exception if #directory is called with a non-ldap URL" do
74
- lambda {
48
+ expect {
75
49
  Treequel.directory( 'http://example.com/' )
76
- }.should raise_error( ArgumentError, /ldap url/i )
50
+ }.to raise_error( ArgumentError, /ldap url/i )
77
51
  end
78
52
 
79
53
  it "accepts an options hash as the argument to the directory convenience method" do
80
54
  opts = { :host => 'ldap.example.com', :base_dn => 'dc=example,dc=com' }
81
- Treequel::Directory.should_receive( :new ).with( opts ).
55
+ expect( Treequel::Directory ).to receive( :new ).with( opts ).
82
56
  and_return( :a_directory )
83
- Treequel.directory( opts ).should == :a_directory
57
+ expect( Treequel.directory( opts ) ).to eq( :a_directory )
84
58
  end
85
59
 
86
60
  it "can build an options hash from an LDAP URL" do
87
- Treequel.make_options_from_uri( 'ldap://ldap.example.com/dc=example,dc=com' ).should ==
88
- { :host => 'ldap.example.com', :base_dn => 'dc=example,dc=com', :port => 389 }
61
+ expect( Treequel.make_options_from_uri('ldap://ldap.example.com/dc=example,dc=com') ).
62
+ to include( :host => 'ldap.example.com', :base_dn => 'dc=example,dc=com', :port => 389 )
89
63
  end
90
64
 
91
65
  it "can build an options hash from an LDAPS URL" do
92
- Treequel.make_options_from_uri( 'ldaps://ldap.example.com/dc=example,dc=com' ).should ==
93
- { :host => 'ldap.example.com', :base_dn => 'dc=example,dc=com', :port => 636, :connect_type => :ssl }
66
+ expect( Treequel.make_options_from_uri('ldaps://ldap.example.com/dc=example,dc=com') ).
67
+ to include(
68
+ :host => 'ldap.example.com',
69
+ :base_dn => 'dc=example,dc=com',
70
+ :port => 636,
71
+ :connect_type => :ssl
72
+ )
94
73
  end
95
74
 
96
75
  it "can build an options hash from an LDAP URL without a host" do
97
- Treequel.make_options_from_uri( 'ldap:///dc=example,dc=com' ).should ==
98
- { :base_dn => 'dc=example,dc=com', :port => 389 }
76
+ expect( Treequel.make_options_from_uri('ldap:///dc=example,dc=com') ).
77
+ to include( :base_dn => 'dc=example,dc=com', :port => 389 )
99
78
  end
100
79
 
101
80
  it "uses the LDAPS port for ldaps:// URIs" do
102
- Treequel.make_options_from_uri( 'ldaps:///dc=example,dc=com' ).should ==
103
- { :base_dn => 'dc=example,dc=com', :connect_type => :ssl, :port => 636 }
81
+ expect( Treequel.make_options_from_uri('ldaps:///dc=example,dc=com') ).
82
+ to include( :base_dn => 'dc=example,dc=com', :connect_type => :ssl, :port => 636 )
104
83
  end
105
84
 
106
85
  # [?<attrs>[?<scope>[?<filter>[?<extensions>]]]]
107
86
  it "can build an options hash from an LDAP URL with extra stuff" do
108
87
  uri = 'ldap:///dc=example,dc=com?uid=jrandom,ou=People?l?one?!bindname=cn=auth'
109
- Treequel.make_options_from_uri( uri ).should ==
110
- { :base_dn => 'dc=example,dc=com', :port => 389 }
88
+ expect( Treequel.make_options_from_uri( uri ) ).
89
+ to include( :base_dn => 'dc=example,dc=com', :port => 389 )
111
90
  end
112
91
 
113
92
  it "accepts a combination of URL and options hash as the argument to the directory " +
@@ -124,7 +103,7 @@ describe Treequel do
124
103
  :pass => pass,
125
104
  }
126
105
 
127
- Treequel::Directory.should_receive( :new ).
106
+ expect( Treequel::Directory ).to receive( :new ).
128
107
  with( options_hash ).
129
108
  and_return( :a_directory )
130
109
 
@@ -139,28 +118,24 @@ describe Treequel do
139
118
  end
140
119
 
141
120
  it "provides a convenience method for creating directory objects from the system LDAP config" do
142
- Treequel.should_receive( :find_configfile ).and_return( :a_configfile_path )
143
- Treequel.should_receive( :read_opts_from_config ).with( :a_configfile_path ).
121
+ expect( Treequel ).to receive( :find_configfile ).and_return( :a_configfile_path )
122
+ expect( Treequel ).to receive( :read_opts_from_config ).with( :a_configfile_path ).
144
123
  and_return({ :configfile_opts => 1 })
145
- Treequel.should_receive( :read_opts_from_environment ).
124
+ expect( Treequel ).to receive( :read_opts_from_environment ).
146
125
  and_return({ :environment_opts => 1 })
147
126
 
148
127
  merged_config = Treequel::Directory::DEFAULT_OPTIONS.
149
128
  merge({ :configfile_opts => 1, :environment_opts => 1 })
150
129
 
151
- Treequel::Directory.should_receive( :new ).with( merged_config ).
130
+ expect( Treequel::Directory ).to receive( :new ).with( merged_config ).
152
131
  and_return( :a_directory )
153
132
 
154
- Treequel.directory_from_config.should == :a_directory
133
+ expect( Treequel.directory_from_config ).to eq( :a_directory )
155
134
  end
156
135
 
157
136
 
158
137
  describe "system LDAP config methods" do
159
138
 
160
- before( :all ) do
161
- setup_logging( :fatal )
162
- end
163
-
164
139
  before( :each ) do
165
140
  ENV['LDAPCONF'] = nil
166
141
  ENV['LDAPRC'] = nil
@@ -176,23 +151,23 @@ describe Treequel do
176
151
  end
177
152
 
178
153
  it "uses the LDAPCONF environment variable if it is set" do
179
- configpath = mock( "configfile Pathname object" )
154
+ configpath = double( "configfile Pathname object" )
180
155
  ENV['LDAPCONF'] = 'a_configfile_path'
181
156
 
182
- Treequel.should_receive( :Pathname ).with( 'a_configfile_path' ).and_return( configpath )
183
- configpath.should_receive( :expand_path ).and_return( configpath )
184
- configpath.should_receive( :readable? ).and_return( true )
157
+ expect( Treequel ).to receive( :Pathname ).with( 'a_configfile_path' ).and_return( configpath )
158
+ expect( configpath ).to receive( :expand_path ).and_return( configpath )
159
+ expect( configpath ).to receive( :readable? ).and_return( true )
185
160
 
186
- Treequel.find_configfile.should == configpath
161
+ expect( Treequel.find_configfile ).to eq( configpath )
187
162
  end
188
163
 
189
164
  it "raises an exception if the file specified in LDAPCONF isn't readable" do
190
- configpath = mock( "configfile Pathname object" )
165
+ configpath = double( "configfile Pathname object" )
191
166
  ENV['LDAPCONF'] = 'a_configfile_path'
192
167
 
193
- Treequel.should_receive( :Pathname ).with( 'a_configfile_path' ).and_return( configpath )
194
- configpath.should_receive( :expand_path ).and_return( configpath )
195
- configpath.should_receive( :readable? ).and_return( false )
168
+ expect( Treequel ).to receive( :Pathname ).with( 'a_configfile_path' ).and_return( configpath )
169
+ expect( configpath ).to receive( :expand_path ).and_return( configpath )
170
+ expect( configpath ).to receive( :readable? ).and_return( false )
196
171
 
197
172
  expect {
198
173
  Treequel.find_configfile
@@ -200,46 +175,46 @@ describe Treequel do
200
175
  end
201
176
 
202
177
  it "uses the LDAPRC environment variable if it is set and LDAPCONF isn't" do
203
- configpath = mock( "configfile Pathname object" )
178
+ configpath = double( "configfile Pathname object" )
204
179
  ENV['LDAPRC'] = 'a_configfile_path'
205
180
 
206
- Treequel.should_receive( :Pathname ).with( 'a_configfile_path' ).and_return( configpath )
207
- configpath.should_receive( :expand_path ).and_return( configpath )
208
- configpath.should_receive( :readable? ).and_return( true )
181
+ expect( Treequel ).to receive( :Pathname ).with( 'a_configfile_path' ).and_return( configpath )
182
+ expect( configpath ).to receive( :expand_path ).and_return( configpath )
183
+ expect( configpath ).to receive( :readable? ).and_return( true )
209
184
 
210
- Treequel.find_configfile.should == configpath
185
+ expect( Treequel.find_configfile ).to eq( configpath )
211
186
  end
212
187
 
213
188
  it "looks in the current user's HOME for the LDAPRC file if it isn't in the CWD" do
214
- cwd_path = mock( "CWD configfile Pathname object" )
215
- homedir_path = mock( "HOME configfile Pathname object" )
189
+ cwd_path = double( "CWD configfile Pathname object" )
190
+ homedir_path = double( "HOME configfile Pathname object" )
216
191
  ENV['LDAPRC'] = 'a_configfile_path'
217
192
 
218
- Treequel.should_receive( :Pathname ).with( 'a_configfile_path' ).and_return( cwd_path )
219
- cwd_path.should_receive( :expand_path ).and_return( cwd_path )
220
- cwd_path.should_receive( :readable? ).and_return( false )
193
+ expect( Treequel ).to receive( :Pathname ).with( 'a_configfile_path' ).and_return( cwd_path )
194
+ expect( cwd_path ).to receive( :expand_path ).and_return( cwd_path )
195
+ expect( cwd_path ).to receive( :readable? ).and_return( false )
221
196
 
222
- Treequel.should_receive( :Pathname ).with( '~' ).and_return( homedir_path )
223
- homedir_path.should_receive( :expand_path ).and_return( homedir_path )
224
- homedir_path.should_receive( :+ ).with( 'a_configfile_path' ).and_return( homedir_path )
225
- homedir_path.should_receive( :readable? ).and_return( true )
197
+ expect( Treequel ).to receive( :Pathname ).with( '~' ).and_return( homedir_path )
198
+ expect( homedir_path ).to receive( :expand_path ).and_return( homedir_path )
199
+ expect( homedir_path ).to receive( :+ ).with( 'a_configfile_path' ).and_return( homedir_path )
200
+ expect( homedir_path ).to receive( :readable? ).and_return( true )
226
201
 
227
- Treequel.find_configfile.should == homedir_path
202
+ expect( Treequel.find_configfile ).to eq( homedir_path )
228
203
  end
229
204
 
230
205
  it "raises an exception if the file specified in LDAPRC isn't readable" do
231
- cwd_path = mock( "CWD configfile Pathname object" )
232
- homedir_path = mock( "HOME configfile Pathname object" )
206
+ cwd_path = double( "CWD configfile Pathname object" )
207
+ homedir_path = double( "HOME configfile Pathname object" )
233
208
  ENV['LDAPRC'] = 'a_configfile_path'
234
209
 
235
- Treequel.should_receive( :Pathname ).with( 'a_configfile_path' ).and_return( cwd_path )
236
- cwd_path.should_receive( :expand_path ).and_return( cwd_path )
237
- cwd_path.should_receive( :readable? ).and_return( false )
210
+ expect( Treequel ).to receive( :Pathname ).with( 'a_configfile_path' ).and_return( cwd_path )
211
+ expect( cwd_path ).to receive( :expand_path ).and_return( cwd_path )
212
+ expect( cwd_path ).to receive( :readable? ).and_return( false )
238
213
 
239
- Treequel.should_receive( :Pathname ).with( '~' ).and_return( homedir_path )
240
- homedir_path.should_receive( :expand_path ).and_return( homedir_path )
241
- homedir_path.should_receive( :+ ).with( 'a_configfile_path' ).and_return( homedir_path )
242
- homedir_path.should_receive( :readable? ).and_return( false )
214
+ expect( Treequel ).to receive( :Pathname ).with( '~' ).and_return( homedir_path )
215
+ expect( homedir_path ).to receive( :expand_path ).and_return( homedir_path )
216
+ expect( homedir_path ).to receive( :+ ).with( 'a_configfile_path' ).and_return( homedir_path )
217
+ expect( homedir_path ).to receive( :readable? ).and_return( false )
243
218
 
244
219
  expect {
245
220
  Treequel.find_configfile
@@ -250,127 +225,127 @@ describe Treequel do
250
225
  pathmocks = []
251
226
 
252
227
  Treequel::COMMON_LDAP_CONF_PATHS.each do |path|
253
- pathname = mock( "pathname: #{path}" )
228
+ pathname = double( "pathname: #{path}" )
254
229
  pathmocks << pathname
255
230
  end
256
- Treequel.should_receive( :Pathname ).and_return( *pathmocks )
231
+ expect( Treequel ).to receive( :Pathname ).and_return( *pathmocks )
257
232
 
258
233
  # Index of the entry we're going to pretend exists
259
234
  successful_index = 6
260
235
  0.upto( successful_index ) do |i|
261
- pathmocks[i].should_receive( :readable? ).and_return( i == successful_index )
236
+ expect( pathmocks[i] ).to receive( :readable? ).and_return( i == successful_index )
262
237
  end
263
238
 
264
- Treequel.find_configfile.should == pathmocks[ successful_index ]
239
+ expect( Treequel.find_configfile ).to eq( pathmocks[ successful_index ] )
265
240
  end
266
241
 
267
- #
242
+ #
268
243
  # OpenLDAP-style config
269
- #
244
+ #
270
245
 
271
246
  it "maps the OpenLDAP URI directive to equivalent options" do
272
- IO.should_receive( :foreach ).with( :a_configfile ).
247
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
273
248
  and_yield( "URI ldap://ldap.acme.com/dc=acme,dc=com" )
274
- Treequel.read_opts_from_config( :a_configfile ).should ==
275
- { :port => 389, :base_dn => "dc=acme,dc=com", :host => "ldap.acme.com" }
249
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
250
+ to include( :port => 389, :base_dn => "dc=acme,dc=com", :host => "ldap.acme.com" )
276
251
  end
277
252
 
278
253
  it "maps the OpenLDAP BASE directive to the base_dn option" do
279
- IO.should_receive( :foreach ).with( :a_configfile ).
254
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
280
255
  and_yield( "BASE dc=acme,dc=com" )
281
- Treequel.read_opts_from_config( :a_configfile ).should ==
282
- { :base_dn => "dc=acme,dc=com" }
256
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
257
+ to include( :base_dn => "dc=acme,dc=com" )
283
258
  end
284
259
 
285
260
  it "maps the OpenLDAP BINDDN directive to the bind_dn option" do
286
- IO.should_receive( :foreach ).with( :a_configfile ).
261
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
287
262
  and_yield( "BINDDN cn=admin,dc=acme,dc=com" )
288
- Treequel.read_opts_from_config( :a_configfile ).should ==
289
- { :bind_dn => "cn=admin,dc=acme,dc=com" }
263
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
264
+ to include( :bind_dn => "cn=admin,dc=acme,dc=com" )
290
265
  end
291
266
 
292
267
  it "maps the OpenLDAP HOST directive to the host option" do
293
- IO.should_receive( :foreach ).with( :a_configfile ).
268
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
294
269
  and_yield( "# Host file\nHOST ldap.acme.com\n\n" )
295
- Treequel.read_opts_from_config( :a_configfile ).should ==
296
- { :host => 'ldap.acme.com' }
270
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
271
+ to include( :host => 'ldap.acme.com' )
297
272
  end
298
273
 
299
274
  it "maps the OpenLDAP PORT directive to the port option" do
300
- IO.should_receive( :foreach ).with( :a_configfile ).
275
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
301
276
  and_yield( "PORT 389" )
302
- Treequel.read_opts_from_config( :a_configfile ).should ==
303
- { :port => 389 }
277
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
278
+ to include( :port => 389 )
304
279
  end
305
280
 
306
- #
281
+ #
307
282
  # NSS-style config
308
- #
283
+ #
309
284
 
310
285
  it "maps the nss-style uri directive to equivalent options" do
311
- IO.should_receive( :foreach ).with( :a_configfile ).
286
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
312
287
  and_yield( "uri ldap://ldap.acme.com/dc=acme,dc=com" )
313
- Treequel.read_opts_from_config( :a_configfile ).should ==
314
- { :port => 389, :base_dn => "dc=acme,dc=com", :host => "ldap.acme.com" }
288
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
289
+ to include( :port => 389, :base_dn => "dc=acme,dc=com", :host => "ldap.acme.com" )
315
290
  end
316
291
 
317
292
  it "maps the nss-style 'host' option correctly" do
318
- IO.should_receive( :foreach ).with( :a_configfile ).
293
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
319
294
  and_yield( "host ldap.acme.com\n\n" )
320
- Treequel.read_opts_from_config( :a_configfile ).should ==
321
- { :host => 'ldap.acme.com' }
295
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
296
+ to include( :host => 'ldap.acme.com' )
322
297
  end
323
298
 
324
299
  it "maps the nss-style 'binddn' option correctly" do
325
- IO.should_receive( :foreach ).with( :a_configfile ).
300
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
326
301
  and_yield( "binddn cn=superuser,dc=acme,dc=com" )
327
- Treequel.read_opts_from_config( :a_configfile ).should ==
328
- { :bind_dn => "cn=superuser,dc=acme,dc=com" }
302
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
303
+ to eq( :bind_dn => "cn=superuser,dc=acme,dc=com" )
329
304
  end
330
305
 
331
306
  it "maps the nss-style 'bindpw' option correctly" do
332
- IO.should_receive( :foreach ).with( :a_configfile ).
307
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
333
308
  and_yield( "# My totally awesome password" ).
334
309
  and_yield( "bindpw a:password!" )
335
- Treequel.read_opts_from_config( :a_configfile ).should ==
336
- { :pass => "a:password!" }
310
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
311
+ to eq( :pass => "a:password!" )
337
312
  end
338
313
 
339
314
  it "maps the nss-style 'base' option correctly" do
340
- IO.should_receive( :foreach ).with( :a_configfile ).
315
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
341
316
  and_yield( "base dc=acme,dc=com" )
342
- Treequel.read_opts_from_config( :a_configfile ).should ==
343
- { :base_dn => "dc=acme,dc=com" }
317
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
318
+ to eq( :base_dn => "dc=acme,dc=com" )
344
319
  end
345
320
 
346
321
  it "maps the nss-style 'ssl' option to the correct port and connect_type if it's 'off'" do
347
- IO.should_receive( :foreach ).with( :a_configfile ).
322
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
348
323
  and_yield( "ssl off" )
349
- Treequel.read_opts_from_config( :a_configfile ).should ==
350
- { :port => 389, :connect_type => :plain }
324
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
325
+ to eq( :port => 389, :connect_type => :plain )
351
326
  end
352
327
 
353
328
  it "maps the nss-style 'ssl' option to the correct port and connect_type if " +
354
329
  "it's 'start_tls'" do
355
- IO.should_receive( :foreach ).with( :a_configfile ).
330
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
356
331
  and_yield( '' ).
357
332
  and_yield( '# Use TLS' ).
358
333
  and_yield( 'ssl start_tls' )
359
- Treequel.read_opts_from_config( :a_configfile ).should ==
360
- { :port => 389, :connect_type => :tls }
334
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
335
+ to eq( :port => 389, :connect_type => :tls )
361
336
  end
362
337
 
363
338
  it "maps the nss-style 'ssl' option to the correct port and connect_type if " +
364
339
  "it's 'on'" do
365
- IO.should_receive( :foreach ).with( :a_configfile ).
340
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
366
341
  and_yield( "\n# Use plain SSL\nssl on\n" )
367
- Treequel.read_opts_from_config( :a_configfile ).should ==
368
- { :port => 636, :connect_type => :ssl }
342
+ expect( Treequel.read_opts_from_config(:a_configfile) ).
343
+ to eq( :port => 636, :connect_type => :ssl )
369
344
  end
370
345
 
371
346
  it "ignores nss-style 'ssl' option if it is set to something other than " +
372
347
  "'on', 'off', or 'start_tls'" do
373
- IO.should_receive( :foreach ).with( :a_configfile ).
348
+ expect( IO ).to receive( :foreach ).with( :a_configfile ).
374
349
  and_yield( "\n# Use alien-invasion protocol\nssl aliens\n" )
375
350
 
376
351
  expect {
@@ -378,46 +353,46 @@ describe Treequel do
378
353
  }.to_not raise_exception()
379
354
  end
380
355
 
381
- #
356
+ #
382
357
  # Environment
383
- #
358
+ #
384
359
 
385
360
  it "maps the OpenLDAP LDAPURI environment variable to equivalent options" do
386
361
  ENV['LDAPURI'] = 'ldaps://quomsohutch.linkerlinlinkin.org/o=linkerlickin'
387
- Treequel.read_opts_from_environment.should == {
362
+ expect( Treequel.read_opts_from_environment ).to include(
388
363
  :host => 'quomsohutch.linkerlinlinkin.org',
389
364
  :connect_type => :ssl,
390
365
  :port => 636,
391
366
  :base_dn => 'o=linkerlickin'
392
- }
367
+ )
393
368
  end
394
369
 
395
370
  it "maps the OpenLDAP LDAPBASE environment variable to the base_dn option" do
396
371
  ENV['LDAPBASE'] = 'o=linkerlickin'
397
- Treequel.read_opts_from_environment.should == {
372
+ expect( Treequel.read_opts_from_environment ).to include(
398
373
  :base_dn => 'o=linkerlickin'
399
- }
374
+ )
400
375
  end
401
376
 
402
377
  it "maps the OpenLDAP LDAPBINDDN environment variable to the bind_dn option" do
403
378
  ENV['LDAPBINDDN'] = 'cn=superuser,ou=people,o=linkerlickin'
404
- Treequel.read_opts_from_environment.should == {
379
+ expect( Treequel.read_opts_from_environment ).to include(
405
380
  :bind_dn => 'cn=superuser,ou=people,o=linkerlickin'
406
- }
381
+ )
407
382
  end
408
383
 
409
384
  it "maps the OpenLDAP LDAPHOST environment variable to the host option" do
410
385
  ENV['LDAPHOST'] = 'quomsohutch.linkerlinlinkin.org'
411
- Treequel.read_opts_from_environment.should == {
412
- :host => 'quomsohutch.linkerlinlinkin.org',
413
- }
386
+ expect( Treequel.read_opts_from_environment ).to include(
387
+ :host => 'quomsohutch.linkerlinlinkin.org'
388
+ )
414
389
  end
415
390
 
416
391
  it "maps the OpenLDAP LDAPPORT environment variable to the port option" do
417
392
  ENV['LDAPPORT'] = '636'
418
- Treequel.read_opts_from_environment.should == {
419
- :port => 636,
420
- }
393
+ expect( Treequel.read_opts_from_environment ).to include(
394
+ :port => 636
395
+ )
421
396
  end
422
397
  end
423
398