Sha256: 68427ed37cca8fe18dc09c351e1e5380de7fd16bf7239ab0c689ae484734b808

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

# The same class in rspec specs file
class Substance
  def initialize exists, description
    @exists = exists
    @description = description
  end
  def exist?(arg=nil)
    @exists
  end
end

module Spec
  module Matchers
    
    describe "exist matcher" do
      
      before(:each) do
        @expected_matcher = {'matchers' => {'exist' => 'existir'}}
        portuguese_language(@expected_matcher)
        Spec::Matchers.register_all_matchers
        @real = Substance.new true, 'something real'
        @imaginary = Substance.new false, 'something imaginary'
      end
      
      it 'should register the exist method translated' do
        values = @expected_matcher['matchers']['exist'].split('|')
        values.each do |value_method|
          Object.instance_methods.should be_include(value_method)
        end
      end
      
      it "passes if target exists" do
        @real.should existir
      end
      
      it "fails if target does not exist" do
        lambda { @imaginary.should exist }.should raise_error
      end
      
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec-i18n-1.1.0 spec/spec-i18n/matchers/exist_spec.rb
rspec-i18n-1.0.0 spec/spec-i18n/matchers/exist_spec.rb