Class: HaveDataMatcher
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(data) ⇒ HaveDataMatcher
constructor
A new instance of HaveDataMatcher.
- #matches?(name) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(data) ⇒ HaveDataMatcher
Returns a new instance of HaveDataMatcher.
5 6 7 |
# File 'lib/mspec/matchers/have_data.rb', line 5 def initialize(data) @data = data end |
Instance Method Details
#failure_message ⇒ Object
23 24 25 26 |
# File 'lib/mspec/matchers/have_data.rb', line 23 def ["Expected #{@name}", "to have data #{@data.pretty_inspect}"] end |
#matches?(name) ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mspec/matchers/have_data.rb', line 9 def matches?(name) @name = name if FeatureGuard.enabled? :encoding size = @data.bytesize else size = @data.size end File.open @name, fmode("rb:binary") do |f| return f.read(size) == @data end end |
#negative_failure_message ⇒ Object
28 29 30 31 |
# File 'lib/mspec/matchers/have_data.rb', line 28 def ["Expected #{@name}", "not to have data #{@data.pretty_inspect}"] end |