Sha256: 4c88ccff92e8057d622b3c5f34c7466220470790c081ef01088dd1bd6a8656cb

Contents?: true

Size: 782 Bytes

Versions: 18

Compression:

Stored size: 782 Bytes

Contents

require 'spec_helper'

describe 'Enumerable#several' do
  context 'with block' do
    it 'returns true if more than 1 element matches the predicate' do
      expect([1, 2, 3, 4].several?(&:even?)).to be_truthy
    end

    it 'returns false if just 1 element matches the predicate' do
      expect([1, 3, 4].several?(&:even?)).to be_falsey
    end

    it 'returns false if no elements match the predicate' do
      expect([1, 3, 4].several?(&:even?)).to be_falsey
    end
  end

  context 'without block' do
    it 'returns true if there are 2 or more non nil/false elements' do
      expect([1, 2, 3, 4].several?).to be_truthy
    end

    it 'returns false if there are less than 2 non nil/false elements' do
      expect([1, nil, false].several?).to be_falsey
    end
  end
end

Version data entries

18 entries across 15 versions & 5 rubygems

Version Path
powerpack-0.1.3 spec/powerpack/enumerable/several_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/spec/powerpack/enumerable/several_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/spec/powerpack/enumerable/several_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/spec/powerpack/enumerable/several_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/spec/powerpack/enumerable/several_spec.rb
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.1/spec/powerpack/enumerable/several_spec.rb
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/spec/powerpack/enumerable/several_spec.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.1/spec/powerpack/enumerable/several_spec.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/powerpack-0.1.2/spec/powerpack/enumerable/several_spec.rb
powerpack-0.1.2 spec/powerpack/enumerable/several_spec.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/spec/powerpack/enumerable/several_spec.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/spec/powerpack/enumerable/several_spec.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/spec/powerpack/enumerable/several_spec.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/spec/powerpack/enumerable/several_spec.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/spec/powerpack/enumerable/several_spec.rb
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/powerpack-0.1.1/spec/powerpack/enumerable/several_spec.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/powerpack-0.1.1/spec/powerpack/enumerable/several_spec.rb
powerpack-0.1.1 spec/powerpack/enumerable/several_spec.rb