Sha256: bab44df62e90029b15d694da33436e71c7f9066e3c47ee4de0daa9bcccfc2a9d

Contents?: true

Size: 1.08 KB

Versions: 72

Compression:

Stored size: 1.08 KB

Contents

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

class Substance
  def initialize exists, description
    @exists = exists
    @description = description
  end
  def exist?
    @exists
  end
  def inspect
    @description
  end
end
  
class SubstanceTester
  include Spec::Matchers
  def initialize substance
    @substance = substance
  end
  def should_exist
    @substance.should exist
  end
end

describe "should exist," do
  
  before(:each) do
    @real = Substance.new true, 'something real'
    @imaginary = Substance.new false, 'something imaginary'
  end

  describe "within an example group" do
  
    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
    
    it "should pass if target doesn't exist" do
      lambda { @real.should_not exist }.should fail
    end
  end

  describe "outside of an example group" do

    it "should pass if target exists" do
      real_tester = SubstanceTester.new @real
      real_tester.should_exist
    end

  end

end

Version data entries

72 entries across 72 versions & 12 rubygems

Version Path
rspec-1.1.1 spec/spec/matchers/exist_spec.rb
rspec-1.1.6 spec/spec/matchers/exist_spec.rb
rspec-1.1.3 spec/spec/matchers/exist_spec.rb
rspec-1.1.11 spec/spec/matchers/exist_spec.rb
rspec-1.1.12 spec/spec/matchers/exist_spec.rb
rspec-1.1.2 spec/spec/matchers/exist_spec.rb
rspec-1.1.4 spec/spec/matchers/exist_spec.rb
rspec-1.1.5 spec/spec/matchers/exist_spec.rb
rspec-1.1.7 spec/spec/matchers/exist_spec.rb
rspec-1.1.8 spec/spec/matchers/exist_spec.rb
rspec-1.1.9 spec/spec/matchers/exist_spec.rb
spree-0.2.0 vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
spree-0.4.1 vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
spree-0.4.0 vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
spree-0.5.0 vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
spree-0.6.0 vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
spree-0.5.1 vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
spree-0.7.1 vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
spree-0.7.0 vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
spree-0.8.0 vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb