Skip to content

User stories 1 and 2 completed (temporary solution to user story 4)#237

Open
jormark wants to merge 1 commit into
makersacademy:mainfrom
jormark:main
Open

User stories 1 and 2 completed (temporary solution to user story 4)#237
jormark wants to merge 1 commit into
makersacademy:mainfrom
jormark:main

Conversation

@jormark
Copy link
Copy Markdown

@jormark jormark commented Jul 18, 2022

Your name

Jordan Markham

User stories

Please list which user stories you've implemented (delete the ones that don't apply).

  • User story 1: "I want to see all the messages (peeps) in a browser"
  • User story 2: "I want to post a message (peep) to chitter"
  • User story 4: "I want to see a list of peeps in reverse chronological order"

README checklist

Does your README contains instructions for

Here is a pill that can help you write a great README!

Copy link
Copy Markdown
Author

@jormark jormark left a comment

Choose a reason for hiding this comment

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

Overall good test coverage, program works as expected and meets the checked requirements. However, formatting the output for better coherency is required, along with a README with instructions on how to operate the program.

Comment thread lib/peep.rb

class Peep
def self.all
if ENV['ENVIRONMENT'] == 'test'
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

There could be a method for this, in order to avoid repeating code!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good observation! If you hadn't commented on it yourself, I would have 😁

expect(page).to have_content "Yoyoyo!"
expect(page).to have_content "http://www.google.com"
end
end No newline at end of file
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Always include a new line at the end of a code file!

@@ -0,0 +1,10 @@
feature 'Creating a new peep' do
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Test coverage is good, but the types of input (try invalids too?) aren't being tested. Only one type of input is being tested here...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's a good point. To make your application more robust, you'd want to make sure you caught invalid inputs and test that too. In the context of this challenge, it's a good enough feature test though :)

Comment thread views/home.erb
<button value="Submit" type="submit">Peep!</button>
</form>

<p><%= @all_peeps.join('/n') %></p>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This wouldn't work - ('/n') would just show up as a string. Maybe "/n" (full quotation marks) would work?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the HTML equivalent of a line break? That's the thing to research.

Copy link
Copy Markdown
Contributor

@siellsiell siellsiell left a comment

Choose a reason for hiding this comment

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

Hey Jordan,

Your code is very clean and readable and you've already made some great observations of your own about how you could improve it. I added a few more comments below.

I was wondering what led you to use the temporary solution to user story 4 -- were just not very keen to implement user story 3 or did you get blocked somewhere?

If you have any questions, just answer on here in the comments or DM me.

Comment thread app.rb
Comment on lines 10 to 12
get '/test' do
'Test page'
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's always a good idea to remove test code from code you submit for code review (anywhere, not just at Makers). Just keeps things clean and easy to follow.

Comment thread lib/peep.rb

class Peep
def self.all
if ENV['ENVIRONMENT'] == 'test'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good observation! If you hadn't commented on it yourself, I would have 😁

@@ -0,0 +1,10 @@
feature 'Creating a new peep' do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's a good point. To make your application more robust, you'd want to make sure you caught invalid inputs and test that too. In the context of this challenge, it's a good enough feature test though :)

Comment thread spec/homepage_spec.rb
Comment on lines +15 to +17
expect(peeps).to include('New Peep 1!')
expect(peeps).to include('Yoyoyo!')
expect(peeps).to include('http://www.google.com')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As you're using include, this doesn't actually test that the peeps are in the right order.

Comment thread views/home.erb
<button value="Submit" type="submit">Peep!</button>
</form>

<p><%= @all_peeps.join('/n') %></p>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the HTML equivalent of a line break? That's the thing to research.

Comment thread spec/homepage_spec.rb

describe '.all' do
it 'returns all peeps in reverse chronological order' do
connection = PG.connect(dbname: 'chitter_test')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you actually need this line?

Comment thread lib/peep.rb
end

result = connection.exec "SELECT * FROM peeps"
return result.map{ |elem| elem["message"]}.reverse
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can actually use the database query to sort the peeps in the right order and save the extra reversal step: https://www.postgresql.org/docs/current/queries-order.html
If you had a lot of peeps, this could improve perfomance quite a lot.

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.

2 participants