...gem 'cucumber_factory' Run bundle update on any added/changed gem, e.g. bundle update cucumber capybara selenium-webdriver database_cleaner cucumber_spinner Error messages & solutions uninitialized constant JSON -> Add gem 'json...

...to your Gemfile uninitialized constant Selenium -> Add gem 'selenium-webdriver' to your Gemfile Failing Cucumber steps that use find Capybara 1's #find method raises an error if nothing could...

creativecouple.github.com

...provides you some methods that help you to write readable and understandable method chains. See yourself: Example // before $('.some').show().children().doThat(); window.setTimeout(function(){ $('some').children().doSomething().hide(function() { window.setTimeout...

otherStuffToDo(); }, 1000); }); }, 500); // after $('.some').show().children().doThat() .wait(500) .doSomething().hide() . wait(1000) . otherStuffToDo(); jquery-timing transformed the setTimeout callback into a chainable method. Now the code is...

...give you the =~ matcher: actual_array.should =~ expected_array Rspec 3 With RSpec 3's expect syntax you can choose one of these two matchers: expect(actual_array).to match_array...

...but contain_exactly takes a list of elements as varargs. Test::Unit If you install shoulda-matchers you can say: assert_same_elements([:a, :b, :c], [:c, :a, :b])

...inputs, where one contains the name of the other (eg. Name and Name with special treatment), Capybara's fill_in method will fail with the following message: Ambiguous match, found...

...value = 'Bettertest Cucumberbatch' fill_in(field, with: value, match: :prefer_exact) Furthermore, we recommend setting Capybara's matching strategy globally to :prefer_exact. This will positively affect all you steps...

Here is a hacky way to load dumps directly from the source server, without fully copying them over and extracting them first. It may break horribly for you. This is...

...the dark side of the force. Install pipe viewer, if you don't have it already: sudo apt-get install pv Know the location of the dump file on the...

WProofreader is a spelling and grammar checking tool that integrates with textareas and numerous WYSIWYG editors. While it usually activates automatically, depending on your application, it may fail to boot...

...do that ourselves, so we disable it autoDestroy: true, lang: 'de_DE', serviceId: '...', // ... } Ensure https://svc.webspellchecker.net/spellcheck31/wscbundle/wscbundle.js is loaded as described in the docs. To activate WProofreader, you can now...

...language when they visit the root path. Here is how to do it without a server-side component (like a Rails application). Use JavaScript's navigator.language (real browsers and IE11...

...following JavaScript will try to auto-detect a user's preferred language. It understands strings like like de_AT, and if the user prefers neither of your supported languages it...

RSpec's let allows you to super into "outside" definitions, in parent contexts. Example: describe '#save' do subject { described_class.new(attributes) } let(:attributes) { title: 'Example', user: create(:user) } it 'saves' do...

...expect(subject.save).to eq(true) end context 'when trying to set a disallowed title' do let(:attributes) { super().merge(title: 'Hello') } # <== it 'will not save' do expect(subject.save).to eq...

github.com

...dependencies and database types. Here's what Gemika can give your test's development setup (all features are opt-in): Test one codebase against multiple sets of gem dependency sets...

...currently MySQL or PostgreSQL). Compute a matrix of all possible dependency permutations (Ruby, gem set, database type). Manually exclude incompatible dependency permutations (e.g. Rails 5.0 does not work with Ruby...

ruby.about.com

The flip-flop operator is a hotly contested feature of Ruby. It's still struggling to find an idiomatic use case, except for a few very rarely needed things. It...

...s not something you'll likely reach for on a daily, weekly or even monthly basis. The only thing you really need to know about it is what it does...

In Capistrano 2, directories in shared_children used to be symlinked to the shared directory during the finalize_update task. # /lib/capistrano/recipes/deploy.rb _cset :shared_children, %w(public/system log tmp/pids) # ... task :finalize...

...update, :except => { :no_release => true } do # ... shared_children.map do |d| run "ln -s #{shared_path}/#{d.split('/').last} #{latest_release}/#{d}" # <-- symlinks only the last segment here end # ... end This would symlink...

...could also use Haml instead. Example Consider the following helper. def greeting message = ''.html_safe message << 'Welcome to ' message << content_tag(:span, Rails.env, class: 'greeting--location') content_tag :div, message...

...That looks clumsy and is hard to read. Wouldn't it be nicer to say something like this? def greeting render_haml <<-HAML .greeting Welcome to %span.greeting--location = Rails.env

To read the Rails session from a Rack middleware, use env['rack.session']. It's an ActionDispatch::Request::Session object. class MyMiddlware def initialize(app) @app = app end def call(env...

...status, headers, body = @app.call(env) session = env['rack.session'] Rails.logger.info("Value of session['foo'] is: " + session['foo'].inspect) [status, headers, body] end end You may not be able to write to...

stackoverflow.com

...that whenever you are using those values for database interaction, you'll end up scoping on the wrong records since the database representation of these dates is not converted to...

Use form models to handle this problem Or soften the validation to validates_presence_of :parent Usually you would validate presence of parent object id, like in this...

validates_presence_of :parent_id # <- end With the parent already persisted creating nesteds still works fine. But one will encounter a 'parent id missing' error on creating a parent...

...You can add other AWS account depending files like .fog or .guignol.yml too. Create symlinks for some config files like .aws_credentials and .fog: ln -s ~/.aws/.aws_credentials ~/.aws_credentials

...export EC2_CERT=~/.aws/cert-ec2.pem export AWS_CREDENTIAL_FILE=~/.aws/aws-credentials Perhaps you also want to set a default region and the JAVA_HOME: export EC2_REGION=eu-west-1

Say you have an RGBA color that you need as a non-transparent color because of reasons. Basically, this is possible. Just understand that you will convert your RGBA color...

...your background is white, so you'll use #fff as that for examples below. Simple approach When your know the RGBA color's base RGB color (e.g. your brand color...

In specs, the session never persists but is always a new object for each request. Data put into the session in a previous request is lost. Here is how to...

...circumvent that. What's going on? You are making ActionController::TestRequests in your specs, and their #initialize method does this: self.session = TestSession.new This means that each time you say something...

github.com

Barby is a great Ruby gem to generate barcodes of all different sorts. It includes support for QR codes via rQRCode; if you need to render only QR codes, you...

>> Barby::Code128.new('Hello Universe').to_image.to_data_url => "data:image/png;base64,iVBORw0KGgoAA..." For super-crisp barcodes, render them as SVG. Printing images usually causes some level of blur...

...should), the host's IP address is: 10.0.2.2 You'll need it to access shared folders or your host's web server when testing pages in IE.

github.com

...Request, visit /__better_errors on your app's root path (e.g. http://localhost:3000/__better_errors). It shows the error page for the last exception that occurred, even when it has been triggered...

When you need to check a value for presence, don't rely on JavaScript since it considers 0 or "0" false. Also don't rely on LoDash's _.isEmpty:

While the name implies that it's meant only for collections, you probably still want something like isBlank or isPresent that return true/false for objects humans would normally consider...

Accessing pseudo elements via JavaScript or jQuery is often painful/impossible. However, accessing their styles is fairly simple. Using getComputedStyle First, find the element in question. let element = document.querySelector('.my-element...

...s getComputedStyle. It takes an optional 2nd argument to filter for pseudo elements. let style = window.getComputedStyle(element, '::before') let color = style.getPropertyValue('background-color') The returned color will be a string...

linuxsa.org.au

...up little more than one extra line in the output of ps. On a server I want to get informed if there are zombie processes and track them with a...

...two choices, fix it or kill it. In this case it's no critical service and I can just restart it...