Skip to content
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

Implement get_feature_variable and create unit tests #190

Merged
merged 7 commits into from
Jul 30, 2019

Conversation

brandonhudavid
Copy link
Contributor

@brandonhudavid brandonhudavid commented Jul 26, 2019

Summary

  • Implement get_feature_variable method in optimizely.rb to return value of variable with any type
  • Changed inputs_valid? function in validator.rb to allow for nil variable type
  • Create new unit tests in project_spec.rb to ensure functionality of get_feature_variable

Ruby is a dynamically-typed language, like JavaScript, so it suffices to have a single method return the value of a feature variable rather than have a separate method for each possible feature variable type.

Test plan

  • Create unit tests in project_spec.rb
  • Enable gherkin integration tests for Ruby in FSC suite and python-testapp

Issues

@brandonhudavid brandonhudavid changed the title (WIP) Implement get_feature_variable and create unit tests Implement get_feature_variable and create unit tests Jul 26, 2019
Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

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

Mostly looks ok, just have a small comment. @msohailhussain can you also take a look when you get the chance please

@@ -132,6 +132,15 @@ def inputs_valid?(variables, logger = NoOpLogger.new, level = Logger::ERROR)
variables.delete :user_id
end

if variables.include? :variable_type
# Empty variable_type is a valid user ID.
Copy link
Contributor

Choose a reason for hiding this comment

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

huh? This can you explain this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If variables[:variable_type] is anything other than a String or null value, it is invalid. Otherwise, it is valid, and so we remove variable_type from variables. That way, it does not go through the value.is_a?(String) && !value.empty? check on line 145.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. Thanks

@msohailhussain
Copy link
Contributor

@brandonhudavid Can you please resolve lint errors.

@coveralls
Copy link

coveralls commented Jul 29, 2019

Coverage Status

Coverage decreased (-0.05%) to 99.467% when pulling e16983b on brandon/get_feat_var into 17c07b6 on master.

Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

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

I see these two extraneous files in your commit:
experiment_to_return, and variation_to_return, can you remove em?

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

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

lgtm

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.

4 participants