Terrible Blog

Because Terrible Labs loves you.

Motion-juxtapose: Now With Rails Support!

| Comments

Earlier this year, we released motion-juxtapose, a gem for using screenshots to test iOS apps built with RubyMotion. Today, we released version 0.2.0 with some bug fixes and support for Rails integration tests!

When running under Rails, the gem uses Capybara to capture its screenshots. Any Capybara driver that supports screenshot capture should work, though we’ve only tested this with Poltergeist so far.

In your spec_helper.rb, add:

1
2
3
require 'juxtapose/capybara'
# if you're using rspec, you can get the `look_like?` custom matcher with:
require 'juxtapose/rspec'

Now the Capybara page object will have a looks_like?(predicate) method that can call to make screenshot assertions:

1
2
3
4
5
6
feature "viewing locations", js: true do
  scenario "should only show books at first location" do
    visit location_path Location.find_by_name("Cambridge")
    expect(page).to look_like("books at Cambridge")
  end
end

Check out all the details over at the project’s Github page and let us know what you think.

Comments