A clean workaround for running capybara tests on Rails with assets pipeline enabled.
Original: teamcapybara/capybara#500 (comment)
A clean workaround for running capybara tests on Rails with assets pipeline enabled.
Original: teamcapybara/capybara#500 (comment)
| module AlertConfirmer | |
| class << self | |
| def reject_confirm_from &block | |
| handle_js_modal 'confirm', false, &block | |
| end | |
| def accept_confirm_from &block | |
| handle_js_modal 'confirm', true, &block | |
| end |
| namespace :db do | |
| namespace :sessions do | |
| desc "Clean up expired Active Record sessions (updated before ENV['UPDATED_AT'], defaults to 1 month ago)." | |
| task :expire => :environment do | |
| time = Time.parse( ENV['UPDATED_AT'] || 1.month.ago.to_s(:db) ) | |
| say "cleaning up expired sessions (older than #{time}) ..." | |
| session = ActiveRecord::SessionStore::Session | |
| rows = session.delete_all ["updated_at < ?", time] | |
| say "deleted #{rows} session row(s) - there are #{session.count} session row(s) left" | |
| end |
| #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) |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000| $ ./executable-with-subcommands-using-thor.rb | |
| Tasks: | |
| executable-with-subcommands-using-thor.rb help [TASK] # Describe available tasks or one specific task | |
| executable-with-subcommands-using-thor.rb subA [TASK] # Execute a task in namespace subA | |
| executable-with-subcommands-using-thor.rb subB [TASK] # Execute a task in namespace subB | |
| executable-with-subcommands-using-thor.rb test # test in CLI | |
| $ ./executable-with-subcommands-using-thor.rb help | |
| Tasks: | |
| executable-with-subcommands-using-thor.rb help [TASK] # Describe available tasks or one specific task |
| RSpec::Core::RakeTask.module_eval do | |
| def pattern | |
| dir = EngineName.root # replace with you the name of your engine | |
| extras = [] | |
| if File.directory?( dir ) | |
| extras << File.join( dir, 'spec', '**', '*_spec.rb' ).to_s | |
| end | |
| [@pattern] | extras | |
| end | |
| end |
| var fn = function(arg1, arg2) { | |
| var str = '<p>aap ' + this.noot + ' ' + arg1 + ' ' + arg2 + '</p>'; | |
| document.body.innerHTML += str; | |
| }; | |
| var context = { | |
| 'noot': 'noot' | |
| }; | |
| var args = ['mies', 'wim']; | |
| // Calls a function with a given 'this' value and arguments provided individually. |
| [url, height, width, output_dir] = phantom.args | |
| console.log("url #{url}, height #{height}, width #{width}, output_dir #{output_dir}") | |
| page = require('webpage').create() | |
| page.viewportSize = | |
| width: width | |
| height: height | |
| page.onConsoleMessage = (msg) -> |
| # A common concern,include into all doc modules | |
| # | |
| module BaseDoc | |
| include Apipie::DSL::Concern | |
| def namespace(namespace, options = {}) | |
| @namespace = namespace | |
| @namespace_name = options[:name] | |
| end | |
| attr_reader :namespace_name |