Skip to content

Instantly share code, notes, and snippets.

@cpruitt
cpruitt / answer.rb
Last active January 31, 2017 16:25 — forked from adavia/answer.rb
Reject based on deep nested blank attributes
class Answer < ApplicationRecord
has_one :answer_open, dependent: :destroy
has_one :answer_rating, dependent: :destroy
accepts_nested_attributes_for :answer_open, reject_if: :all_blank
accepts_nested_attributes_for :answer_rating, reject_if: :all_blank
end
it "opens the file correctly" do
file_path = "/some/path/to.xml"
xml = "<xml>bleh</xml>"
stub_file = stub("fake_file")
stub_file.stub(:read).and_return(xml)
File.stub(:open).and_return(stub_file)
reader = Wastead::DataReader::XMLReader.new()
reader.should_receive(:process_xml).with(xml)
@cpruitt
cpruitt / cap_notify.rb
Created March 8, 2012 17:33 — forked from johnthethird/cap_notify.rb
Capistrano deployment email notifier for Rails 3
=begin
Capistrano deployment email notifier for Rails 3
Do you need to send email notifications after application deployments?
Christopher Sexton developed a Simple Capistrano email notifier for rails. You can find details at http://www.codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html.
Here is Rails 3 port of the notifier.
The notifier sends an email after application deployment has been completed.