$ rails g model User
belongs_to
has_one
| #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) |
| # in spec/support/omniauth_macros.rb | |
| module OmniauthMacros | |
| def mock_auth_hash | |
| # The mock_auth configuration allows you to set per-provider (or default) | |
| # authentication hashes to return during integration testing. | |
| OmniAuth.config.mock_auth[:twitter] = { | |
| 'provider' => 'twitter', | |
| 'uid' => '123545', | |
| 'user_info' => { | |
| 'name' => 'mockuser', |
| # This is a skeleton for testing models including examples of validations, callbacks, | |
| # scopes, instance & class methods, associations, and more. | |
| # Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
| # | |
| # I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
| # so if you have any, please share! | |
| # | |
| # @kyletcarlson | |
| # | |
| # This skeleton also assumes you're using the following gems: |
| rails g scaffold Book title:string description:text | |
| rails g scaffold Pubhouse title:string address:text | |
| rails g model BookPubhouse book_id:integer pubhouse_id:integer | |
| rake db:migrate |
| # MySQL. Versions 4.1 and 5.0 are recommended. | |
| # | |
| # Install the MySQL driver: | |
| # gem install mysql2 | |
| # | |
| # And be sure to use new-style password hashing: | |
| # http://dev.mysql.com/doc/refman/5.0/en/old-client.html | |
| development: | |
| adapter: mysql2 | |
| encoding: utf8 |