- View first, then Controller and Model last.
- In Controller tests:
- Don't mock ActiveRecord method
- Do stub ActiveRecord method (No real SQL execution allowed)
- Do mock custom model method
- Use signature from model mock to create real method in model (or module)
- Should not contain more than 5 lines or 10 function calls
- In Model tests:
- Do real SQL execution (No mock, no stub)
Saturday, March 3, 2012
Personal (and non-popular) Rails development rules of thumb
Saturday, December 24, 2011
[PostgreSQL][Mac] Modify root password (Forgot password)
- sudo su postgres
- supply your Mac password
- modify /Library/PostgreSQL/9.x/data/pg_hba.conf
- from local all all md5
- to local all all trust
- execute /Library/PostgreSQL/9.x/bin/pg_ctl restart -D /Library/PostgreSQL/9.x/data/
- run psql
- change postgres password
- ALTER USER postgres WITH ENCRYPTED PASSWORD 'password';
- modify pg_hba.conf back
- restart again
Tested with PostgreSQL version 9.1 OSX Lion
Sunday, December 4, 2011
Learn some Ruby syntaxes from company source code
I think the fastest way to catch up Ruby and Rails idiomatic of my new company is to learn from it directly instead of learning from other available tutorials or books. Below is my note on this learning.
Rake
Exec shell command
- string.chomp to remove new line in end of string
Rake
Exec shell command
- use back-quote such as `ls`
- return string from stdout
- access Process object with $? such as $?.success
- (not related to Ruby) `command 2>/dev/null` get rid of stderr
- string.chomp to remove new line in end of string
RSpec a lot of things on https://www.relishapp.com/rspec
Thursday, December 1, 2011
[MacOSX] How to modify enviroment.plist without any additional tools
- Convert enviroment.plist to XML format with plutil -convert xml1 environment.plist
- Edit it.
- Convert it back to binary format with plutil -convert binary1 environment.plist
[RubyMine] invalid byte sequence in US-ASCII
I had this problem when I tried to bundle install. This causes from System Environment Variables which RubyMine is using is different from you shell and LANG is default to US-ASCII.
You can fix this (For 10.6+) by add LANG=en_US.UTF-8 to ~/.MacOSX/enviroment.plist
Please checkout How to modify enviroment.plist without any additional tools
You can fix this (For 10.6+) by add LANG=en_US.UTF-8 to ~/.MacOSX/enviroment.plist
Please checkout How to modify enviroment.plist without any additional tools
Sunday, November 6, 2011
[VIM] Make newly created file(s) available for search with FuzzyFinder
Once your FuzzyFinder has loaded current files, if you create a new file, you have to tell it to reload it by execute:-
Source: FuzzyFinder : buffer/file/command/tag/etc explorer with fuzzy matching
Thanks: @virasak
:FufRenewCache
Source: FuzzyFinder : buffer/file/command/tag/etc explorer with fuzzy matching
Thanks: @virasak
How to add helper method to Cucumber's World
Add this line to any files under features/supports/ directory
Then you can access method inside the module in all of your Cucumber's step definitions.
Credit: #51 Integration Tests With Cucumber
World({any_module_names})Module's name here can be a predefined Rails's helper or your application helper or a new helper which is just created here.
Then you can access method inside the module in all of your Cucumber's step definitions.
Credit: #51 Integration Tests With Cucumber
Subscribe to:
Posts (Atom)
Collectd PostgreSQL Plugin
I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...
-
sudo su postgres supply your Mac password modify /Library/PostgreSQL/9.x/data/pg_hba.conf from local all all md5 to local all all ...
-
This error occurs when you or some of your vim plugins try to access register '*' which is a system clipboard. In default Mac OSX vi...
-
Put your cursor on the text box of the post/comment you want to indent Go to the menubar at the top of the screen Edit > Emoji & ...