Last active
February 28, 2017 19:07
-
-
Save DmytroVasin/06044a753ce1eadc09864ce204ef79c0 to your computer and use it in GitHub Desktop.
Extend Rspec to include additional matcher.
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
describe "Assets", type: :feature, js: true do | |
describe "application.js" do | |
it "does not include page-specific content" do | |
visit root_path | |
expect("d3").to be_undefined_in_js | |
expect("moment").to be_undefined_in_js | |
end | |
end | |
private | |
RSpec::Matchers.define :be_undefined_in_js do | |
match do |actual| | |
evaluate_script("typeof #{actual} === 'undefined'") == true | |
end | |
failure_message do |actual| | |
"expected JS not to include #{actual}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment