![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Screenshot-driven assertions for testing Rails and RubyMotion applications.
Motion-juxtapose uses ImageMagick under the hood for image comparison. If you're using Homebrew, you can install it with:
brew install imagemagick
Add this line to your application's Gemfile:
gem 'motion-juxtapose'
And then execute:
$ bundle
Or install it yourself as:
$ gem install motion-juxtapose
Juxtapose's workflow generally goes:
bundle exec juxtapose
and browse to http://localhost:4567 — you should see the just-captured screenshot, like below.Juxtapose provides a single new matcher: it_should_look_like
takes a single argument, a descriptive string predicate of what the screen should look like.
Example:
describe "home controller" do
extend Juxtapose
describe "home controller" do
tests HomeViewController
it "has a button that moves when tapped" do
tap "Goodbye, world!"
it_should_look_like "when_tapped"
end
end
end
Add the following config to your features/support/env.rb:
require 'motion-juxtapose'
Juxtapose::FrankStrategy.setup
This lets you write a screenshot matcher along the lines of:
Then /^the screen should match "([^\"]*)"$/ do |template|
wait_for_nothing_to_be_animating
screenshotter = Juxtapose::Screenshotter.new(self, template)
max_attempts = 20
expect(screenshotter.attempt_verify(max_attempts)).to eq(true)
end
Add the following config to your features/support/env.rb:
require 'motion-juxtapose'
Juxtapose::AppiumStrategy.setup
This lets you write a screenshot matcher along the lines of:
Then /^the screen should match "([^\"]*)"$/ do |template|
wait_for_nothing_to_be_animating
#unlike frank we need to pass in a project root to find the screenshot directory
screenshotter = Juxtapose::Screenshotter.new(self, template, 0, File.expand_path('./'))
max_attempts = 20
expect(screenshotter.attempt_verify(max_attempts)).to eq(true)
end
Any Capybara driver that supports screenshot capture should work, but I've only tested this with Poltergeist so far.
In your spec_helper.rb
, add:
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:
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
Sometimes screenshots will differ slightly due to things like animation timing. Juxtapose will try to match an existing screenshot multiple times to help counteract this, but it can still be useful to be able to match screenshots using a percent similarity threshold.
In bacon specs, you can pass a fuzz factor from 0 to 100 to it_should_look_like
, 0 meaning an exact match and 100 matching anything of the same size. The default is 0.
# matches images that are 15% similar
it_should_look_like 'a fancy animation', 15
In Frank, pass the fuzz factor in as the third argument to the Screenshotter constructor. A more exacting Frank step could be written as:
Then /^the screen should match "([^\"]*)" within (\d+)% in (\d+) attempts$/ do |template, fuzz_factor, max_attempts|
wait_for_nothing_to_be_animating
screenshotter = Juxtapose::Screenshotter.new(self, template, fuzz_factor)
expect(screenshotter.attempt_verify(max_attempts)).to eq(true)
end
Juxtapose comes with a small webapp that you can use to view your screenshot specs, see diffs between accepted and failing specs and accept any changed images that are expected changes.
To start it, run bundle exec juxtapose
in the root of your project and browse to localhost:4567.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that motion-juxtapose demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.