treequel 1.1.1 → 1.2.0pre320
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.
- data.tar.gz.sig +0 -0
- data/ChangeLog +49 -1
- data/README.md +65 -0
- data/Rakefile +24 -19
- data/bin/treequel +20 -3
- data/lib/treequel.rb +3 -3
- data/lib/treequel/branch.rb +21 -7
- data/lib/treequel/branchset.rb +10 -0
- data/lib/treequel/model.rb +12 -2
- data/lib/treequel/schema.rb +1 -1
- data/rake/documentation.rb +9 -2
- data/rake/hg.rb +16 -3
- data/rake/manual.rb +1 -1
- data/rake/packaging.rb +1 -1
- data/rake/publishing.rb +158 -95
- data/rake/testing.rb +52 -88
- data/spec/lib/constants.rb +1 -0
- data/spec/lib/control_behavior.rb +7 -5
- data/spec/lib/helpers.rb +40 -17
- data/spec/lib/matchers.rb +2 -0
- data/spec/treequel/branch_spec.rb +44 -21
- data/spec/treequel/branchcollection_spec.rb +4 -3
- data/spec/treequel/branchset_spec.rb +42 -31
- data/spec/treequel/control_spec.rb +2 -1
- data/spec/treequel/controls/contentsync_spec.rb +2 -1
- data/spec/treequel/controls/pagedresults_spec.rb +4 -7
- data/spec/treequel/controls/sortedresults_spec.rb +4 -7
- data/spec/treequel/directory_spec.rb +11 -12
- data/spec/treequel/filter_spec.rb +7 -14
- data/spec/treequel/mixins_spec.rb +4 -9
- data/spec/treequel/model/objectclass_spec.rb +2 -1
- data/spec/treequel/model_spec.rb +16 -35
- data/spec/treequel/monkeypatches_spec.rb +12 -1
- data/spec/treequel/schema/attributetype_spec.rb +2 -1
- data/spec/treequel/schema/ldapsyntax_spec.rb +2 -1
- data/spec/treequel/schema/matchingrule_spec.rb +2 -1
- data/spec/treequel/schema/matchingruleuse_spec.rb +2 -1
- data/spec/treequel/schema/objectclass_spec.rb +2 -1
- data/spec/treequel/schema/table_spec.rb +2 -1
- data/spec/treequel/schema_spec.rb +2 -1
- data/spec/treequel_spec.rb +10 -2
- metadata +16 -17
- metadata.gz.sig +0 -0
- data/README +0 -66
data/spec/lib/constants.rb
CHANGED
@@ -15,6 +15,7 @@ module Treequel::TestConstants # :nodoc:all
|
|
15
15
|
TEST_HOST = 'ldap.example.com'
|
16
16
|
TEST_PORT = LDAP::LDAP_PORT
|
17
17
|
TEST_BASE_DN = 'dc=acme,dc=com'
|
18
|
+
TEST_LDAPURI = "ldap://#{TEST_HOST}:#{TEST_PORT}/#{TEST_BASE_DN}"
|
18
19
|
|
19
20
|
TEST_BIND_DN = "cn=admin,#{TEST_BASE_DN}"
|
20
21
|
TEST_BIND_PASS = 'passomaquoddy'
|
@@ -10,7 +10,8 @@ BEGIN {
|
|
10
10
|
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
11
|
}
|
12
12
|
|
13
|
-
require '
|
13
|
+
require 'rspec'
|
14
|
+
|
14
15
|
require 'spec/lib/constants'
|
15
16
|
require 'spec/lib/helpers'
|
16
17
|
|
@@ -23,13 +24,14 @@ include Treequel::Constants
|
|
23
24
|
#####################################################################
|
24
25
|
### C O N T E X T S
|
25
26
|
#####################################################################
|
26
|
-
|
27
|
+
shared_examples_for "A Treequel::Control" do
|
27
28
|
include Treequel::SpecHelpers
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
let( :control ) do
|
31
|
+
described_class
|
31
32
|
end
|
32
33
|
|
34
|
+
|
33
35
|
it "implements one of either #get_client_controls or #get_server_controls" do
|
34
36
|
methods = [
|
35
37
|
'get_client_controls', # 1.8.x
|
@@ -37,7 +39,7 @@ describe "A Treequel::Control", :shared => true do
|
|
37
39
|
:get_client_controls, # 1.9.x
|
38
40
|
:get_server_controls
|
39
41
|
]
|
40
|
-
(
|
42
|
+
(control.instance_methods( false ) | methods).should_not be_empty()
|
41
43
|
end
|
42
44
|
|
43
45
|
end
|
data/spec/lib/helpers.rb
CHANGED
@@ -10,29 +10,22 @@ BEGIN {
|
|
10
10
|
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
11
|
}
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
require 'rubygems'
|
21
|
-
retry
|
22
|
-
end
|
23
|
-
raise
|
24
|
-
end
|
13
|
+
require 'rspec'
|
14
|
+
|
15
|
+
require 'yaml'
|
16
|
+
require 'treequel'
|
17
|
+
|
18
|
+
require 'spec/lib/constants'
|
19
|
+
require 'spec/lib/matchers'
|
25
20
|
|
26
21
|
|
27
22
|
### RSpec helper functions.
|
28
23
|
module Treequel::SpecHelpers
|
29
24
|
include Treequel::TestConstants
|
30
25
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
|
26
|
+
SCHEMA_DUMPFILE = Pathname( __FILE__ ).dirname.parent + 'data' + 'schema.yml'
|
27
|
+
SCHEMAHASH = LDAP::Schema.new( YAML.load_file(SCHEMA_DUMPFILE) )
|
28
|
+
SCHEMA = Treequel::Schema.new( SCHEMAHASH )
|
36
29
|
|
37
30
|
class ArrayLogger
|
38
31
|
### Create a new ArrayLogger that will append content to +array+.
|
@@ -65,6 +58,12 @@ module Treequel::SpecHelpers
|
|
65
58
|
module_function
|
66
59
|
###############
|
67
60
|
|
61
|
+
### Make an easily-comparable version vector out of +ver+ and return it.
|
62
|
+
def vvec( ver )
|
63
|
+
return ver.split('.').collect {|char| char.to_i }.pack('N*')
|
64
|
+
end
|
65
|
+
|
66
|
+
|
68
67
|
### Reset the logging subsystem to its default state.
|
69
68
|
def reset_logging
|
70
69
|
Treequel.reset_logger
|
@@ -93,8 +92,32 @@ module Treequel::SpecHelpers
|
|
93
92
|
end
|
94
93
|
end
|
95
94
|
|
95
|
+
|
96
|
+
### Make a Treequel::Directory that will use the given +conn+ object as its
|
97
|
+
### LDAP connection. Also pre-loads the schema object and fixtures some other
|
98
|
+
### external data.
|
99
|
+
def get_fixtured_directory( conn )
|
100
|
+
LDAP::SSLConn.stub( :new ).and_return( @conn )
|
101
|
+
conn.stub( :root_dse ).and_return( nil )
|
102
|
+
directory = Treequel.directory( TEST_LDAPURI )
|
103
|
+
directory.stub( :schema ).and_return( SCHEMA )
|
104
|
+
|
105
|
+
return directory
|
106
|
+
end
|
107
|
+
|
96
108
|
end
|
97
109
|
|
98
110
|
|
111
|
+
### Mock with Rspec
|
112
|
+
Rspec.configure do |c|
|
113
|
+
c.mock_with :rspec
|
114
|
+
c.include( Treequel::TestConstants )
|
115
|
+
c.include( Treequel::SpecHelpers )
|
116
|
+
c.include( Treequel::Matchers )
|
117
|
+
|
118
|
+
c.filter_run_excluding( :ruby_1_8_only => true ) if
|
119
|
+
Treequel::SpecHelpers.vvec( RUBY_VERSION ) >= Treequel::SpecHelpers.vvec('1.9.1')
|
120
|
+
end
|
121
|
+
|
99
122
|
# vim: set nosta noet ts=4 sw=4:
|
100
123
|
|
data/spec/lib/matchers.rb
CHANGED
@@ -10,7 +10,8 @@ BEGIN {
|
|
10
10
|
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
11
|
}
|
12
12
|
|
13
|
-
require '
|
13
|
+
require 'rspec'
|
14
|
+
|
14
15
|
require 'spec/lib/constants'
|
15
16
|
require 'spec/lib/helpers'
|
16
17
|
require 'spec/lib/matchers'
|
@@ -70,6 +71,28 @@ describe Treequel::Branch do
|
|
70
71
|
branch.entry.should == entry
|
71
72
|
end
|
72
73
|
|
74
|
+
it "can be constructed from an entry with Symbol keys" do
|
75
|
+
entry = {
|
76
|
+
:dn => [TEST_PERSON_DN],
|
77
|
+
TEST_PERSON_DN_ATTR => TEST_PERSON_DN_VALUE,
|
78
|
+
}
|
79
|
+
branch = Treequel::Branch.new_from_entry( entry, @directory )
|
80
|
+
|
81
|
+
branch.rdn_attributes.should == { TEST_PERSON_DN_ATTR => [TEST_PERSON_DN_VALUE] }
|
82
|
+
branch.entry.should == {
|
83
|
+
'dn' => [TEST_PERSON_DN],
|
84
|
+
TEST_PERSON_DN_ATTR => TEST_PERSON_DN_VALUE,
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
it "can be instantiated with a Hash with Symbol keys" do
|
89
|
+
branch = Treequel::Branch.new( @directory, TEST_PERSON_DN,
|
90
|
+
TEST_PERSON_DN_ATTR.to_sym => TEST_PERSON_DN_VALUE )
|
91
|
+
branch.entry.should == {
|
92
|
+
TEST_PERSON_DN_ATTR => TEST_PERSON_DN_VALUE,
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
73
96
|
it "raises an exception if constructed with something other than a Hash entry" do
|
74
97
|
expect {
|
75
98
|
Treequel::Branch.new( @directory, TEST_PEOPLE_DN, 18 )
|
@@ -91,10 +114,10 @@ describe Treequel::Branch do
|
|
91
114
|
|
92
115
|
@schema = mock( "treequel schema" )
|
93
116
|
@entry = mock( "entry object" )
|
94
|
-
@directory.stub
|
95
|
-
@directory.stub
|
96
|
-
@directory.stub
|
97
|
-
@schema.stub
|
117
|
+
@directory.stub( :schema ).and_return( @schema )
|
118
|
+
@directory.stub( :get_entry ).and_return( @entry )
|
119
|
+
@directory.stub( :base_dn ).and_return( TEST_BASE_DN )
|
120
|
+
@schema.stub( :attribute_types ).
|
98
121
|
and_return({ :cn => :a_value, :ou => :a_value })
|
99
122
|
|
100
123
|
@syntax = stub( "attribute ldapSyntax object", :oid => OIDS::STRING_SYNTAX )
|
@@ -375,8 +398,8 @@ describe Treequel::Branch do
|
|
375
398
|
end
|
376
399
|
|
377
400
|
it "can return the set of all its MUST attributeTypes based on which objectClasses it has" do
|
378
|
-
oc1 = mock( "first objectclass" )
|
379
|
-
oc2 = mock( "second objectclass" )
|
401
|
+
oc1 = mock( "first objectclass", :name => 'first_oc' )
|
402
|
+
oc2 = mock( "second objectclass", :name => 'second_oc' )
|
380
403
|
|
381
404
|
@branch.should_receive( :object_classes ).and_return([ oc1, oc2 ])
|
382
405
|
oc1.should_receive( :must ).at_least( :once ).and_return([ :cn, :uid ])
|
@@ -735,8 +758,8 @@ describe Treequel::Branch do
|
|
735
758
|
@entry.should_receive( :[] ).with( 'glumpy' ).at_least( :once ).
|
736
759
|
and_return([ 'glumpa1', 'glumpa2' ])
|
737
760
|
|
738
|
-
@attribute_type.stub
|
739
|
-
@directory.stub
|
761
|
+
@attribute_type.stub( :syntax ).and_return( @syntax )
|
762
|
+
@directory.stub( :convert_to_object ).and_return {|_,str| str }
|
740
763
|
|
741
764
|
@branch[ :glumpy ].should == [ 'glumpa1', 'glumpa2' ]
|
742
765
|
end
|
@@ -747,8 +770,8 @@ describe Treequel::Branch do
|
|
747
770
|
@entry.should_receive( :[] ).with( 'glumpy' ).at_least( :once ).
|
748
771
|
and_return([ 'glumpa1' ])
|
749
772
|
|
750
|
-
@attribute_type.stub
|
751
|
-
@directory.stub
|
773
|
+
@attribute_type.stub( :syntax ).and_return( @syntax )
|
774
|
+
@directory.stub( :convert_to_object ).and_return {|_,str| str }
|
752
775
|
|
753
776
|
@branch[ :glumpy ].should == 'glumpa1'
|
754
777
|
end
|
@@ -766,10 +789,10 @@ describe Treequel::Branch do
|
|
766
789
|
end
|
767
790
|
|
768
791
|
it "caches the value fetched from its entry" do
|
769
|
-
@schema.stub
|
770
|
-
@attribute_type.stub
|
771
|
-
@attribute_type.stub
|
772
|
-
@directory.stub
|
792
|
+
@schema.stub( :attribute_types ).and_return({ :glump => @attribute_type })
|
793
|
+
@attribute_type.stub( :single? ).and_return( true )
|
794
|
+
@attribute_type.stub( :syntax ).and_return( @syntax )
|
795
|
+
@directory.stub( :convert_to_object ).and_return {|_,str| str }
|
773
796
|
@entry.should_receive( :[] ).with( 'glump' ).once.and_return( [:a_value] )
|
774
797
|
2.times { @branch[ :glump ] }
|
775
798
|
end
|
@@ -779,7 +802,7 @@ describe Treequel::Branch do
|
|
779
802
|
@attribute_type.should_receive( :single? ).and_return( true )
|
780
803
|
@entry.should_receive( :[] ).with( 'bvector' ).at_least( :once ).
|
781
804
|
and_return([ '010011010101B' ])
|
782
|
-
@syntax.stub
|
805
|
+
@syntax.stub( :oid ).and_return( OIDS::BIT_STRING_SYNTAX )
|
783
806
|
@directory.should_receive( :convert_to_object ).
|
784
807
|
with( OIDS::BIT_STRING_SYNTAX, '010011010101B' ).
|
785
808
|
and_return( 1237 )
|
@@ -805,14 +828,14 @@ describe Treequel::Branch do
|
|
805
828
|
end
|
806
829
|
|
807
830
|
it "clears the cache after a successful write" do
|
808
|
-
@schema.stub
|
809
|
-
@attribute_type.stub
|
810
|
-
@attribute_type.stub
|
811
|
-
@directory.stub
|
831
|
+
@schema.stub( :attribute_types ).and_return({ :glorpy => @attribute_type })
|
832
|
+
@attribute_type.stub( :single? ).and_return( true )
|
833
|
+
@attribute_type.stub( :syntax ).and_return( @syntax )
|
834
|
+
@directory.stub( :convert_to_object ).and_return {|_,val| val }
|
812
835
|
@entry.should_receive( :[] ).with( 'glorpy' ).and_return( [:firstval], [:secondval] )
|
813
836
|
|
814
837
|
@directory.should_receive( :modify ).with( @branch, {'glorpy' => ['chunks']} )
|
815
|
-
@directory.stub
|
838
|
+
@directory.stub( :convert_to_attribute ).and_return {|_,val| val }
|
816
839
|
@entry.should_receive( :[]= ).with( 'glorpy', ['chunks'] )
|
817
840
|
|
818
841
|
@branch[ :glorpy ].should == :firstval
|
@@ -10,7 +10,8 @@ BEGIN {
|
|
10
10
|
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
11
|
}
|
12
12
|
|
13
|
-
require '
|
13
|
+
require 'rspec'
|
14
|
+
|
14
15
|
require 'spec/lib/constants'
|
15
16
|
require 'spec/lib/helpers'
|
16
17
|
|
@@ -148,7 +149,7 @@ describe Treequel::BranchCollection do
|
|
148
149
|
@branchset1.should_receive( :each ).and_yield( :bs1_stuff )
|
149
150
|
@branchset2.should_receive( :each ).and_yield( :bs2_stuff )
|
150
151
|
added_branch = stub( "added branch", :directory => @directory )
|
151
|
-
added_branch.stub
|
152
|
+
added_branch.stub( :to_ary ).and_return( [added_branch] )
|
152
153
|
|
153
154
|
results = @collection + added_branch
|
154
155
|
|
@@ -236,7 +237,7 @@ describe Treequel::BranchCollection do
|
|
236
237
|
|
237
238
|
it "raises a reasonable exception if one of its delegates returns a non-branchset" do
|
238
239
|
filter = Treequel::Filter.new
|
239
|
-
@branchset1.stub
|
240
|
+
@branchset1.stub( :filter ).and_return( filter )
|
240
241
|
|
241
242
|
expect {
|
242
243
|
@collection.filter
|
@@ -10,7 +10,8 @@ BEGIN {
|
|
10
10
|
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
11
|
}
|
12
12
|
|
13
|
-
require '
|
13
|
+
require 'rspec'
|
14
|
+
|
14
15
|
require 'spec/lib/constants'
|
15
16
|
require 'spec/lib/helpers'
|
16
17
|
|
@@ -18,20 +19,12 @@ require 'treequel/branchset'
|
|
18
19
|
require 'treequel/branchcollection'
|
19
20
|
require 'treequel/control'
|
20
21
|
|
21
|
-
include Treequel::TestConstants
|
22
|
-
include Treequel::Constants
|
23
22
|
|
24
23
|
#####################################################################
|
25
24
|
### C O N T E X T S
|
26
25
|
#####################################################################
|
27
26
|
|
28
27
|
describe Treequel::Branchset do
|
29
|
-
include Treequel::SpecHelpers
|
30
|
-
|
31
|
-
# Make the specs read more clearly
|
32
|
-
class << self
|
33
|
-
alias_method :they, :it
|
34
|
-
end
|
35
28
|
|
36
29
|
DEFAULT_PARAMS = {
|
37
30
|
:limit => 0,
|
@@ -50,19 +43,19 @@ describe Treequel::Branchset do
|
|
50
43
|
end
|
51
44
|
|
52
45
|
before( :each ) do
|
53
|
-
@
|
54
|
-
@
|
55
|
-
@branch
|
46
|
+
@conn = double( "LDAP connection", :set_option => true, :bound? => false )
|
47
|
+
@directory = get_fixtured_directory( @conn )
|
48
|
+
@branch = @directory.base
|
56
49
|
@params = DEFAULT_PARAMS.dup
|
57
50
|
end
|
58
51
|
|
59
52
|
|
60
|
-
|
53
|
+
context "an instance" do
|
61
54
|
before( :each ) do
|
62
55
|
@branchset = Treequel::Branchset.new( @branch )
|
63
56
|
end
|
64
57
|
|
65
|
-
|
58
|
+
it "is Enumerable" do
|
66
59
|
resultbranch = mock( "Result Branch" )
|
67
60
|
|
68
61
|
@branch.should_receive( :search ).
|
@@ -76,7 +69,7 @@ describe Treequel::Branchset do
|
|
76
69
|
#
|
77
70
|
# #empty?
|
78
71
|
#
|
79
|
-
|
72
|
+
it "is empty if it doesn't match at least one entry" do
|
80
73
|
params = @params.merge( :limit => 1 )
|
81
74
|
@branch.should_receive( :search ).
|
82
75
|
with( Treequel::Branchset::DEFAULT_SCOPE, @branchset.filter, params ).
|
@@ -85,7 +78,7 @@ describe Treequel::Branchset do
|
|
85
78
|
@branchset.should be_empty()
|
86
79
|
end
|
87
80
|
|
88
|
-
|
81
|
+
it "isn't empty if it matches at least one entry" do
|
89
82
|
params = @params.merge( :limit => 1 )
|
90
83
|
@branch.should_receive( :search ).
|
91
84
|
with( Treequel::Branchset::DEFAULT_SCOPE, @branchset.filter, params ).
|
@@ -97,7 +90,7 @@ describe Treequel::Branchset do
|
|
97
90
|
#
|
98
91
|
# #map
|
99
92
|
#
|
100
|
-
|
93
|
+
it "can be mapped into an Array of attribute values" do
|
101
94
|
resultbranch = mock( "Result Branch" )
|
102
95
|
resultbranch2 = mock( "Result Branch 2" )
|
103
96
|
|
@@ -114,7 +107,7 @@ describe Treequel::Branchset do
|
|
114
107
|
#
|
115
108
|
# #to_hash
|
116
109
|
#
|
117
|
-
|
110
|
+
it "can be mapped into a Hash of entries keyed by one of its attributes" do
|
118
111
|
resultbranch = mock( "Result Branch" )
|
119
112
|
resultbranch2 = mock( "Result Branch 2" )
|
120
113
|
|
@@ -136,7 +129,7 @@ describe Treequel::Branchset do
|
|
136
129
|
end
|
137
130
|
|
138
131
|
|
139
|
-
|
132
|
+
it "can be mapped into a Hash of tuples using two attributes" do
|
140
133
|
resultbranch = mock( "Result Branch" )
|
141
134
|
resultbranch2 = mock( "Result Branch 2" )
|
142
135
|
|
@@ -162,9 +155,9 @@ describe Treequel::Branchset do
|
|
162
155
|
#
|
163
156
|
# #+
|
164
157
|
#
|
165
|
-
|
158
|
+
it "can be combined with another instance into a BranchCollection by adding them together" do
|
166
159
|
other_branch = mock( "second treequel branch", :dn => 'theotherdn' )
|
167
|
-
other_branch.stub
|
160
|
+
other_branch.stub( :directory ).and_return( @directory )
|
168
161
|
other_branchset = Treequel::Branchset.new( other_branch )
|
169
162
|
|
170
163
|
result = @branchset + other_branchset
|
@@ -173,9 +166,9 @@ describe Treequel::Branchset do
|
|
173
166
|
result.branchsets.should include( @branchset, other_branchset )
|
174
167
|
end
|
175
168
|
|
176
|
-
|
169
|
+
it "returns the results of the search with the additional Branch if one is added to it" do
|
177
170
|
other_branch = mock( "additional treequel branch", :dn => 'theotherdn' )
|
178
|
-
other_branch.stub
|
171
|
+
other_branch.stub( :to_ary ).and_return( [other_branch] )
|
179
172
|
resultbranch = mock( "Result Branch" )
|
180
173
|
resultbranch2 = mock( "Result Branch 2" )
|
181
174
|
|
@@ -191,7 +184,7 @@ describe Treequel::Branchset do
|
|
191
184
|
#
|
192
185
|
# #-
|
193
186
|
#
|
194
|
-
|
187
|
+
it "returns the results of the search without the specified object if an object is " +
|
195
188
|
"subtracted from it" do
|
196
189
|
resultbranch = stub( "Result Branch", :dn => TEST_PERSON_DN )
|
197
190
|
resultbranch2 = stub( "Result Branch 2", :dn => TEST_PERSON2_DN )
|
@@ -209,7 +202,7 @@ describe Treequel::Branchset do
|
|
209
202
|
|
210
203
|
end
|
211
204
|
|
212
|
-
|
205
|
+
context "instance with no filter, options, or scope set" do
|
213
206
|
|
214
207
|
before( :each ) do
|
215
208
|
@branchset = Treequel::Branchset.new( @branch )
|
@@ -431,17 +424,35 @@ describe Treequel::Branchset do
|
|
431
424
|
#
|
432
425
|
# #as
|
433
426
|
#
|
434
|
-
it "can create a new branchset cloned from itself that will return instances of a
|
427
|
+
it "can create a new branchset cloned from itself that will return instances of a " +
|
428
|
+
"different branch class" do
|
435
429
|
subclass = Class.new( Treequel::Branch )
|
436
|
-
@branch.stub
|
437
|
-
@branch.stub
|
430
|
+
@branch.stub( :directory ).and_return( :the_directory )
|
431
|
+
@branch.stub( :dn ).and_return( TEST_HOSTS_DN )
|
438
432
|
newset = @branchset.as( subclass )
|
439
433
|
newset.branch.should be_an_instance_of( subclass )
|
440
434
|
end
|
441
435
|
|
436
|
+
|
437
|
+
#
|
438
|
+
# from
|
439
|
+
#
|
440
|
+
it "can create a new branchset cloned from itself with a different base DN (String)" do
|
441
|
+
newset = @branchset.from( TEST_SUBHOSTS_DN )
|
442
|
+
newset.base_dn.should == TEST_SUBHOSTS_DN
|
443
|
+
end
|
444
|
+
|
445
|
+
it "can create a new branchset cloned from itself with a different base DN " +
|
446
|
+
"(Treequel::Branch)" do
|
447
|
+
branch = Treequel::Branch.new( @directory, TEST_SUBHOSTS_DN )
|
448
|
+
newset = @branchset.from( branch )
|
449
|
+
newset.base_dn.should == TEST_SUBHOSTS_DN
|
450
|
+
end
|
451
|
+
|
442
452
|
end
|
443
453
|
|
444
|
-
|
454
|
+
|
455
|
+
context "instance with no filter, and scope set to 'onelevel'" do
|
445
456
|
|
446
457
|
before( :each ) do
|
447
458
|
@branchset = Treequel::Branchset.new( @branch, :scope => :onelevel )
|
@@ -462,7 +473,7 @@ describe Treequel::Branchset do
|
|
462
473
|
|
463
474
|
end
|
464
475
|
|
465
|
-
|
476
|
+
context "created for a directory with registered controls" do
|
466
477
|
|
467
478
|
before( :all ) do
|
468
479
|
@control = Module.new {
|
@@ -476,7 +487,7 @@ describe Treequel::Branchset do
|
|
476
487
|
end
|
477
488
|
|
478
489
|
before( :each ) do
|
479
|
-
@directory.stub
|
490
|
+
@directory.stub( :registered_controls ).and_return([ @control ])
|
480
491
|
end
|
481
492
|
|
482
493
|
after( :each ) do
|