Skip to content

Instantly share code, notes, and snippets.

View danieljohnmorris's full-sized avatar
😀

Daniel Morris danieljohnmorris

😀
View GitHub Profile
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@danieljohnmorris
danieljohnmorris / fb_pixels.html
Last active August 29, 2015 14:27
FB Conversion Pixel Ads
<!-- Facebook Conversion Code for Signup success - Fans of Alumni - Website Clicks -->
<script>(function() {
var _fbq = window._fbq || (window._fbq = []);
if (!_fbq.loaded) {
var fbds = document.createElement('script');
fbds.async = true;
fbds.src = '//connect.facebook.net/en_US/fbds.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(fbds, s);
_fbq.loaded = true;
<!-- pulse survey invite code -->
<!--#if expr="$bbcpage_survey_go = 1" -->
<div lang="en-GB" class="pulse-bar blq-reset" id="pulse-container">
<div id="pulse-q">
<p>Help us to keep our finger on the pulse.</p><p><strong>Do you have 5 minutes to tell us what you think about this site?</strong></p>
</div>
<ul class="blq-clearfix" id="pulse-a">
<li><a href="/survey/pulse/global/redirect/index.shtml?scope=global&survey=yes&surveyname=<!--#echo var='bbcpage_survey_cookie_value'-->&site=<!--#echo var='bbcpage_surveysite'-->&url=<!--#echo var='bbcpage_surveysite_url'-->&js=yes&uid=<!--#echo var='survey_bbcuid' -->" id="pulse-accept">Yes</a></li>
<li id="pulse-reject-container"><a href="/survey/pulse/global/redirect/index.shtml?scope=global&survey=no&surveyname=<!--#echo var='bbcpage_survey_cookie_value'-->&site=<!--#echo var='bbcpage_surveysite'-->&url=<!--#echo var='bbcpage_surveysite_url'-->&js=yes&uid=<!--#echo var='survey_bbcuid' -->" id="pulse-reject">No</a></li>
</ul>
[root@pal lib-test]# phing -Dwebapp.name=twitterbridge -Dwebapp.root=/mnt/hgfs/workspace/twitterbridge/webapp/ -f all_tests.xml
Buildfile: /mnt/hgfs/workspace/twitterbridge/webapp/php/lib-test/all_tests.xml
twitterbridge Tests > dir_setup:
twitterbridge Tests > test:
[PHP Error] require_once(PHPUnit/Util/Log/XML.php): failed to open stream: No such file or directory [line 22 of /usr/share/pear/phing/tasks/ext/phpunit/phpunit3/XMLPHPUnit3ResultFormatter.php]
PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Util/Log/XML.php' (include_path='../modules/twitterbridge/models:/usr/share/php/test:/mnt/hgfs/workspace/twitterbridge/webapp/conf:/mnt/hgfs/workspace/twitterbridge/webapp/php/lib-test:/mnt/hgfs/workspace/twitterbridge/webapp/php/lib:/data/WORK/open.bbc.co.uk/htdocs:/data/WORK/open.bbc.co.uk/php/lib:/data/WORK/open.bbc.co.uk/php/modules:/data/WORK/open.bbc.co.uk/php/lang:/data/WORK/open.bbc.co.uk/php/views:/data/WORK/open.bbc.co.uk/conf:/data/WORK/bbc.co.uk/htdocs:/data/WORK/bbc.co.uk/p
@danieljohnmorris
danieljohnmorris / app_template__resque.rb
Created May 5, 2010 20:31
r3 app tpl - load resque
# usage (in app dir):
# rake rails:template LOCATION=http://gist.github.com/391381.txt
gem 'resque', :git => 'git://github.com/defunkt/resque.git'
gem 'resque-scheduler'
file 'config/resque.yml', <<-FILE
development: localhost:6379
test: localhost:6379
staging: redis1.se.github.com:6379
@danieljohnmorris
danieljohnmorris / app_template__obvious_stuff.rb
Created May 12, 2010 18:26
r3 app tpl - obvious stuff ie. remove public.html etc
# usage (in app dir):
# rake rails:template LOCATION=http://gist.github.com/398938.txt
# make a sensible gitignore
file ".gitignore", <<-EOF
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
# usage (in app dir):
# rake rails:template LOCATION=http://gist.github.com/398938.txt
# apply obvious
apply "http://gist.github.com/398936.txt"
# apply resque
apply "http://gist.github.com/391381.txt"
# apply auth
# usage (in app dir):
# rake rails:template LOCATION=http://gist.github.com/403207.txt
### Append edge rails lines to end of Gemfile
# get existing file
gemfile_contents = File.readlines 'Gemfile'
# uncomment edge rails statement (line #6)
gemfile_contents[5].sub!('#', '').lstrip!
@danieljohnmorris
danieljohnmorris / app_template__resque__r3_friendly.rb
Created May 18, 2010 10:42
r3 app tpl - load resque in a r3 friendly way
# usage (in app dir):
# rake rails:template LOCATION=http://gist.github.com/404864.txt
gem 'redis', '1.0.7' # bugfix for "uninitialized constant Redis::Client::ALIASES"
gem 'resque'
gem 'resque-scheduler' # non-blocking cron-alternative daemon
file "script/install_redis", <<-CODE
#!/bin/bash
git clone git://github.com/defunkt/resque.git vendor/resque
@danieljohnmorris
danieljohnmorris / app_template__prepare_testing.rb
Created May 19, 2010 12:31
r3 app tpl - setup cucumber and rspec for rails
# usage (in app dir):
# rake rails:template LOCATION=http://gist.github.com/406257.txt
gem "database_cleaner"
group :test do
gem "launchy" # So you can do Then show me the page
# gem "capybara" # alternative to webrat
gem "spork"
gem "cucumber-rails"
gem "cucumber", "0.7.2"