-
Notifications
You must be signed in to change notification settings - Fork 52
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
Flesh out handling of Updates #13
base: master
Are you sure you want to change the base?
Conversation
ghost
commented
Dec 19, 2013
- Provide explicit attribute accessors for the Update type
- Handle "more updates" in a manner consistent with the existing "more projects" functionality
- Add tests to the client spec and a new update spec
Provide sequence number, title and body members.
Add methods to check for the presence of "more updates" and load them if possible. Mirror the "more projects" functionality for the sake of consistency.
These two commits address different but related issues, so I can squash them and open a new pull request if that is preferable. |
Thanks for the contribution, can you also add some tests for these? I'd prefer to see less in-code comments and more tests which describe the desired behaviour and handling of edge cases. Any comments from @markolson or @benrugg ? |
Sure thing, I'll work on getting some tests together. |
My one comment isn't particularly relevant to this PR, but the pattern
is repeated a lot, and we can probably DRYing that up easily :) |
Hey, @ajkerrigan, thanks for adding this functionality. It's great to have more contributions to kickscraper! |
- Add an update spec to test operations that apply to individual updates - Add tests to the client spec for higher level operations that touch updates in bulk
I've added some tests, and had to tweak a couple things along the way to get them all to pass. I guess that's how it's supposed to work! I added small comments in one or two places where the necessary changes were not obvious (at least to me). I'm pretty green when it comes to Ruby, RSpec and open source contributions in general - so don't be shy if these changes don't jive with the conventions you've established. |
Sorry nobody has checked this out yet. I'll try to get to it sometime soon. Or if anyone else has a chance, go for it! |
end | ||
|
||
it "throws an error when accessing updates without a valid project loaded" do | ||
subject { client.find_project TEST_PROJECT_ID } |
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.
Hey, just looking at this right now. I'm wondering if this test is actually passing for the wrong reason. If TEST_PROJECT_ID is a valid project, why is subject nil on the next line?
Maybe the subject should be in a context block, and it should search for an invalid project id?
Hey @ajkerrigan, thanks again for adding this functionality. It looks great to me. I made one note on a specific test if you want to check that out... |
Ah yes I see what you're saying there. It may be that I'm misunderstanding something about how the context "loads more projects after a successful search" do
subject do
client.recently_launched_projects
client.more_projects_available?.should be_true
client.load_more_projects
end
it_returns "a collection", Kickscraper::Project
end It looked to me like the context "loads more updates when available" do
before { client.find_project(TEST_PROJECT_ID) }
describe "more updates are available" do
subject { client }
its(:more_updates_available?) { should be_true }
end
describe "more updates load properly" do
subject { client.load_more_updates }
it_returns "a collection", Kickscraper::Update
end
end |
Ah yeah, gotcha. You know what... I was talking about the test "throws an error when accessing updates without a valid project loaded". That one seemed weird to me, because it seemed like the way the code is written, it is pulling in a valid project for the subject, rather than an invalid one. But, I think you're right about the new way of writing the other two tests. That looks more semantic. Either way I think is probably fine. (But I'm not a guru at writing tests!) |
CAVEAT: I've not looked at this since June and I'm currently working in NodeJS so my memory is a bit fuzzy :) Just a thought but why are these update methods on client.rb and not on project? After all the updates are only related to a given project. It seems from your commit that This would then lead to: context "loads more updates when available" do
let(:project) { client.find_project(TEST_PROJECT_ID) }
describe "more updates are available" do
subject { project }
its(:more_updates_available?) { should be_true }
end
describe "more updates load properly" do
subject { project.load_more_updates }
it_returns "a collection", Kickscraper::Update
end
end |
That's a valid point @jamlen - I'll see about airlifting the update logic from client to project. I remember thinking about where to put the code initially, and now that you ask I can't recall a good reason for putting it on the client. |
Hey @ajkerrigan, a bunch of the code base has changed since you originally submitted this update... Would you like to check it out and see if your new changes still work? I think we can pull this in, especially if you move the new methods to project instead of client... |
I won't be able to devote any time to this until at least next week, but I'd like to have a look and see what if anything can be salvaged. It won't meet my original need (crawling public and private updates for a user's backed projects), but I do think there's still some value in the pure public approach. I agree that the methods make more sense on project. I'm struggling to remember why the heck I put them on client to begin with! |
Cool, thanks for checking it out again. I haven't done any work with pulling in project updates, but I'd love to see what's possible. (There are still both public and private api calls, so maybe you can do both for the updates). |