Sha256: 63e15eafb59798d693baa8ac4d2dd3804d397b32b3f3e6a561bfbcb74fef7084

Contents?: true

Size: 1.23 KB

Versions: 27

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 RSpec::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 "passes if target exists" do
      real_tester = SubstanceTester.new @real
      real_tester.should_exist
    end

  end

end

Version data entries

27 entries across 27 versions & 3 rubygems

Version Path
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/exist_spec.rb
rspec-expectations-2.4.0 spec/rspec/matchers/exist_spec.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/exist_spec.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/exist_spec.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/exist_spec.rb
rspec-expectations-2.3.0 spec/rspec/matchers/exist_spec.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/exist_spec.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/exist_spec.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/spec/rspec/matchers/exist_spec.rb
rspec-expectations-2.2.0 spec/rspec/matchers/exist_spec.rb
rspec-expectations-2.1.0 spec/rspec/matchers/exist_spec.rb
rspec-expectations-2.0.1 spec/rspec/matchers/exist_spec.rb
gemrage-1.0.0 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/exist_spec.rb
gemrage-0.4.1 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/exist_spec.rb
gemrage-0.4.0 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/exist_spec.rb
gemrage-0.3.2 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/exist_spec.rb
gemrage-0.3.1 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/exist_spec.rb
gemrage-0.3.0 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/exist_spec.rb
gemrage-0.2.0 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/exist_spec.rb
gemrage-0.1.2 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/spec/rspec/matchers/exist_spec.rb