Sha256: edb44ba874b0fdafea2c5dadc7ff418a653f9a62ecff06c763e0e365d84bac9f

Contents?: true

Size: 1.08 KB

Versions: 37

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe "expect(...).to satisfy { block }" do
  it_behaves_like "an RSpec matcher", :valid_value => true, :invalid_value => false do
    let(:matcher) { satisfy { |v| v } }
  end

  it "describes itself" do
    expect(satisfy.description).to eq("satisfy block")
  end

  it "passes if block returns true" do
    expect(true).to satisfy { |val| val }
    expect(true).to satisfy do |val|
      val
    end
  end

  it "fails if block returns false" do
    expect {
      expect(false).to satisfy { |val| val }
    }.to fail_with("expected false to satisfy block")
    expect do
      expect(false).to satisfy do |val|
        val
      end
    end.to fail_with("expected false to satisfy block")
  end
end

describe "expect(...).not_to satisfy { block }" do
  it "passes if block returns false" do
    expect(false).not_to satisfy { |val| val }
    expect(false).not_to satisfy do |val|
      val
    end
  end

  it "fails if block returns true" do
    expect {
      expect(true).not_to satisfy { |val| val }
    }.to fail_with("expected true not to satisfy block")
  end
end

Version data entries

37 entries across 37 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/satisfy_spec.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/satisfy_spec.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/satisfy_spec.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/satisfy_spec.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/satisfy_spec.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/satisfy_spec.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/satisfy_spec.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/spec/rspec/matchers/satisfy_spec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-expectations-2.14.5/spec/rspec/matchers/satisfy_spec.rb
rspec-expectations-2.99.2 spec/rspec/matchers/satisfy_spec.rb
dxruby_rp5-0.0.4 spec/vendor/rspec-expectations-2.14.4/spec/rspec/matchers/satisfy_spec.rb
rspec-expectations-2.99.1 spec/rspec/matchers/satisfy_spec.rb
rspec-expectations-2.99.0 spec/rspec/matchers/satisfy_spec.rb
rspec-expectations-2.99.0.rc1 spec/rspec/matchers/satisfy_spec.rb
rspec-expectations-3.0.0.beta2 spec/rspec/matchers/built_in/satisfy_spec.rb
rspec-expectations-2.99.0.beta2 spec/rspec/matchers/satisfy_spec.rb
rspec-expectations-2.14.5 spec/rspec/matchers/satisfy_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-expectations-2.14.4/spec/rspec/matchers/satisfy_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-expectations-2.14.4/spec/rspec/matchers/satisfy_spec.rb
dxruby_rp5-0.0.3 spec/vendor/rspec-expectations-2.14.4/spec/rspec/matchers/satisfy_spec.rb