# author: Percival date: 12/06/09
# Have a good day!
require 'clazz'
describe Clazz do
before(:each) do
@clazz = Clazz.new
end
it "蹇呴』鑳藉瀛樺偍鍜岃緗被鍚?/span>" do
end
it "蹇呴』灝嗗畠瀹炵幇鐨勬帴鍙e瓨鍌ㄥ湪涓涓泦鍚堥噷" do
end
it "蹇呴』鏈変竴涓泦鍚堢敤鏉ュ瓨鍌ㄩ渶瑕佸鍏ョ殑綾?/span>" do
end
it "蹇呴』瀵瑰鎻愪緵鎷ユ湁鐨勬墍鏈夋柟娉曟帴鍙?/span>" do
end
it "蹇呴』鑳藉浠庝竴涓枃浠朵腑瀵煎叆綾諱俊鎭?/span>" do
end
end
闇瑕佷慨鏀?lib/spec/example/example_proxy.rb涓猴細
require 'iconv' #璁ヾescribe鏀寔涓枃 鈥斺擯ercival
module Spec
module Example
# Lightweight proxy for an example. This is the object that is passed to
# example-related methods in Spec::Runner::Formatter::BaseFormatter
class ExampleProxy
def initialize(description=nil, options={}, location=nil) # :nodoc:
#璁ヾescribe鏀寔涓枃 鈥斺擯ercival
description = Iconv.iconv("GBK","UTF-8",description)
@description, @options, @location = description, options, location
end
# Optional hash passed to the example declaration
attr_reader :options
# This is the docstring passed to the <tt>it()</tt> method or any
# of its aliases
attr_reader :description
# The file and line number at which the represented example
# was declared. This is extracted from <tt>caller</tt>, and is therefore
# formatted as an individual line in a backtrace.
attr_reader :location
# Deprecated - use location()
def backtrace
Spec.deprecate("ExampleProxy#backtrace","ExampleProxy#location")
location
end
# Convenience method for example group - updates the value of
# <tt>description</tt> and returns self.
def update(description) # :nodoc:
@description = description
self
end
def ==(other) # :nodoc:
(other.description == description) & (other.location == location)
end
end
end
end
鐒跺悗璁﹕hould鍜宻hould_not鏀寔涓枃錛屼慨鏀筶ib\spec\expectations\handler.rb:
require 'iconv'
module Spec
module Expectations
class InvalidMatcherError < ArgumentError; end
class PositiveExpectationHandler
def self.handle_matcher(actual, matcher, message=nil, &block)
#璁﹕hould鏀寔涓枃
if(actual.instance_of? String)
actual = Iconv.iconv("UTF-8","GBK",actual).first
end
::Spec::Matchers.last_should = :should
::Spec::Matchers.last_matcher = matcher
return ::Spec::Matchers::PositiveOperatorMatcher.new(actual) if matcher.nil?
match = matcher.matches?(actual, &block)
return match if match
message ||= matcher.respond_to?(:failure_message_for_should) ?
matcher.failure_message_for_should :
matcher.failure_message
if matcher.respond_to?(:diffable?) && matcher.diffable?
::Spec::Expectations.fail_with message, matcher.expected.first, matcher.actual
else
::Spec::Expectations.fail_with message
end
end
end
class NegativeExpectationHandler
def self.handle_matcher(actual, matcher, message=nil, &block)
#璁﹕hould鏀寔涓枃
if(actual.instance_of? String)
actual = Iconv.iconv("UTF-8","GBK",actual).first
end
::Spec::Matchers.last_should = :should_not
::Spec::Matchers.last_matcher = matcher
return ::Spec::Matchers::NegativeOperatorMatcher.new(actual) if matcher.nil?
match = matcher.respond_to?(:does_not_match?) ?
!matcher.does_not_match?(actual, &block) :
matcher.matches?(actual, &block)
return match unless match
message ||= matcher.respond_to?(:failure_message_for_should_not) ?
matcher.failure_message_for_should_not :
matcher.negative_failure_message
if matcher.respond_to?(:diffable?) && matcher.diffable?
::Spec::Expectations.fail_with message, matcher.expected.first, matcher.actual
else
::Spec::Expectations.fail_with message
end
end
end
end
end
鏆傛椂鎴戝彧鐢ㄥ埌榪欎簺鍏冪礌錛屽彲鑳借繕涓嶅叏闈紝鏈夐亣鍒伴棶棰樼殑鍐嶅姞涓娿?br />

]]>