Sha256: fd908e314e4bd4482cf7e311542f3a8adc319f84f8ca2e462c0d25d6637c4a1b

Contents?: true

Size: 1.06 KB

Versions: 7

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

7 entries across 7 versions & 2 rubygems

Version Path
has_finder-0.1.1 spec/rails/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
has_finder-0.1.2 spec/rails/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
has_finder-0.1.3 spec/rails/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
rspec-1.0.5 spec/spec/matchers/exist_spec.rb
rspec-1.0.6 spec/spec/matchers/exist_spec.rb
rspec-1.0.7 spec/spec/matchers/exist_spec.rb
rspec-1.0.8 spec/spec/matchers/exist_spec.rb