spec/authy/api_spec.rb in authy-2.3.1 vs spec/authy/api_spec.rb in authy-2.4.0

- old
+ new

@@ -2,35 +2,41 @@ describe "Authy::API" do describe "Registering users" do it "should find or create a user" do - user = Authy::API.register_user(:email => generate_email, - :cellphone => generate_cellphone, - :country_code => 1) + user = Authy::API.register_user( + :email => generate_email, + :cellphone => generate_cellphone, + :country_code => 1 + ) user.should be_kind_of(Authy::Response) user.should be_kind_of(Authy::User) user.should_not be_nil user.id.should_not be_nil user.id.should be_kind_of(Integer) end it "should return the error messages as a hash" do - user = Authy::API.register_user(:email => generate_email, - :cellphone => "abc-1234", - :country_code => 1) + 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 == 'is invalid' end it "should allow to override the API key" do - user = Authy::API.register_user(:email => generate_email, - :cellphone => generate_cellphone, - :country_code => 1, - :api_key => "invalid_api_key") + user = Authy::API.register_user( + :email => generate_email, + :cellphone => generate_cellphone, + :country_code => 1, + :api_key => "invalid_api_key" + ) user.should_not be_ok user.errors['message'].should =~ /invalid api key/i end @@ -48,10 +54,10 @@ 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.should be_kind_of(Authy::Response) - response.ok?.should be_false + response.should_not be_ok 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")