Sha256: 8b3cd5bd9435b2af3657e6d95f11bcc05952bf7df4fe8eda9f0c81440e611f13

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 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

3 entries across 3 versions & 1 rubygems

Version Path
picolena-0.1.6 rails_plugins/rspec/spec/spec/matchers/exist_spec.rb
picolena-0.1.7 rails_plugins/rspec/spec/spec/matchers/exist_spec.rb
picolena-0.1.8 rails_plugins/rspec/spec/spec/matchers/exist_spec.rb