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

Updated Rails, Fixed Tests, Updated Readme #34

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Updated Rails, Fixed Tests, Updated Readme #34

wants to merge 10 commits into from

Conversation

natesire
Copy link

Changes Made

  1. Updated Readme to explain the sql output file is stored in the db directory. I was looking in the project root directory.

  2. Updated the gem to use the latest active record version.

  3. Fixed a faulty test that was searching an array for added sql statements.

Copy link
Contributor

@brandonjoyce brandonjoyce left a comment

Choose a reason for hiding this comment

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

Thanks for contributing! Just a few suggestions. Let me know what you think.

@@ -28,14 +29,14 @@
)
end

it 'formats selects by 1 count' do
Copy link
Contributor

Choose a reason for hiding this comment

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

This test isn't checking the formatting so this might be a better name:
it 'appends 1 statement'

'ORDER BY "widgets"."id" DESC LIMIT 1'
)
ap statements.to_a
expect(statements.to_a.to_s).to include '\"widgets\".\"name\" = ?'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might be better to leave this test as it was before. Since we're testing the formatting of the output, I kinda like the thoroughness of looking for the whole statement.

@@ -34,4 +34,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'sqlite3'
spec.add_development_dependency 'rubocop', '~> 0.37.0'
spec.add_development_dependency 'rubocop-rspec'
spec.add_development_dependency 'awesome_print'
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we kill this before merging? I'm not sure it adds enough value to stay.

@brandonjoyce
Copy link
Contributor

Oh, also looks like failing on CI if you don't mind checking what's up with that.

@natesire
Copy link
Author

natesire commented Apr 13, 2018 via email

@brandonjoyce
Copy link
Contributor

I agree with your statements on the differences between high and low level tests, but I'm thinking of specs/sql_footprint_spec.rb as the high level integration tests while most of the smaller scope tests are in the spec/sql_footprint/ folder.

Here's where the high level version provides value: It looks like the new version of ActiveRecord changed the ordering of the sql statement syntax which caused the long form test to fail for you. I think that's important feedback to get from the test suite even if it's a little harder to read. With that information we can inform users that an upgrade will cause some churn in their footprint files ahead of time.

I'm totally ok with adding some more granular tests as well though if you're looking for specific things.

Disclaimer: It's been quite a while since I've updated anything in the project so I'm open to hearing that I'm wrong. 😄

@natesire
Copy link
Author

natesire commented Apr 13, 2018 via email

README.md Outdated
@@ -65,7 +65,8 @@ Or if you're using FactoryGirl you could do something like this:
RSpec.configure do |config|
module FactoryBoy
def create(*args)
SqlFootprint.exclude { FactoryGirl.create(*args) }
``` FactoryGirl changed their gem name to FactoryBot ```
Copy link
Contributor

Choose a reason for hiding this comment

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

hrm ... FactoryBoy is no longer a very good name for this module. It was meant as a companion to FactoryGirl, now it looks like a typo.

@natesire
Copy link
Author

natesire commented Apr 13, 2018 via email

@natesire
Copy link
Author

natesire commented Apr 14, 2018 via email

.gitignore Outdated
@@ -9,3 +9,6 @@
/tmp/
footprint.sql
footprint.:memory:.sql
.idea/

Choose a reason for hiding this comment

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

It would be better to add this to your .gitignore_global file rather than checking in intelliJ specific stuff here. Presumably the same applies to the rbenv stuff.

@natesire
Copy link
Author

natesire commented Jun 6, 2018 via email

.gitignore Outdated
@@ -9,3 +9,5 @@
/tmp/
footprint.sql
footprint.:memory:.sql
.rbenv-gemsets
.gems
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these two things might be specific to your tool choices, too. Or, do you think other devs will be installing gems in .gems too?

matches.push 'ORDER BY "widgets"."id" DESC'
matches.push 'LIMIT ?'

puts statements.to_a.to_s
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove this puts before merging?

@natesire
Copy link
Author

natesire commented Jun 6, 2018 via email

matches.push 'LIMIT ?'

matches.each do |match|
expect(statements.to_a.detect { |record| record.match match }).not_to be_nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I stared at this for a while trying to think of a simpler way of stating it, but I've got nothing. Would be nice to simplify, if possible.

@mikegee
Copy link
Contributor

mikegee commented Jun 7, 2018

@nathantech2005 if you can think of a way to rewrite that one spec to be simpler for the next reader, that would be amazing. Otherwise, wanna squash this into a commit or two? Seems like we have more commits that diff here 😛

nathansire added 2 commits June 7, 2018 13:50
less brittle test.
clean up 2 rubocop offenses.
clean up multi line.
clean up multi line.
testing older active record version.
try upgrading rubocop version.
needs rubocop version .40
narrowing gem versions to make more maintainable.
ruby v2 uses older active record.
add pry back
bizarre active record errors.
don't specify active record version.
try setting minimum gem version.
better name for FactoryBoy.
ignore jetbrains files using ~/.gitignore_global instead of locally in .gitignore
remove two more ignored files.
remove debug code
@natesire
Copy link
Author

natesire commented Jun 7, 2018 via email

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