-
Notifications
You must be signed in to change notification settings - Fork 10
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
[WEBSITE-899][WEBSITE-946][WEBSITE-950] Extract components to separate gems. #63
[WEBSITE-899][WEBSITE-946][WEBSITE-950] Extract components to separate gems. #63
Conversation
katylouise
commented
Apr 19, 2017
- Extracted decorators to separate gem.
- Extracted NTriple related code (NTripleResponseBuilder, NTripleResponse) to separate gem.
- Created a BaseResponse.
- Refactored tests.
- Refactored documentation.
# @param [String] base_url the base url of our api. (expected: http://example.com - without the trailing slash). | ||
# @param [Hash] headers the headers being sent in the request. | ||
# @param [Parliament::Builder] builder the builder to use in order to build a response. | ||
# @params [Module] decorators the decorator module to use in order to provide possible alias methods for any objects created by the builder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [146/120]
# | ||
# @raise [Parliament::ServerError] when the server responds with a 5xx status code. | ||
# @raise [Parliament::ClientError] when the server responds with a 4xx status code. | ||
# @raise [Parliament::NoContentResponseError] when the server responds with a 204 status code. | ||
# | ||
# @param [Hash] params (optional) additional URI encoded form values to be added to the URI. | ||
# | ||
# @return [Parliament::Response] a Parliament::Response object containing all of the nodes returned from the URL. | ||
# @return [Parliament::Response::BaseResponse] a Parliament::Response::BaseResponse object containing all of the data returned from the URL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [146/120]
# | ||
# @param [String] base_url the base url of our api. (expected: http://example.com - without the trailing slash). | ||
# @param [Hash] headers the headers being sent in the request. | ||
def initialize(base_url: nil, headers: nil, builder: nil) | ||
# @param [Parliament::Builder] builder the builder to use in order to build a response. | ||
# @params [Module] decorators the decorator module to use in order to provide possible alias methods for any objects created by the builder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [146/120]
5dda347
to
b8a1951
Compare
…arate gems. * Extracted decorators to separate gem. * Extracted NTriple related code (NTripleResponseBuilder, NTripleResponse) to separate gem. * Created a BaseResponse. * Refactored tests. * Refactored documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bex, I've added some comments/changes below
Gemfile
Outdated
@@ -5,3 +5,6 @@ gemspec | |||
|
|||
# Include coveralls for CI coverage reports | |||
gem 'coveralls', require: false | |||
|
|||
gem 'parliament-grom-decorators', path: '../parliament-grom-decorators' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are being used for testing we will need to either add them as development dependencies or look at how they are needed within the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also breaking tests
@@ -1,12 +1,21 @@ | |||
module Parliament | |||
module Builder | |||
# API response builder, allowing the user to return the body of an HTTPResponse. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be 'Base response builder'? It's not technically API specific
class BaseResponseBuilder | ||
def initialize(response) | ||
# Creates a new BaseReponseBuilder. | ||
# @param [HTTPResponse] response an HTTP response containing n-triple data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it need to contain ntriple data?
def initialize(response) | ||
# Creates a new BaseReponseBuilder. | ||
# @param [HTTPResponse] response an HTTP response containing n-triple data. | ||
# @param [Module] decorators the decorator modules to provide alias methods to the resulting objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be more like:
'A namespace which contains modules used to decorate the objects we receive'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Infact, is this even needed? Our base response doesn't actually use the decorators?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing the code below perhaps we need to mention why it's not used and that it is for API completeness?
@@ -1,78 +1,83 @@ | |||
module Parliament | |||
module Request | |||
# API request object, allowing the user to make a request to an API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this API specific?
@@ -61,10 +61,10 @@ | |||
end | |||
|
|||
context 'it accepts query parameters' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this actually testing?
How does this test prove that what you're expecting to happen, actually happens? You don't appear to be checking that the params hash actually generates the URL you expect? Just that a connection to that URL could be made. Infact, this response isn't even checking that it's a 200?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed this test to check the request made contains the parameters expected in the url.
@@ -24,7 +25,7 @@ | |||
end | |||
|
|||
describe '#respond_to_missing?' do | |||
subject { Parliament::Request::UrlRequest.new(base_url: 'http://test.com') } | |||
subject { Parliament::Request::UrlRequest.new(base_url: 'http://test.com', decorators: Parliament::Grom::Decorator) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this, parliament-grom-decorators should be aded as a development dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added parliament-grom-decorators as a dev dependency in the gemspec.
let(:response) { 'hello world' } | ||
subject { Parliament::Response::BaseResponse.new(response) } | ||
|
||
it 'has a response' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the correct way to test what a method returns?
spec/parliament/utils_spec.rb
Outdated
@@ -22,23 +22,23 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these utils be part of the Ntriple gem? It's directly related to that data and output?
@@ -8,6 +8,8 @@ | |||
|
|||
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) | |||
require 'parliament' | |||
require 'parliament/grom/decorator' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two should DEFINITELY be development dependencies
On top of this, you're tests fail because of the relative paths used in Gemfile |
# @param [Module] decorators the decorator module to use in order to provide possible alias methods for any objects created by the builder. | ||
# @example Passing headers | ||
# | ||
# request = Parliament::Request::UrlRequest.new(base_url: 'http://example.com', headers: { 'Access-Token' => '12345678' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [128/120]
# @param [String] base_url the base url of our api. (expected: http://example.com - without the trailing slash). | ||
# @param [Hash] headers the headers being sent in the request. | ||
# @param [Parliament::Builder] builder the builder to use in order to build a response. | ||
# @param [Module] decorators the decorator module to use in order to provide possible alias methods for any objects created by the builder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [145/120]
def initialize(response) | ||
# Creates a new BaseReponseBuilder. | ||
# @param [HTTPResponse] response an HTTP response. | ||
# @param [Module] decorators a namespace which contains modules used to decorate the objects we receive. It is not used directly by the BaseResponseBuilder, but is there for API completeness. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [198/120]