Skip to content

Commit 2b10c00

Browse files
committed
move login ticket generation to a module method
Signed-off-by: Tyler Pickett <t.pickett66@gmail.com>
1 parent bb8dc24 commit 2b10c00

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

lib/rubycas-server-core/tickets.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Core
66
module Tickets
77

88
# One time login ticket for given client
9-
def generate_login_ticket(client)
9+
def self.generate_login_ticket(client)
1010
lt = LoginTicket.new
1111
lt.ticket = "LT-" + Util.random_string
1212
lt.client_hostname = client

spec/rubycas-server-core/tickets_spec.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
module RubyCAS::Server::Core
44
describe RubyCAS::Server::Core::Tickets do
5+
let(:client_hostname) { 'myhost.test' }
6+
57
before do
68
RubyCAS::Server::Core.setup("spec/config/config.yml")
79
klass = Class.new {
@@ -11,31 +13,27 @@ module RubyCAS::Server::Core
1113
@client_hostname = "myhost.test"
1214
end
1315

14-
Tickets = RubyCAS::Server::Core::Tickets
15-
16-
describe "login ticket object" do
17-
before do
18-
@lt = @cas.generate_login_ticket(@client_hostname)
19-
end
16+
describe '.generate_login_ticket(client_hostname)', focus: true do
17+
let(:lt) { Tickets.generate_login_ticket(client_hostname) }
2018

2119
it "should return a login ticket" do
22-
@lt.class.should == Tickets::LoginTicket
20+
lt.class.should == Tickets::LoginTicket
2321
end
2422

2523
it "should set the client_hostname" do
26-
@lt.client_hostname.should == @client_hostname
24+
lt.client_hostname.should == client_hostname
2725
end
2826

2927
it "should set the ticket string" do
30-
@lt.ticket.should_not be_nil
28+
lt.ticket.should_not be_nil
3129
end
3230

3331
it "should set the ticket string starting with 'LT'" do
34-
@lt.ticket.should match /^LT/
32+
lt.ticket.should match /^LT/
3533
end
3634

3735
it "should not mark the ticket as consumed" do
38-
@lt.consumed.should be_nil
36+
lt.consumed.should be_nil
3937
end
4038
end
4139

0 commit comments

Comments
 (0)