responsive.is
Online tool to test how a site behaves in popular desktop, tablet and phone resolutions.
colszowka/simplecov - GitHub
Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites.
Note that rcov won't ever have support for Ruby 1.9, you're supposed to use rcov for 1.8 and simplecov for 1.9.
Cucumber.yml was found, but could not be parsed.
If you encounter the error message above when running cucumber, just execute...
rm rerun.txt
...in the Rails directory.
Or run...
tests
...from the geordi gem. This will do the work for you automatically.
ActiveSupport::StringInquirer
Wrapping a string in this class gives you a prettier way to test for equality.
plus2/whereuat - GitHub
Adds a slide out panel to your Rails application that directs clients to test stories that have been marked as 'delivered' in Pivotal Tracker.
Run a rake task in all environments
Use like this:
power-rake db:migrate VERSION=20100913132321
By default the environments development
, test
, cucumber
and performance
are considered. The script will not run rake on a production
or staging
environment.
This script is part of our geordi gem on github.
Railscheck project home page
This project is (or will be) a best effort semi-static verifier for your Ruby on Rails projects. Delivered as a Ruby gem it provides a shell command task "railscheck" that you can run against your Rails projects to test for a number of typical bugs, potential problems and inconsistencies.
Integrity | The easy and fun automated continuous integration server
Integrity is the angel watching over your shoulder while you code. As soon as you push your commits, it builds, runs your tests, and makes sure everything works fine.
mdub's sham_rack at master - GitHub
Or, you can test your Rack application (or Sinatra, or Rails, or Merb) using arbitrary HTTP client libraries, to check interoperability.
citrusbyte's contest at master - GitHub
Write declarative tests using nested contexts without performance penalties. Contest is less than 100 lines of code and gets the job done.
thumblemonks's riot at master - GitHub
Riot differs primarily in that it does not rerun setup for each test in a context.
Localized external services - GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS
ShamRack mounts a Rack app locally, just for your tests. It goes one further: it “mounts” it using Net::HTTP such that requests to the Rack app never hit any network.
mynyml's holygrail at master - GitHub
The Holy Grail of testing for front-end development; execute browser-less, console-based, javascript + DOM code right from within your Rails test suite.
Don't use migrations to seed default data
Don't insert table rows in a Rails database migration. This will break tests that expect that database to be empty and cause you all sorts of pain.
If you need a place for default application data, use db/seed.rb or put a script into lib/scripts
. It won't run automatically, so add a chore story to Pivotal Tracker as a reminder.
Sync confidential files between unixes using cloud storage and encfs
Note: You might also want to check out BoxCryptor which does pretty much the same, and is supported across many more platforms. I just didn't want to use Dropbox...
I use Ubuntu One to automatically sync confidential files between my machines. The encryption is done via encfs, which is a file-based encryption that simply puts encrypted versions of files from one folder into another. This is well-suited for cloud storage, since it allows syncing single files, not whole crypt containers.
Recipe
I'll ass...
Minimal JavaScript function to detect version of Internet Explorer or Edge
If possible your code should detect features, not browsers. But sometimes you just need to sniff the browser. And when you do, you're probably fighting a Microsoft product.
The following function returns a Number
like 10, 11, 12, 13 for Internet Explorer or Edge (anything above 11 is Edge). It returns undefined
for any other browser.
function ieVersion(uaString) {
uaString = uaString || navigator.userAgent;
var match = /\...
Selenium may break with ChromeDriver 75+
When you update your ChromeDriver to version 75 or beyond, you might get w3c errors in your tests.
For example, reading the browser console for errors no longer works, and page.driver.browser.manage.logs.get(:browser)
will raise an error like "undefined method `log' for #<Selenium::WebDriver::Remote::W3C::Bridge:0x000055903f307aa8>
".
Add options.add_option('w3c', false)
to your Selenium configuration (e.g. features/support/selenium.rb
) and you should be back to normal:
Capybara.register_driver :selenium do |app|
options ...
whenever: Make runner commands use bundle exec
In whenever you can schedule Ruby code directly like so:
every 1.day, :at => '4:30 am' do
runner "MyModel.task_to_run_at_four_thirty_in_the_morning"
end
Combined with the best practice to hide background tasks behind a single static methods you can test, this is probably preferable to defining additional Rake tasks.
Unfortunately when whenever register a runner command, it doesn't use bundle exec
in the resulting crontab. This gets you errors like this:
`gem_original_require': no suc...
Override e-mail recipients in ActionMailer
Our gem Mail Magnet allows you to override e-mail recipients in ActionMailer so all mails go to a given address.
This is useful for staging environments where you want to test production-like mail delivery without sending e-mails to real users.
Strong params: Raise in development if unpermitted params are found
Rails 4:
config.action_controller.action_on_unpermitted_parameters
enables logging or raising an exception if parameters that are not explicitly permitted are found. Set to :log
or :raise
to enable. The default value is :log
in development and test environments, and false in all other environments.
Rails 3:
If you include the strong_params
gem, see the Readme for handling unpermitted keys.
Updated: Jasmine: Creating DOM elements efficiently
I have moved away from creating fixture elements using CSS selectors. While CSS can be very concise, it can be hard to recognize the created elements, and how they are nested within each other.
A more visual alternative is to embed a string of HTML into your test. My specs often have a function htmlFixtures()
that parses the HTML and returns a reference to all created elements:
let [list, item1, item2] = htmlFixtures(`
<ul type="square">
<li>item 1</li>
<li>item 2</li>
</ul>
`)
Because the effective HTML is visible...