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
$ time rake test:parallel | |
(in /Users/jasonmorrison/dev/myapp/trunk) | |
2 processes for 49 tests, ~ 24 tests per process | |
Loaded suite -e | |
Started | |
.................................. (abbreviated) | |
29.32s user 3.31s system 143% cpu 22.669 total |
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
$ time rake test:units test:functionals | |
Started | |
.......... (abbreviated... FOR BLOG READING SPEED!!) | |
415 tests, 898 assertions, 0 failures, 0 errors | |
29.14s user 3.74s system 87% cpu 37.614 total |
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
$ script/plugin install git://github.com/jasonm/parallel_specs.git |
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 db:structure:dump | |
$ echo "create database myapp_test2;" | mysql -uroot | |
$ mysql -uroot -Dmyapp_test2 < db/development_structure.sql | |
$ vim config/database.yml # add some ERB to config/database.yml | |
test: | |
adapter: mysql | |
encoding: utf8 | |
database: myapp_test<%= ENV['TEST_ENV_NUMBER'] %> | |
username: root |
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
$ time rake test:parallel | |
(in /Users/jasonmorrison/dev/myapp/trunk) | |
2 processes for 49 tests, ~ 24 tests per process | |
Loaded suite -e | |
Started | |
.................................. (abbreviated) | |
29.32s user 3.31s system 143% cpu 22.669 total |
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
posts = Post.find do | |
user.email =~ "%thoughtbot%" | |
tags.name === %w( ruby rails ) | |
created_on <=> [ 2.weeks.ago, 1.week.ago ] | |
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
query = User.find do | |
company.name = cname? | |
order_by created_on | |
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
users = query.find(:cname => "thoughtbot") | |
</code></pre> | |
Now, what's tricky is that you could pass any syntax-changing value to that and you'd get the right SQL in the executed query. | |
<filter:code lang="ruby"> | |
query.find :cname => "thoughtbot" # => company.name = "thoughtbot" | |
query.find :cname => nil # => company.name IS NULL | |
query.find :cname => ["Google", "37 Signals"] # => company.name IN ("Google", "37 Signals") |
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 Person < ActiveRecord::Base | |
has_one :address, :as => :addressable | |
end | |
class Company < ActiveRecord::Base | |
has_one :address, :as => :addressable |
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 Address < ActiveRecord::Base | |
belongs_to :person | |
belongs_to :company | |
end |