Sha256: d767106fee52628c81a38fa9ebe9fd4d1080ed5c85588fd275136fb2334660d1

Contents?: true

Size: 1.23 KB

Versions: 32

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

class Substance
  def initialize exists, description
    @exists = exists
    @description = description
  end
  def exist?(arg=nil)
    @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 "passes if target exists" do
      @real.should exist
    end
  
    it "passes if target exists with args" do
      @real.should exist('this arg')
    end
  
    it "fails if target does not exist" do
      lambda { @imaginary.should exist }.should fail
    end
    
    it "describes itself" do
      exist.description.should == "exist"
    end
    
    it "passes should_not exist 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

32 entries across 32 versions & 11 rubygems

Version Path
rspec-instructure-1.3.3 spec/spec/matchers/exist_spec.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/spec/spec/matchers/exist_spec.rb
rspec-1.3.2 spec/spec/matchers/exist_spec.rb
rspec-1.3.1 spec/spec/matchers/exist_spec.rb
rspec-1.3.1.rc spec/spec/matchers/exist_spec.rb
rspec-1.3.0 spec/spec/matchers/exist_spec.rb
hubbub-0.0.11 lib/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
hubbub-0.0.10 lib/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
hubbub-0.0.9 lib/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
hubbub-0.0.8 lib/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
hubbub-0.0.6 lib/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/spec/spec/matchers/exist_spec.rb
media-path-0.1.2 vendor/rspec/spec/spec/matchers/exist_spec.rb
simple-templater-0.0.1.3 vendor/rspec/spec/spec/matchers/exist_spec.rb
pupu-0.0.2.pre vendor/rspec/spec/spec/matchers/exist_spec.rb
media-path-0.1.1.pre vendor/rspec/spec/spec/matchers/exist_spec.rb
simple-templater-0.0.1.2 vendor/rspec/spec/spec/matchers/exist_spec.rb
media-path-0.1.1 vendor/rspec/spec/spec/matchers/exist_spec.rb
simple-templater-0.0.1.1 vendor/rspec/spec/spec/matchers/exist_spec.rb
pupu-0.0.2 vendor/rspec/spec/spec/matchers/exist_spec.rb