start new:
tmux
start new with session name:
tmux new -s myname
| def valid_date_type(arg_date_str): | |
| """custom argparse *date* type for user dates values given from the command line""" | |
| try: | |
| return datetime.datetime.strptime(arg_date_str, "%Y-%m-%d") | |
| except ValueError: | |
| msg = "Given Date ({0}) not valid! Expected format, YYYY-MM-DD!".format(arg_date_str) | |
| raise argparse.ArgumentTypeError(msg) | |
| def valid_datetime_type(arg_datetime_str): | |
| """custom argparse type for user datetime values given from the command line""" |
| #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) |
| #!/bin/bash | |
| # Create the directory structure | |
| mkdir -p features/step_definitions | |
| mkdir -p features/support | |
| # Create a placeholder for the step_definitions folder | |
| touch features/step_definitions/"$(basename `pwd`)_steps.rb" | |
| # Create the environment file |
| # First attempting to use Capybara directly, you will run into issues when trying to set HTTP headers; e.g. | |
| # using Basic HTTP Authentication requires setting the header. | |
| # Also we need to set the Content-Type and Accept headers to ensure that our API negotiates content types correctly. | |
| # When using Rack, Capybara delegates request and response handling down to Rack::Test. | |
| # So use Rack::Test directly in step definitions, and it works. | |
| # Rack::Test has a module called Rack::Test::Methods that can be mixed into a class to provide it | |
| # with methods for get, post, put, delete as well as last_request, last_response, header and more. | |
| # The Rack::Test::Methods can be mixed into the Cucumber world at the top of our API steps file like so: | |
| ############################## |
| require "sinatra/base" | |
| require "sinatra/namespace" | |
| require "multi_json" | |
| require "api/authentication" | |
| require "api/error_handling" | |
| require "api/pagination" | |
| module Api | |
| class Base < ::Sinatra::Base |