This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe Sweeper do | |
context 'a subscription is expired' do | |
let(:bob) { double(active?: true, paid_at: 2.months.ago) } | |
let(:users) { [bob] } | |
before { allow(User).to receive(:all).and_return(users) } | |
it 'emails the user' do | |
expect(UserMailer).to receive(:billing_problem).with(bob) | |
described_class.sweep | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instructions for this test: | |
# 1. Please clone this gist as a git repo locally | |
# 2. Create your own github repo called 'rubytest' (or a name of your choice) and add this repo as a new remote to the cloned repo | |
# 3. Edit this file to answer the questions, and push this file with answers back out to your own 'rubytest' repo. | |
# Problem 1. Explain briefly what this code does. Create a RSpec unit test for | |
# it, fix any bugs, then clean up the syntax to be more idiomatic Ruby and make | |
# sure your tests still pass. | |
# | |
# Your spec should have at least 3 contexts/conditional tests (what are they?) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Reverb::Actions::WatchListing | |
def self.watch(user, product, listener) | |
if product.owner?(user) | |
listener.failure(I18n.t('flash.watchlist.error_own')) | |
else | |
Reverb::Analytics.track(user, :watch_product) # FIXME, this doesn't belong here | |
user.user_watch_products.create(:product_id => product.id) | |
listener.success | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bcx david$ rake stats | |
+----------------------+-------+-------+---------+---------+-----+-------+ | |
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M | | |
+----------------------+-------+-------+---------+---------+-----+-------+ | |
| Controllers | 3704 | 2942 | 72 | 479 | 6 | 4 | | |
| Helpers | 1901 | 1529 | 13 | 261 | 20 | 3 | | |
| Models | 5310 | 4116 | 50 | 653 | 13 | 4 | | |
| Libraries | 2167 | 1593 | 51 | 200 | 3 | 5 | | |
| Integration tests | 297 | 217 | 6 | 1 | 0 | 215 | | |
| Functional tests | 3897 | 3065 | 61 | 11 | 0 | 276 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logCall() { | |
console.log(logCall.caller.name + '(' + | |
Array.prototype.slice.call(logCall.caller.arguments) | |
.map(JSON.stringify).join(', ') + | |
')'); | |
} |