spec/authy/api_spec.rb in authy-2.3.0 vs spec/authy/api_spec.rb in authy-2.3.1
- old
+ new
@@ -19,11 +19,11 @@
user = Authy::API.register_user(:email => generate_email,
:cellphone => "abc-1234",
:country_code => 1)
user.errors.should be_kind_of(Hash)
- user.errors['cellphone'].should == 'must be a valid cellphone number.'
+ user.errors['cellphone'].should == 'is invalid'
end
it "should allow to override the API key" do
user = Authy::API.register_user(:email => generate_email,
:cellphone => generate_cellphone,
@@ -36,22 +36,24 @@
end
describe "verificating tokens" do
before do
- @user = Authy::API.register_user(:email => generate_email,
- :cellphone => generate_cellphone,
+ @email = generate_email
+ @cellphone = generate_cellphone
+ @user = Authy::API.register_user(:email => @email,
+ :cellphone => @cellphone,
:country_code => 1)
@user.should be_ok
end
it "should fail to validate a given token if the user is not registered" do
- response = Authy::API.verify(:token => 'invalid_token', :id => @user['id'])
+ response = Authy::API.verify(:token => 'invalid_token', :id => @user.id)
response.should be_kind_of(Authy::Response)
response.ok?.should be_false
- response.errors['message'].should == 'token is invalid'
+ response.errors['message'].should == 'Token is invalid.'
end
it "should allow to override the API key" do
response = Authy::API.verify(:token => 'invalid_token', :id => @user['id'], :api_key => "invalid_api_key")
@@ -96,11 +98,11 @@
end
context "user doesn't exist" do
it "should not be ok" do
response = Authy::API.send("request_#{kind}", :id => "tony")
- response.errors['message'].should == "User doesn't exist."
+ response.errors['message'].should == "User not found."
response.should_not be_ok
end
end
end
@@ -108,11 +110,11 @@
describe "delete users" do
context "user doesn't exist" do
it "should not be ok" do
response = Authy::API.delete_user(:id => "tony")
- response.errors['message'].should == "User doesn't exist."
+ response.errors['message'].should == "User not found."
response.should_not be_ok
end
end
context "user exists" do
@@ -122,9 +124,32 @@
end
it "should be ok" do
response = Authy::API.delete_user(:id => @user.id)
response.message.should == "User was added to remove."
+ response.should be_ok
+ end
+ end
+ end
+
+ describe "user status" do
+ context "user doesn't exist" do
+ it "should not be ok" do
+ response = Authy::API.user_status(:id => "tony")
+ response.errors["message"].should == "User not found."
+ response.should_not be_ok
+ end
+ end
+
+ context "user exists" do
+ before do
+ @user = Authy::API.register_user(:email => generate_email, :cellphone => generate_cellphone, :country_code => 1)
+ @user.should be_ok
+ end
+
+ it "should be ok" do
+ response = Authy::API.user_status(:id => @user.id)
+ response.status.should be_kind_of(Hash)
response.should be_ok
end
end
end