Skip to content

Commit

Permalink
More JRuby fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
nomoon committed Mar 5, 2017
1 parent 94f67af commit 4592139
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/ragabash/refinements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,12 @@ def safe_copy
end
alias frozen_copy safe_copy

unless defined?(JRUBY_VERSION)
if defined?(JRUBY_VERSION)
BLANK_RE = /\A[[:space:]]*\z/
def blank?
empty? || BLANK_RE === self # rubocop:disable Style/CaseEquality
end
else
require "fast_blank"
alias blank? blank_as?
end
Expand Down
4 changes: 2 additions & 2 deletions spec/ragabash/refinements_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
it("Symbol returns false") { expect(:symbol.blank?).to equal(false) }
it("BigDecimal returns false") { expect(BigDecimal.new("1.5").blank?).to equal(false) }
it("String returns true if empty") { expect("".blank?).to equal(true) }
it("String returns true if unicode whitespace") { expect("\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000".blank?).to equal(true) } unless defined?(JRUBY_VERSION)
it("String returns true if unicode whitespace") { expect("\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000".blank?).to equal(true) }
it("String returns true if regular whitespace") { expect(" ".blank?).to equal(true) }
it("String returns false if not empty") { expect("A string".blank?).to equal(false) }
it("Array returns true if empty") { expect([].blank?).to equal(true) }
Expand All @@ -133,7 +133,7 @@
it("Symbol returns true") { expect(:symbol.present?).to equal(true) }
it("BigDecimal returns true") { expect(BigDecimal.new("1.5").present?).to equal(true) }
it("String returns false if empty") { expect("".present?).to equal(false) }
it("String returns false if unicode whitespace") { expect("\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000".present?).to equal(false) } unless defined?(JRUBY_VERSION)
it("String returns false if unicode whitespace") { expect("\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000".present?).to equal(false) }
it("String returns false if regular whitespace") { expect(" ".present?).to equal(false) }
it("String returns true if not empty") { expect("A string".present?).to equal(true) }
it("Array returns false if empty") { expect([].present?).to equal(false) }
Expand Down

0 comments on commit 4592139

Please sign in to comment.