lib/tryouts/drill/response.rb in tryouts-0.8.1 vs lib/tryouts/drill/response.rb in tryouts-0.8.2
- old
+ new
@@ -112,105 +112,6 @@
end
end
- # = Dream
- #
- # Contains the expected response of a Drill
- #
- class Dream < Tryouts::Drill::Response
-
- def self.from_block(definition)
- d = Tryouts::Drill::Dream.new
- d.from_block definition
- d
- end
-
- def from_block(definition)
- self.output = instance_eval &definition
- self
- end
-
- # Takes a String +val+ and splits the lines into an Array.
- def inline(val=nil)
- lines = (val.split($/) || [])
- lines.shift if lines.first.strip == ""
- lines.pop if lines.last.strip == ""
- lines
- end
-
- def ==(reality)
- return @answer unless @answer.nil?
- @answer = Response.compare(self, reality)
- end
-
- def test_to_string(reality)
- return @test_string unless @test_string.nil?
- @test_string = Response.compare_string(self, reality)
- end
-
- def comparison_value
- return @ret unless @ret.nil?
- @ret = case @format
- when :gt, :gte, :lt, :lte, :ne
- op = {:gt=>'>',:gte=>'>=', :lt=>'<', :lte => '<=', :ne => '!='}.find { |i| i[0] == @format }
- @output
- when :proc
- true
- when :respond_to?, :is_a?, :kind_of?
- true
- when :grep
- @output
- else
- @output
- end
- end
- end
-
- # = Reality
- #
- # Contains the actual response of a Drill
- #
- class Reality < Tryouts::Drill::Response
- # An ordered hash taken from the DrillContext that created this Reality.
- attr_accessor :stash
- attr_accessor :error
- attr_accessor :trace
- attr_accessor :ecode
- attr_accessor :etype
- # For :cli drills only. Contains the shell command string.
- attr_accessor :command
- def initialize
- @stash = Tryouts::HASH_TYPE.new
- end
-
- def ==(dream)
- Response.compare(dream, self)
- end
-
- def comparison_value(dream)
- case dream.format
- when :proc
- test = dream.output
- (test.arity > 0 ? test.call(@output) : test.call)
- when :exception
- @etype
- when :respond_to?, :is_a?, :kind_of?, :grep
- @output.send(dream.format, dream.output)
- when nil
- @output
- else
- return nil if @output.nil?
-
- if !dream.format.is_a?(Symbol)
- "This dream format is not a Symbol: #{dream.format}"
- elsif @output.respond_to?(dream.format)
- @output.send(dream.format)
- else
- @output
- end
- end
- end
- end
-
end
\ No newline at end of file