spec/ribose/client_spec.rb in ribose-0.4.1 vs spec/ribose/client_spec.rb in ribose-0.5.0
- old
+ new
@@ -5,44 +5,43 @@
context "no attribtues provided" do
it "initialize with default configuration" do
client = Ribose::Client.new
expect(client.api_token).to eq(Ribose.configuration.api_token)
- expect(client.user_email).to eq(Ribose.configuration.user_email)
+ expect(client.api_email).to eq(Ribose.configuration.api_email)
end
end
context "custom attribtues provided" do
it "initialize with the supplied attribtues" do
- client = Ribose::Client.new(token: 123, email: "john@ex.com")
+ email = "john@ex.com"
+ token = "SECRET_API_TOKEN"
+ client = Ribose::Client.new(api_token: token, api_email: email)
- expect(client.api_token).to eq("123")
- expect(client.user_email).to eq("john@ex.com")
+ expect(client.api_token).to eq(token)
+ expect(client.api_email).to eq(email)
end
end
end
describe ".from_login" do
it "authenticate the user and build a client" do
- email = "useremail@example..com"
- password = "supersecretpassword"
+ email = "user.email@gmail.com"
+ password = "supser.secrect.password"
- allow(Ribose::Session).to receive(:create).and_return(session_hash)
+ allow(Ribose::Session).to receive(:create).and_return(session)
client = Ribose::Client.from_login(email: email, password: password)
- expect(client.user_email).to eq(email)
- expect(client.api_token).to eq(session_hash["authentication_token"])
+ expect(client.api_email).to eq(email)
+ expect(client.uid).to eq(session.uid)
+ expect(client.client_id).to eq(session.client)
end
end
- def session_hash
- {
- "authentication_token" => "SecretToken",
- "last_activity" => {
- "id" => 122072207,
- "session_id" => "SessionId",
- "browser" => "Ribose Ruby Client",
- "user_id" => "user-uuid-123-4567"
- },
- }
+ def session
+ @session ||= Ribose::SessionData.new(
+ uid: "hello",
+ expiry: Time.now + 3600,
+ client: "RIBOSE_RUBY_CLIENT",
+ )
end
end