Skip to content

Adds support to Verify emails, fixes verify_delete method #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 25, 2021
Merged

Adds support to Verify emails, fixes verify_delete method #62

merged 8 commits into from
Jun 25, 2021

Conversation

gabrielso
Copy link
Contributor

@gabrielso gabrielso commented Jun 24, 2021

  1. Adds support to Verify emails
    Added the VerifyEmailMessage entity
    Adds example of Verify email

  2. Sets version 3.0.0-rc.1

  3. Fixes verify_delete
    The client tries to instantiate a Verify object from the delete request but the response is empty.
    Response body is nil and doesn't respond to .empty?.
    Sending the request directly instead as other *_delete methods.

The client tried to instantiate a Verify object from the delete request
but the response is empty. Response body is nil and doesn't respond to
`.empty?`. Sending the request directly instead.
- Fixes examples
- Adds VerifyEmailMessage entity
- Adds `verify_email_message` method to client
@gabrielso gabrielso changed the title Fixes verify_delete method Adds support to Verify emails, fixes verify_delete method Jun 24, 2021
@marcelcorso marcelcorso merged commit 9569b7e into messagebird:master Jun 25, 2021
Copy link
Contributor

@jalerson jalerson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments and questions 👍


def created_datetime=(value)
@created_datetime = value_to_time(value)
end

def valid_until_date_time=(value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't a breaking change? Why it's necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jalerson, the gem generates the attribute names based on the response from the API, and it converts camelCase to snake_case.

The response from the server contains the validUntilDatetime key, therefore the valid_until_date_time attribute breaks.

It is a breaking change that fixes a broken gem, and this is a major release as well, so I think it fits.

@@ -2,6 +2,6 @@

module MessageBird
module Version
STRING = '2.0.1'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This MR is only introducing new features to the gem, which is a minor upgrade. Why we're doing a major upgrade here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1,42 +1,56 @@
# frozen_string_literal: true

describe 'Verify' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand if you want to keep the test structure consistent with the other tests, however, rspec is such a powerful testing framework to write expressive tests, so I'd recommend:

  • use describe to describe features
  • use context to describe the feature in different situations/contexts
  • use it to specify expectations (one it per expect)

For example:

describe 'Verify an email OTP' do
  context 'using an existing OTP' do
    ...

    it 'has the ID verify-id' do
      expect(verify.id).to eq 'verify-id'
    end

    it 'has the verified status' do
      expect(verify.status).to eq 'verified'
    end
  end

  context 'using a non-existing OTP' do
    it 'raises an error' do
      expect { @client.verify('verify-id') }.to raise_error(MessageBird::ErrorException)
    end
  end

  context "<insert here any other scenario>" do
    ...
  end
end

Copy link
Contributor Author

@gabrielso gabrielso Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, too late 😆 .

For the topmost describe block I usually prefer to use the class I'm testing, it gives me an instance of the class in the subject variable already to be used in the examples, and I can access it in some magic ways:

describe Array do
  context "new instances" do
    it "should be empty" do
      expect(subject).to be_empty
    end
    # or magically
    it { should be_empty }
    # or
    it { is_expected.to be_empty }
  end
end

@jalerson
Copy link
Contributor

Just found it's too late for my review 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants