jubjub 0.0.7 → 0.0.8
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/README.mdown +27 -1
- data/lib/jubjub.rb +1 -1
- data/lib/jubjub/connection/xmpp_gateway.rb +9 -9
- data/lib/jubjub/connection/xmpp_gateway/helper.rb +5 -5
- data/lib/jubjub/connection/xmpp_gateway/muc.rb +127 -32
- data/lib/jubjub/connection/xmpp_gateway/pubsub.rb +64 -64
- data/lib/jubjub/data_form.rb +16 -13
- data/lib/jubjub/errors.rb +2 -2
- data/lib/jubjub/helpers.rb +32 -0
- data/lib/jubjub/jid.rb +8 -8
- data/lib/jubjub/muc.rb +3 -1
- data/lib/jubjub/muc/affiliation.rb +77 -0
- data/lib/jubjub/muc/affiliations_collection.rb +31 -0
- data/lib/jubjub/muc/collection.rb +12 -19
- data/lib/jubjub/muc/configuration.rb +2 -2
- data/lib/jubjub/muc/muc.rb +24 -11
- data/lib/jubjub/pubsub.rb +1 -1
- data/lib/jubjub/pubsub/affiliation.rb +20 -20
- data/lib/jubjub/pubsub/affiliation_collection.rb +11 -18
- data/lib/jubjub/pubsub/collection.rb +14 -21
- data/lib/jubjub/pubsub/configuration.rb +2 -2
- data/lib/jubjub/pubsub/item.rb +8 -8
- data/lib/jubjub/pubsub/item_collection.rb +10 -17
- data/lib/jubjub/pubsub/pubsub.rb +17 -17
- data/lib/jubjub/pubsub/subscription.rb +6 -6
- data/lib/jubjub/response.rb +1 -1
- data/lib/jubjub/response/error.rb +6 -6
- data/lib/jubjub/response/proxy.rb +8 -8
- data/lib/jubjub/response/response.rb +10 -10
- data/lib/jubjub/user.rb +16 -15
- data/spec/connection/xmpp_gateway_muc_spec.rb +174 -40
- data/spec/connection/xmpp_gateway_pubsub_spec.rb +100 -104
- data/spec/fixtures/vcr_cassettes/muc_configuration.yml +73 -6
- data/spec/fixtures/vcr_cassettes/muc_create_with_configuration.yml +8 -8
- data/spec/fixtures/vcr_cassettes/muc_message.yml +89 -0
- data/spec/fixtures/vcr_cassettes/muc_modify_affiliations.yml +367 -0
- data/spec/fixtures/vcr_cassettes/muc_retrieve_affiliations.yml +93 -0
- data/spec/fixtures/vcr_cassettes/pubsub_publish_with_dataform_payload.yml +3 -3
- data/spec/fixtures/vcr_cassettes/pubsub_retrieve_items.yml +24 -18
- data/spec/mixins/user_spec.rb +37 -37
- data/spec/models/data_form_spec.rb +3 -3
- data/spec/models/jid_spec.rb +41 -41
- data/spec/models/muc_affiliation_collection_spec.rb +146 -0
- data/spec/models/muc_affiliation_spec.rb +215 -0
- data/spec/models/muc_collection_spec.rb +64 -32
- data/spec/models/muc_configuration_spec.rb +3 -3
- data/spec/models/muc_spec.rb +44 -23
- data/spec/models/pubsub_affiliation_collection_spec.rb +65 -30
- data/spec/models/pubsub_affiliation_spec.rb +50 -50
- data/spec/models/pubsub_collection_spec.rb +65 -49
- data/spec/models/pubsub_item_collection_spec.rb +17 -17
- data/spec/models/pubsub_item_spec.rb +18 -18
- data/spec/models/pubsub_spec.rb +41 -41
- data/spec/models/pubsub_subscription_spec.rb +23 -23
- data/spec/models/response_error_spec.rb +19 -19
- data/spec/models/response_proxy_spec.rb +51 -49
- data/spec/models/response_spec.rb +33 -33
- data/spec/support/helpers.rb +21 -1
- data/spec/support/matchers.rb +4 -4
- data/spec/support/shared_examples.rb +132 -94
- data/spec/support/webmock_stanza_matching.rb +43 -0
- metadata +45 -16
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Jubjub::Pubsub::Subscription do
|
4
|
-
|
4
|
+
|
5
5
|
def pubsub_subscription_factory(override = {})
|
6
6
|
options = {
|
7
7
|
:jid => Jubjub::Jid.new("pubsub.foo.com"),
|
@@ -11,7 +11,7 @@ describe Jubjub::Pubsub::Subscription do
|
|
11
11
|
:subscription => 'subscribed',
|
12
12
|
:connection => "SHHHH CONNECTION OBJECT"
|
13
13
|
}.merge( override )
|
14
|
-
|
14
|
+
|
15
15
|
Jubjub::Pubsub::Subscription.new(
|
16
16
|
options[:jid],
|
17
17
|
options[:node],
|
@@ -21,95 +21,95 @@ describe Jubjub::Pubsub::Subscription do
|
|
21
21
|
options[:connection]
|
22
22
|
)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
describe "instance method" do
|
26
|
-
|
26
|
+
|
27
27
|
describe "inspect" do
|
28
|
-
|
28
|
+
|
29
29
|
it "should not show connection information" do
|
30
30
|
p = pubsub_subscription_factory :connection => 'SHHHH CONNECTION OBJECT'
|
31
31
|
p.inspect.should_not match 'SHHHH CONNECTION OBJECT'
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
it "should show string version of jid" do
|
35
35
|
p = pubsub_subscription_factory :jid => Jubjub::Jid.new("pubsub.foo.com")
|
36
36
|
p.inspect.should match '@jid="pubsub.foo.com"'
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
it "should show node" do
|
40
40
|
p = pubsub_subscription_factory :node => "node"
|
41
41
|
p.inspect.should match '@node="node"'
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
it "should show string version of subscriber" do
|
45
45
|
p = pubsub_subscription_factory :subscriber => Jubjub::Jid.new("theo@foo.com")
|
46
46
|
p.inspect.should match '@subscriber="theo@foo.com"'
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
it "should show subid" do
|
50
50
|
p = pubsub_subscription_factory :subid => nil
|
51
51
|
p.inspect.should match '@subid=nil'
|
52
|
-
|
52
|
+
|
53
53
|
p = pubsub_subscription_factory :subid => "wibble"
|
54
54
|
p.inspect.should match '@subid="wibble"'
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
it "should show subscription" do
|
58
58
|
p = pubsub_subscription_factory :subscription => nil
|
59
59
|
p.inspect.should match '@subscription=nil'
|
60
|
-
|
60
|
+
|
61
61
|
p = pubsub_subscription_factory :subscription => 'subscribed'
|
62
62
|
p.inspect.should match '@subscription="subscribed"'
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
describe "jid" do
|
68
68
|
it "should return the jid" do
|
69
69
|
p = pubsub_subscription_factory :jid => 'foo.com'
|
70
70
|
p.jid.should == Jubjub::Jid.new('foo.com')
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
describe "node" do
|
75
75
|
it "should return the node" do
|
76
76
|
p = pubsub_subscription_factory :node => 'node_1'
|
77
77
|
p.node.should == 'node_1'
|
78
78
|
end
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
describe "subscriber" do
|
82
82
|
it "should return the subscriber jid" do
|
83
83
|
p = pubsub_subscription_factory :subscriber => 'theo@foo.com'
|
84
84
|
p.subscriber.should == Jubjub::Jid.new('theo@foo.com')
|
85
85
|
end
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
describe "subid" do
|
89
89
|
it "should return the subid" do
|
90
90
|
p = pubsub_subscription_factory :subid => 'as12'
|
91
91
|
p.subid.should == 'as12'
|
92
92
|
end
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
describe "subscription" do
|
96
96
|
it "should return the subscription" do
|
97
97
|
p = pubsub_subscription_factory :subscription => '32'
|
98
98
|
p.subscription.should == '32'
|
99
99
|
end
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
describe "unsubscribe" do
|
103
103
|
it "should call pubsub.unsubscribe on connection" do
|
104
104
|
@mock_connection = mock
|
105
105
|
@mock_connection.stub_chain :pubsub, :unsubscribe
|
106
106
|
@mock_connection.pubsub.should_receive(:unsubscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', '123' )
|
107
|
-
|
107
|
+
|
108
108
|
p = pubsub_subscription_factory :jid => 'pubsub.foo.com', :node => 'node', :subid => '123', :connection => @mock_connection
|
109
109
|
p.unsubscribe
|
110
110
|
end
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
end
|
114
|
-
|
115
|
-
end
|
114
|
+
|
115
|
+
end
|
@@ -1,68 +1,68 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Jubjub::Response::Error do
|
4
|
-
|
4
|
+
|
5
5
|
describe 'creating' do
|
6
|
-
|
6
|
+
|
7
7
|
it 'should take a stanza' do
|
8
8
|
xml = Nokogiri::XML::Document.parse "<error type='cancel'><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>"
|
9
|
-
|
9
|
+
|
10
10
|
response = Jubjub::Response::Error.new xml
|
11
|
-
|
11
|
+
|
12
12
|
response.stanza.should == xml
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
describe 'instance method' do
|
18
|
-
|
18
|
+
|
19
19
|
describe 'condition' do
|
20
20
|
it 'should return a "urn:ietf:params:xml:ns:xmpp-stanzas" error condition' do
|
21
21
|
xml = Nokogiri::XML::Document.parse "<error><bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'></error>"
|
22
22
|
Jubjub::Response::Error.new( xml ).condition.should == "bad-request"
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it 'should return nil if unknown' do
|
26
26
|
xml = Nokogiri::XML::Document.parse "<error><text>Something went wrong</text><error/>"
|
27
27
|
Jubjub::Response::Error.new( xml ).condition.should equal(nil)
|
28
|
-
end
|
28
|
+
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
describe 'type' do
|
32
32
|
it 'should return nil if no error type available' do
|
33
33
|
xml = Nokogiri::XML::Document.parse "<error/>"
|
34
34
|
Jubjub::Response::Error.new( xml ).type.should equal(nil)
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it 'should return value errors present' do
|
38
38
|
xml = Nokogiri::XML::Document.parse "<error type='cancel'/>"
|
39
39
|
Jubjub::Response::Error.new( xml ).type.should == 'cancel'
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
describe 'text' do
|
44
|
-
it 'should return empty string if no text is available' do
|
44
|
+
it 'should return empty string if no text is available' do
|
45
45
|
xml = Nokogiri::XML::Document.parse "<error type='cancel'/>"
|
46
46
|
Jubjub::Response::Error.new( xml ).text.should == ""
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
it 'should return the text if available' do
|
50
50
|
xml = Nokogiri::XML::Document.parse "<error type='cancel'><text>Hello!</text></error>"
|
51
51
|
Jubjub::Response::Error.new( xml ).text.should == "Hello!"
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
it 'should return all text if available if multiple locales available' do
|
55
55
|
xml = Nokogiri::XML::Document.parse "<error type='cancel'><text xml:lang='en'>Hello!</text><text xml:lang='fr'>Bonjour!</text></error>"
|
56
56
|
Jubjub::Response::Error.new( xml ).text.should == "Hello!Bonjour!"
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
it 'should return the text in the correct locale if language specified' do
|
60
60
|
xml = Nokogiri::XML::Document.parse "<error type='cancel'><text xml:lang='en'>Hello!</text><text xml:lang='fr'>Bonjour!</text></error>"
|
61
61
|
Jubjub::Response::Error.new( xml ).text('fr').should == "Bonjour!"
|
62
62
|
Jubjub::Response::Error.new( xml ).text('en').should == "Hello!"
|
63
63
|
end
|
64
|
-
end
|
64
|
+
end
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
end
|
67
|
+
|
68
|
+
end
|
@@ -1,96 +1,98 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
1
3
|
describe Jubjub::Response::Proxy do
|
2
|
-
|
4
|
+
|
3
5
|
describe "creating" do
|
4
|
-
|
6
|
+
|
5
7
|
it "should require proxy_primary, proxy_secondary and public_method" do
|
6
8
|
primary = "String"
|
7
9
|
secondary = ["Array"]
|
8
|
-
|
10
|
+
|
9
11
|
p = Jubjub::Response::Proxy.new primary, secondary, "to_s"
|
10
12
|
|
11
13
|
p.proxy_primary.should equal(primary)
|
12
14
|
p.proxy_secondary.should equal(secondary)
|
13
15
|
end
|
14
|
-
|
16
|
+
|
15
17
|
end
|
16
|
-
|
18
|
+
|
17
19
|
describe "proxied methods" do
|
18
|
-
|
20
|
+
|
19
21
|
before do
|
20
22
|
@primary_class = Class.new do
|
21
23
|
def abc() end
|
22
24
|
def efg() end
|
23
25
|
def xyz() end
|
24
26
|
end
|
25
|
-
|
27
|
+
|
26
28
|
@secondary_class = Class.new do
|
27
29
|
def abc() end # Same as primary
|
28
30
|
def efg() end # Same as primary
|
29
31
|
def cba() end # Does not exist on primary
|
30
32
|
end
|
31
|
-
|
33
|
+
|
32
34
|
@primary = @primary_class.new
|
33
35
|
@secondary = @secondary_class.new
|
34
36
|
end
|
35
|
-
|
37
|
+
|
36
38
|
subject { Jubjub::Response::Proxy.new @primary, @secondary, 'efg' }
|
37
|
-
|
39
|
+
|
38
40
|
describe "that exist on proxy_primary" do
|
39
|
-
|
41
|
+
|
40
42
|
it "should not defer the primary_method" do
|
41
43
|
@primary.should_receive(:efg).never
|
42
|
-
|
44
|
+
|
43
45
|
subject.efg
|
44
46
|
end
|
45
|
-
|
47
|
+
|
46
48
|
it "should not defer methods that belong to Object.public_methods" do
|
47
49
|
@primary.should_receive(:class).never
|
48
|
-
|
50
|
+
|
49
51
|
subject.class
|
50
52
|
end
|
51
|
-
|
53
|
+
|
52
54
|
it "should defer to the proxy_primary" do
|
53
55
|
@primary.should_receive(:abc)
|
54
|
-
|
56
|
+
|
55
57
|
subject.abc
|
56
58
|
end
|
57
|
-
|
59
|
+
|
58
60
|
end
|
59
|
-
|
61
|
+
|
60
62
|
describe "that don't defer to proxy_primary" do
|
61
|
-
|
63
|
+
|
62
64
|
it "should defer to proxy_secondary" do
|
63
65
|
@secondary.should_receive(:cba)
|
64
|
-
|
66
|
+
|
65
67
|
subject.cba
|
66
68
|
end
|
67
|
-
|
69
|
+
|
68
70
|
it "should defer Object.public_methods to proxy_secondary" do
|
69
71
|
@secondary.should_receive(:class)
|
70
|
-
|
72
|
+
|
71
73
|
subject.class
|
72
74
|
end
|
73
|
-
|
75
|
+
|
74
76
|
it "should defer to proxy_secondary if primary_method" do
|
75
77
|
@secondary.should_receive(:efg)
|
76
|
-
|
78
|
+
|
77
79
|
subject.efg
|
78
80
|
end
|
79
|
-
|
81
|
+
|
80
82
|
it "should blow up if it doesn't exist on proxy_secondary either" do
|
81
83
|
expect {
|
82
84
|
subject.explode
|
83
85
|
}.to raise_error(NoMethodError,"undefined method `explode' for #{@secondary.inspect}")
|
84
86
|
end
|
85
|
-
|
87
|
+
|
86
88
|
end
|
87
|
-
|
89
|
+
|
88
90
|
end
|
89
|
-
|
91
|
+
|
90
92
|
describe "instance method" do
|
91
|
-
|
93
|
+
|
92
94
|
describe "inspect" do
|
93
|
-
|
95
|
+
|
94
96
|
it "should really inspect proxy_secondary" do
|
95
97
|
# The proxy_primary is just a thin layer over the top of the proxy_secondary
|
96
98
|
# So make sure inspect shows us the proxy_secondary
|
@@ -98,46 +100,46 @@ describe Jubjub::Response::Proxy do
|
|
98
100
|
secondary = ["Array"]
|
99
101
|
|
100
102
|
p = Jubjub::Response::Proxy.new primary, secondary, "to_s"
|
101
|
-
|
103
|
+
|
102
104
|
p.inspect.should == secondary.inspect
|
103
105
|
end
|
104
|
-
|
106
|
+
|
105
107
|
end
|
106
|
-
|
108
|
+
|
107
109
|
describe "proxy_primary" do
|
108
|
-
|
110
|
+
|
109
111
|
it "should return the proxy_primary object" do
|
110
112
|
primary = "p"
|
111
|
-
|
113
|
+
|
112
114
|
proxy = Jubjub::Response::Proxy.new primary, "s", "to_s"
|
113
|
-
|
115
|
+
|
114
116
|
proxy.proxy_primary.should equal(primary)
|
115
117
|
end
|
116
|
-
|
118
|
+
|
117
119
|
end
|
118
|
-
|
120
|
+
|
119
121
|
describe "proxy_secondary" do
|
120
|
-
|
122
|
+
|
121
123
|
it "should return the proxy_secondary object" do
|
122
124
|
secondary = "p"
|
123
|
-
|
125
|
+
|
124
126
|
proxy = Jubjub::Response::Proxy.new "p", secondary, "to_s"
|
125
|
-
|
127
|
+
|
126
128
|
proxy.proxy_secondary.should equal(secondary)
|
127
129
|
end
|
128
|
-
|
130
|
+
|
129
131
|
end
|
130
|
-
|
132
|
+
|
131
133
|
describe "proxy_class" do
|
132
|
-
|
134
|
+
|
133
135
|
it "should return Jubjub::Response::Proxy" do
|
134
136
|
p = Jubjub::Response::Proxy.new "p", "s", "to_s"
|
135
|
-
|
137
|
+
|
136
138
|
p.proxy_class.should equal(Jubjub::Response::Proxy)
|
137
139
|
end
|
138
|
-
|
140
|
+
|
139
141
|
end
|
140
|
-
|
142
|
+
|
141
143
|
end
|
142
|
-
|
143
|
-
end
|
144
|
+
|
145
|
+
end
|
@@ -1,113 +1,113 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Jubjub::Response do
|
4
|
-
|
4
|
+
|
5
5
|
describe 'creating' do
|
6
|
-
|
6
|
+
|
7
7
|
it 'should take a stanza' do
|
8
8
|
stanza = xml_fixture 'dataform_1'
|
9
|
-
|
9
|
+
|
10
10
|
response = Jubjub::Response.new stanza
|
11
|
-
|
11
|
+
|
12
12
|
response.stanza.should == stanza
|
13
13
|
response.result.should == nil
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it 'should take a block to define result' do
|
17
17
|
stanza = xml_fixture 'dataform_1'
|
18
|
-
|
18
|
+
|
19
19
|
namespaces = {
|
20
20
|
'commands' => 'http://jabber.org/protocol/commands',
|
21
21
|
'x_data' => 'jabber:x:data'
|
22
22
|
}
|
23
|
-
|
23
|
+
|
24
24
|
response = Jubjub::Response.new( stanza ) do |s|
|
25
25
|
s.xpath(
|
26
26
|
"//iq[@type='result']/commands:command/x_data:x[@type='form']/x_data:instructions",
|
27
27
|
namespaces
|
28
28
|
).text
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
response.result.should == 'Fill out this form to configure your new bot!'
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
describe 'instance method' do
|
37
|
-
|
37
|
+
|
38
38
|
describe 'result' do
|
39
|
-
|
39
|
+
|
40
40
|
before { @stanza = xml_fixture 'dataform_1' }
|
41
|
-
|
42
|
-
it 'should return result of block used in initialization if specified' do
|
41
|
+
|
42
|
+
it 'should return result of block used in initialization if specified' do
|
43
43
|
Jubjub::Response.new( @stanza ){ "Result" }.result.should == "Result"
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
it 'should return nil if no block provided' do
|
47
47
|
Jubjub::Response.new( @stanza ).result.should == nil
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
describe 'proxy_result' do
|
53
|
-
|
53
|
+
|
54
54
|
before { @stanza = xml_fixture 'dataform_1' }
|
55
|
-
|
55
|
+
|
56
56
|
it 'should return proxy of result' do
|
57
57
|
result = "Result"
|
58
58
|
Jubjub::Response.new( @stanza ){ result }.proxy_result.should be_a_kind_of_response_proxied result.class
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
describe 'success?' do
|
64
64
|
it 'should return true when stanza is iq[@type="get"]' do
|
65
65
|
xml = Nokogiri::XML::Document.parse "<iq type='get'/>"
|
66
66
|
Jubjub::Response.new( xml ).success?.should equal(true)
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
it 'should return true when stanza is iq[@type="result"]' do
|
70
70
|
xml = Nokogiri::XML::Document.parse "<iq type='result'/>"
|
71
71
|
Jubjub::Response.new( xml ).success?.should equal(true)
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
it 'should return true when stanza is iq[@type="set"]' do
|
75
75
|
xml = Nokogiri::XML::Document.parse "<iq type='set'/>"
|
76
76
|
Jubjub::Response.new( xml ).success?.should equal(true)
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
it 'should return false when stanza is iq[@type="error"]' do
|
80
80
|
xml = Nokogiri::XML::Document.parse "<iq type='error'/>"
|
81
81
|
Jubjub::Response.new( xml ).success?.should equal(false)
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
it 'should not look at child iq elements' do
|
85
85
|
xml = Nokogiri::XML::Document.parse "<totally><wrong><iq type='result'/></wrong></totally>"
|
86
86
|
Jubjub::Response.new( xml ).success?.should equal(false)
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
it 'should return false when stanza is nonsensical' do
|
90
90
|
xml = Nokogiri::XML::Document.parse "<presence/>"
|
91
91
|
Jubjub::Response.new( xml ).success?.should equal(false)
|
92
92
|
end
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
describe 'error' do
|
96
|
-
|
96
|
+
|
97
97
|
it 'should return Jubjub::Response:Error object if error present' do
|
98
98
|
xml = Nokogiri::XML::Document.parse "<iq type='error'><error><policy-violation xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'></error></iq>"
|
99
99
|
r = Jubjub::Response.new( xml )
|
100
100
|
r.error.should be_a Jubjub::Response::Error
|
101
101
|
r.error.condition.should == "policy-violation"
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
it 'should return nil if error is not present' do
|
105
105
|
xml = Nokogiri::XML::Document.parse "<iq type='set'/>"
|
106
106
|
Jubjub::Response.new( xml ).error.should be_nil
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
end
|
112
|
-
|
113
|
-
end
|
112
|
+
|
113
|
+
end
|