diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-03-04 09:53:26 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-03-04 09:53:26 +0000 |
commit | 3912c73583464e3ff203e3e101325ccabcba0506 (patch) | |
tree | 3b57620358c4c4cfe1c52702f2979876f6452aa0 /spec/spec_helper.rb | |
parent | 2a49615ee3ea08f7952283efc0306a1ac0c23334 (diff) | |
parent | af83354da1030c2d2fad3c63f3ccb516c4923d38 (diff) |
Merge branch 'release/0.17' into wdtk
Conflicts:
config/general.yml-example
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r-- | spec/spec_helper.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1eeb8603b..dc5a0d6eb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -187,11 +187,16 @@ Spork.prefork do end end + # Reset the default locale, making sure that the previous default locale + # is also cleared from the fallbacks def with_default_locale(locale) original_default_locale = I18n.default_locale + original_fallbacks = I18n.fallbacks + I18n.fallbacks = nil I18n.default_locale = locale yield ensure + I18n.fallbacks = original_fallbacks I18n.default_locale = original_default_locale end @@ -215,3 +220,16 @@ Spork.each_run do FactoryGirl.reload # This code will be run each time you run your specs. end + +def normalise_whitespace(s) + s = s.gsub(/\A\s+|\s+\Z/, "") + s = s.gsub(/\s+/, " ") + return s +end + +RSpec::Matchers.define :be_equal_modulo_whitespace_to do |expected| + match do |actual| + normalise_whitespace(actual) == normalise_whitespace(expected) + end +end + |