wtforum 0.1.1 → 0.1.2
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/lib/wtforum.rb +3 -1
- data/lib/wtforum/session.rb +6 -0
- data/lib/wtforum/version.rb +1 -1
- data/spec/integration/wtforum_session_spec.rb +16 -6
- metadata +4 -4
data/lib/wtforum.rb
CHANGED
@@ -9,6 +9,8 @@ require "wtforum/user"
|
|
9
9
|
require "wtforum/session"
|
10
10
|
|
11
11
|
module WTForum
|
12
|
+
class WTForumError < StandardError; end
|
13
|
+
|
12
14
|
class << self
|
13
15
|
attr_accessor :domain, :api_key, :admin_username, :admin_password
|
14
16
|
|
@@ -29,7 +31,7 @@ module WTForum
|
|
29
31
|
if node.present?
|
30
32
|
node.text
|
31
33
|
else
|
32
|
-
raise xml.css("error, .errorMsg").text
|
34
|
+
raise WTForumError, xml.css("errormessage, error, .errorMsg").text
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
data/lib/wtforum/session.rb
CHANGED
@@ -7,6 +7,12 @@ module WTForum
|
|
7
7
|
page = Mechanize.new.get(uri)
|
8
8
|
auth_token = WTForum.extract_value(:authtoken, from: page.body)
|
9
9
|
new(auth_token)
|
10
|
+
rescue WTForumError => e
|
11
|
+
if e.message == "Error: The specified user does not exist."
|
12
|
+
raise WTForum::User::NotFound
|
13
|
+
else
|
14
|
+
raise
|
15
|
+
end
|
10
16
|
end
|
11
17
|
|
12
18
|
def initialize token
|
data/lib/wtforum/version.rb
CHANGED
@@ -3,13 +3,23 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
describe WTForum::Session do
|
6
|
-
|
7
|
-
|
6
|
+
context "when user exists" do
|
7
|
+
let(:user) do
|
8
|
+
WTForum::User.create username: "wtforum_test_user", email: "wtforum_test_user@example.com"
|
9
|
+
end
|
10
|
+
after { user.destroy }
|
11
|
+
|
12
|
+
it "can log in users" do
|
13
|
+
session = WTForum::Session.create(user.id)
|
14
|
+
session.token.should match(/^[a-z0-9]{11}$/i)
|
15
|
+
end
|
8
16
|
end
|
9
|
-
after { user.destroy }
|
10
17
|
|
11
|
-
|
12
|
-
|
13
|
-
|
18
|
+
context "when user doesn't exist" do
|
19
|
+
it "raises an exception" do
|
20
|
+
lambda {
|
21
|
+
WTForum::Session.create(1)
|
22
|
+
}.should raise_exception(WTForum::User::NotFound)
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: wtforum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Micah Geisel
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
type: :runtime
|
@@ -155,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
155
|
requirements:
|
156
156
|
- - ! '>='
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
hash:
|
158
|
+
hash: 4397302379876706461
|
159
159
|
segments:
|
160
160
|
- 0
|
161
161
|
version: '0'
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
requirements:
|
165
165
|
- - ! '>='
|
166
166
|
- !ruby/object:Gem::Version
|
167
|
-
hash:
|
167
|
+
hash: 4397302379876706461
|
168
168
|
segments:
|
169
169
|
- 0
|
170
170
|
version: '0'
|