Skip to content

Instantly share code, notes, and snippets.

@apolzon
Created March 28, 2012 19:09
Show Gist options
  • Select an option

  • Save apolzon/2229566 to your computer and use it in GitHub Desktop.

Select an option

Save apolzon/2229566 to your computer and use it in GitHub Desktop.
include javascript rspec matcher
RSpec::Matchers.define :include_javascript do |expected|
match do |actual|
actual && actual.match(/<script src="\/javascripts\/#{expected}\.js.+ type="text\/javascript"><\/script>/)
end
failure_message_for_should do |actual|
"expected that javascript tag #{expected} would be present, but was not"
end
failure_message_for_should_not do |actual|
"expected that javascript tag #{expected} would not be present, but was"
end
description do
"include javascript tag #{expected}"
end
end
@apolzon
Copy link
Author

apolzon commented Mar 28, 2012

Yes it does, but thats just the way it gets output from javascript_include_tag. No sense in supporting people who don't use the Rails helpers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment