Skip to content

Instantly share code, notes, and snippets.

@clayton
clayton / gist:648e8bd5b768cd513a28
Created July 12, 2015 07:55
Building on SOLID foundations - Steve Freeman & Nat Pryce - Breakout Session from Software Architect 2013
https://www.youtube.com/watch?v=6Bia81dI-JE
Building on SOLID foundations - Steve Freeman & Nat Pryce
10:00 - Ravioli Code
12:15 - Spaghetti and Meatballs
* Brittle event flow tying objects together
13:30 - Tangle of Wires
* You can wiring your objects together, using DI, but everything
is just tangled together with all of this wiring between objects
desc "Run all features"
task :features => 'db:test:prepare'
task :features => "features:all"
require 'cucumber/rake/task' #I have to add this -mischa
require 'spec/rake/spectask'
namespace :rcov do
Cucumber::Rake::Task.new(:cucumber) do |t|
t.rcov = true
t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data}
class Compare
def self.similar_between?(keeper, finder)
finder_scan = finder.scan(/./)
keeper_scan = keeper.scan(/./)
same = []
keeper_scan.each_with_index{ |char, key| same << char if finder_scan[key] == char }
same.join
end
end
# From http://github.com/jaymcgavren
#
# Save this as rcov.rake in lib/tasks and use rcov:all =>
# to get accurate spec/feature coverage data
require 'cucumber/rake/task'
require 'spec/rake/spectask'
namespace :rcov do
Cucumber::Rake::Task.new(:cucumber) do |t|
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 1462 | 1189 | 49 | 200 | 4 | 3 |
| Helpers | 535 | 413 | 0 | 39 | 0 | 8 |
| Models | 2641 | 2004 | 67 | 267 | 3 | 5 |
| Libraries | 1320 | 992 | 9 | 132 | 14 | 5 |
| Model specs | 5554 | 4309 | 0 | 5 | 0 | 859 |
| View specs | 0 | 0 | 0 | 0 | 0 | 0 |
| Controller specs | 2866 | 2230 | 2 | 25 | 12 | 87 |
And I should receive an email #features/step_definitions/email_steps.rb:51
undefined method `unread_emails_for' for #<ActionController::Integration::Session:0x102aea080> (NoMethodError)
./features/step_definitions/email_steps.rb:52:in `/^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/'
features/user_signup.feature:20:in `And I should receive an email'
==============
# KEEP PRACTICE
hack = current_account.users.find_by_email(params[:user_session][:login])
namespace :ci do
Rake.application.remove_task("ci:run")
task :run do
Rake::Task["spec"].invoke
end
end
<% if @panel1_product.max_qty > 0 && @panel1_product.remaining < 20 && @panel1_product.available? %>
<% if @panel1_product.remaining == 1 %>
<p class="remaining"><%= @panel1_product.remaining %> item left!</p>
<% else %>
<p class="remaining"><%= @panel1_product.remaining %> items left!</p>
<% end %>
<% end %>
def active?
today = Time.now.strftime('%Y-%m-%d %H:%M')
today >= self.begin_date.strftime('%Y-%m-%d 06:00') && today <= self.end_date.strftime('%Y-%m-%d 23:59')
end