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
| def save_screenshot(path = nil) | |
| path ||= "capybara-#{Time.new.strftime("%Y%m%d%H%M%S")}#{rand(10**10)}.png" | |
| path = File.expand_path(path, Capybara.save_and_open_page_path) if Capybara.save_and_open_page_path | |
| FileUtils.mkdir_p(File.dirname(path)) | |
| super(path, full: true) | |
| path | |
| end | |
| def shoot(opts = {}) |
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
| # http://www.ruby-doc.org/core-1.9.3/Hash.html#method-c-new | |
| # ... It is the block’s responsibility to store the value in the hash if required. | |
| cuca = Hash.new([]) | |
| cuca["ola"] << 12 # ~ [] << 12 | |
| p cuca # => {} | |
| cuca = Hash.new([]) |
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
| module Sorcery | |
| class FreeAuth | |
| include Controller | |
| def initialize(request) | |
| @request = request | |
| end | |
| def session | |
| @session ||= @request.session |
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
| module Carrierwave | |
| module DelayedVersions | |
| extend ActiveSupport::Concern | |
| module ClassMethods | |
| def delayed_versions | |
| @delayed_versions ||= Set.new | |
| end | |
| def delayed_version(name, opts = {}, &block) |
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
| after "deploy:stop", "clockwork:stop" | |
| after "deploy:start", "clockwork:start" | |
| after "deploy:restart", "clockwork:restart" | |
| namespace :clockwork do | |
| desc "Stop clockwork" | |
| task :stop, :roles => clockwork_roles, :on_error => :continue, :on_no_matching_servers => :continue do | |
| run "if [ -d #{current_path} ] && [ -f #{pid_file} ]; then cd #{current_path} && kill -INT `cat #{pid | |
| _file}` ; fi" | |
| 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
| require "securerandom" | |
| def get_secure_random | |
| puts "Func called" | |
| SecureRandom.hex(16) | |
| end | |
| res = get_secure_random while res[0] != "a" | |
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
| def saop | |
| save_and_open_page | |
| end | |
| def screenshot | |
| page.driver.render("/home/roger/shot.jpg", :full => true) | |
| end | |
| def select_should_have(locator, text) | |
| node = page.find_field(locator) |
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
| # https://github.com/rogercampos/armot/blob/master/test/armot_test.rb#L514 | |
| test "should work if the I18n backend has not fallbacks" do | |
| with_no_method(I18n.singleton_class, :fallbacks) do | |
| assert_equal false, I18n.respond_to?(:fallbacks) | |
| post = Post.last | |
| I18n.locale = :pt | |
| assert_equal nil, post.title | |
| 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
| def count_query_reads_for(clazz) | |
| old = ActiveRecord::Base.logger | |
| log_stream = StringIO.new | |
| logger = Logger.new(log_stream) | |
| ActiveRecord::Base.logger = logger | |
| yield | |
| ActiveRecord::Base.logger = old | |
| logger.close | |
| log_stream.string.scan(/#{clazz} Load/).size | |
| end |
NewerOlder