This file contains hidden or 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
# The following is an example of how you might use shared content to reduce the | |
# duplication in https://gist.github.com/1128108. I prefer to avoid examples | |
# that use `should respond_to`, as it specifies structure rather than behavior. | |
# I'd recommend specifying something about what happens when the message is | |
# sent, e.g. subject.some_method.should eq(some_value). That implicitly | |
# specifies that the object responds to some_method, and provides more useful | |
# direction/information about how the object should behave. | |
# | |
# That said ... |
This file contains hidden or 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
with_attribute(SomeModel, :record_timestamps).temporarily(false) do | |
model_instance.update_attributes(:updated_at => 35.minutes.ago) | |
end | |
with_attribute(SomeModel, :record_timestamps, false) do | |
model_instance.update_attributes(:updated_at => 35.minutes.ago) | |
end | |
SomeModel.with(:record_timestamps, false) do # with, with_temp, with_attr??? | |
model_instance.update_attributes(:updated_at => 35.minutes.ago) |
This file contains hidden or 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 MacropostsController < ApplicationController | |
before_filter :authenticate | |
before_filter :authorized_user, :only => :destroy | |
def create | |
params[:macropost][:user_id] = current_user.id | |
params[:macropost][:project_id] = params[:project_id] | |
@macropost = Macropost.new(params[:macropost]) | |
if @macropost.save |
This file contains hidden or 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 PostsController do | |
let(:post) { Factory(:post) } | |
describe "PUT #update" do | |
it "allows an author to edit a post" do | |
sign_in post.author | |
put :update, :id => post.id | |
response.should be_successful | |
end |
This file contains hidden or 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
$ which ruby | |
/Users/david/.rvm/rubies/ruby-1.8.6-p420/bin/ruby | |
$ gem install ruby-debug | |
Building native extensions. This could take a while... | |
ERROR: Error installing ruby-debug: | |
rbx-require-relative requires Ruby version ~> 1.8.7. | |
# why is anything rbx related coming into play in an mri 1.8.6 env????? |
This file contains hidden or 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
service = flexmock() | |
client = Client.new(service) | |
service.should_receive(:expensive_method).once.and_return('some data') | |
client.method_that_invokes_expensive_method_on_service | |
client.method_that_invokes_expensive_method_on_service |
This file contains hidden or 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
$ rake | |
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01. | |
Gem.source_index called from /Users/dchelimsky/.rvm/gems/ree-1.8.7-2011.03@chart/gems/rails-2.3.12/lib/rails/gem_dependency.rb:21. | |
NOTE: Gem::SourceIndex#spec_dirs= is deprecated, use Specification.dirs=. It will be removed on or after 2011-11-01. | |
Gem::SourceIndex#spec_dirs= called from /Users/dchelimsky/.rvm/gems/ree-1.8.7-2011.03@chart/gems/bundler-1.0.14/lib/bundler/rubygems_integration.rb:175. | |
NOTE: Gem::SourceIndex#add_specs is deprecated with no replacement. It will be removed on or after 2011-11-01. | |
Gem::SourceIndex#add_specs called from /Users/dchelimsky/.rvm/gems/ree-1.8.7-2011.03@chart/gems/bundler-1.0.14/lib/bundler/rubygems_integration.rb:176. | |
NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01. | |
Gem::SourceIndex#add_spec called from /Users/dchelimsky/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:1 |
This file contains hidden or 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
shared_context 'user' do | |
before :all do | |
@user = User.create( :name => "Bob", :password => "foo", :admin => false ) | |
end | |
def login | |
visit( url( :login ) ) | |
fill_in :name, :with => "Bob" | |
fill_in :password, :with => "foo" | |
click_button "Login" |
This file contains hidden or 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
$ gem -v | |
1.8.5 | |
$ rake -T | |
(in /Users/dchelimsky/work/chart) | |
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01. | |
Gem.source_index called from /Users/dchelimsky/work/chart/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:21. | |
NOTE: Gem::SourceIndex#refresh! is deprecated with no replacement. It will be removed on or after 2011-11-01. | |
Gem::SourceIndex#refresh! called from /Users/dchelimsky/work/chart/config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:34. | |
NOTE: Gem::SourceIndex#load_gems_in is deprecated with no replacement. It will be removed on or after 2011-11-01. | |
Gem::SourceIndex#load_gems_in called from /Users/dchelimsky/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:320. |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>JQuery example</title> | |
<script src="jquery.js" type="text/javascript"></script> | |
<script type='text/javascript'> | |
//<![CDATA[ | |
$(function() { | |
$('.panel').bind('showDescription', function() { | |
$(this).show(); |