Create an application that can read in pairs of dates in the following format -
DD MM YYYY, DD MM YYYY
Validate the input data, and compute the difference between the two dates in days.
require 'spec_helper' | |
describe "Artists to releases relationship" do | |
before(:all) do | |
@kanye = FactoryGirl.create(:artist, :name => 'Kanye West') | |
@jz = FactoryGirl.create(:artist, :name => 'Jay Z') | |
@watch_the_throne = FactoryGirl.create(:release, :name => 'Watch the Throne') | |
@dropout = FactoryGirl.create(:release, :name => 'The College Dropout') | |
end |
# A. Less nested contexts, clearer object collaboration at the cost of repetition | |
describe PlaceParameters do | |
describe '#sort_by' do | |
it 'concatenates the sort_by and sort_dir params' do | |
params = { sort_by: 'name', sort_dir: 'asc' } | |
sort_by = PlaceParameters.new(params).sort_by | |
expect(sort_by).to match /^name asc$/i |
# DISCLAIMER: Beer was consumed | |
# Need to make assertions about ActiveRecord query messages applied to | |
# a model but don't want to include AR as a dependency? Feeling yolo? | |
# I had that situation lately with a gem that takes params and uses macros | |
# to build a scoped relation (github.com/hooroo/query_ar), so I cooked this up. | |
# Usage is as follows. |