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
dchelimsky-rspec-1.1.10 spec/spec/matchers/exist_spec.rb
dchelimsky-rspec-1.1.11.1 spec/spec/matchers/exist_spec.rb
dchelimsky-rspec-1.1.11.2 spec/spec/matchers/exist_spec.rb
dchelimsky-rspec-1.1.11.3 spec/spec/matchers/exist_spec.rb
dchelimsky-rspec-1.1.11.4 spec/spec/matchers/exist_spec.rb
dchelimsky-rspec-1.1.11.5 spec/spec/matchers/exist_spec.rb
dchelimsky-rspec-1.1.11.6 spec/spec/matchers/exist_spec.rb
dchelimsky-rspec-1.1.11.7 spec/spec/matchers/exist_spec.rb
dchelimsky-rspec-1.1.11 spec/spec/matchers/exist_spec.rb
dchelimsky-rspec-1.1.12 spec/spec/matchers/exist_spec.rb
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb
newbamboo-evented-rspec-1.1.12 spec/spec/matchers/exist_spec.rb
newbamboo-rspec-1.1.12 spec/spec/matchers/exist_spec.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/exist_spec.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/exist_spec.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/exist_spec.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/matchers/exist_spec.rb