Module: RSpec::Matchers::BeFasterThan

Defined in:
lib/should_be_faster.rb

Instance Method Summary collapse

Instance Method Details

#faster_than(rhs_code, options = {}) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/should_be_faster.rb', line 72

def faster_than(rhs_code, options={})
  options ||= {}
  options[:factor] = @factor
  Matcher.new(:faster_than) do
    options[:faster]  = true
    options[:matcher] = self
    RSpec::Matchers::BenchmarkComparison.new(rhs_code, options).benchmark_comparison
  end
end

#slower_than(rhs_code, options = {}) ⇒ Object



82
83
84
85
86
87
88
89
90
# File 'lib/should_be_faster.rb', line 82

def slower_than(rhs_code, options={})
  options ||= {}
  options[:factor] = @factor
  Matcher.new(:slower_than) do
    options[:faster]  = false
    options[:matcher] = self
    RSpec::Matchers::BenchmarkComparison.new(rhs_code, options).benchmark_comparison
  end
end

#times(*args) ⇒ Object



67
68
69
70
# File 'lib/should_be_faster.rb', line 67

def times(*args)
  @factor = args[0]
  self
end