This file contains 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
var ary = [{a:1, b:2, c:3}, {a:3, b:5, c:3}, {a:2, b:3, c:3}, {a:2, b:2, c:3}, {a:3, b:4, c:3}, {a:3, b:3, c:3} ]; | |
JSON.stringify(ary.sort()); | |
"[{"a":1,"b":2,"c":3},{"a":3,"b":5,"c":3},{"a":2,"b":3,"c":3},{"a":2,"b":2,"c":3},{"a":3,"b":4,"c":3},{"a":3,"b":3,"c":3}]" | |
JSON.stringify(ary.sort(function(x,y){return x['a'] - y['a']})) | |
"[{"a":1,"b":2,"c":3},{"a":2,"b":3,"c":3},{"a":2,"b":2,"c":3},{"a":3,"b":5,"c":3},{"a":3,"b":4,"c":3},{"a":3,"b":3,"c":3}]" | |
JSON.stringify(ary.sort(function(x,y){return [x['a'] - y['a'],x['b']-y['b']]})) | |
"[{"a":1,"b":2,"c":3},{"a":2,"b":3,"c":3},{"a":2,"b":2,"c":3},{"a":3,"b":5,"c":3},{"a":3,"b":4,"c":3},{"a":3,"b":3,"c":3}]" |
This file contains 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
require 'spec_helper' | |
describe 'Example with let' do | |
let(:status) { create(:status, :screen_name => 'test_status from let')} | |
it 'should be a status' do | |
status.should be_a(Status) | |
end | |
end |
This file contains 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
[\ 21:28][~/projects/social-dashboard (master)]$ rake db:test:prepare | |
[\ 21:28][~/projects/social-dashboard (master)]$ RAILS_ENV=test rails runner "pp Status.all" | |
[] | |
[\ 21:28][~/projects/social-dashboard (master)]$ rspec spec/models/test_db_pollution_spec.rb | |
example with an exception | |
should be a status (FAILED - 1) | |
example with before :each | |
should be a status |