Sha256: 140936df3fc1ee747ea8c448baa8ee3922b9f88797689c807e326f8b06edcb67

Contents?: true

Size: 1.06 KB

Versions: 10

Compression:

Stored size: 1.06 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

# NOTE - this was initially handled by an explicit matcher, but is now
# handled by a default set of predicate_matchers.

class Substance
  def initialize exists, description
    @exists = exists
    @description = description
  end
  def exist?
    @exists
  end
  def inspect
    @description
  end
end
  
describe "should exist" do
  before(:each) do
    @real = Substance.new true, 'something real'
    @imaginary = Substance.new false, 'something imaginary'
  end
  
  it "should pass if target exists" do
    @real.should exist
  end
  
  it "should fail if target does not exist" do
    lambda { @imaginary.should exist }.
      should fail
  end
end

describe "should_not exist" do  
  before(:each) do
    @real = Substance.new true, 'something real'
    @imaginary = Substance.new false, 'something imaginary'
  end
  it "should pass if target doesn't exist" do
    @imaginary.should_not exist
  end
  it "should fail if target does exist" do
    lambda { @real.should_not exist }.
      should fail
  end
end
    

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rspec-1.0.4 spec/spec/matchers/exist_spec.rb
rspec-0.9.0 spec/spec/matchers/exist_spec.rb
rspec-0.9.1 spec/spec/matchers/exist_spec.rb
rspec-0.9.2 spec/spec/matchers/exist_spec.rb
rspec-0.9.3 spec/spec/matchers/exist_spec.rb
rspec-0.9.4 spec/spec/matchers/exist_spec.rb
rspec-1.0.0 spec/spec/matchers/exist_spec.rb
rspec-1.0.1 spec/spec/matchers/exist_spec.rb
rspec-1.0.2 spec/spec/matchers/exist_spec.rb
rspec-1.0.3 spec/spec/matchers/exist_spec.rb