Class: XSpec::SpecFile

Inherits:
Object
  • Object
show all
Defined in:
lib/xspec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(processor, path, compiled_xspec) ⇒ SpecFile

Returns a new instance of SpecFile.



156
157
158
159
160
161
162
# File 'lib/xspec.rb', line 156

def initialize(processor, path, compiled_xspec)
  @processor, @path, @compiled_xspec = processor, path, compiled_xspec
  @ran = false
  @errored = false
  @failures = []
  @error = ''
end

Instance Attribute Details

#compiled_xspecObject (readonly)

Returns the value of attribute compiled_xspec.



154
155
156
# File 'lib/xspec.rb', line 154

def compiled_xspec
  @compiled_xspec
end

#errorObject (readonly)

Returns the value of attribute error.



154
155
156
# File 'lib/xspec.rb', line 154

def error
  @error
end

#failuresObject (readonly)

Returns the value of attribute failures.



154
155
156
# File 'lib/xspec.rb', line 154

def failures
  @failures
end

#pathObject (readonly)

Returns the value of attribute path.



154
155
156
# File 'lib/xspec.rb', line 154

def path
  @path
end

#processorObject (readonly)

Returns the value of attribute processor.



154
155
156
# File 'lib/xspec.rb', line 154

def processor
  @processor
end

Instance Method Details

#errored?Boolean

Returns:

  • (Boolean)


176
177
178
# File 'lib/xspec.rb', line 176

def errored?
  @errored
end

#failures?Boolean

Returns:

  • (Boolean)


172
173
174
# File 'lib/xspec.rb', line 172

def failures?
  !@failures.empty?
end

#not_run?Boolean

Returns:

  • (Boolean)


164
165
166
# File 'lib/xspec.rb', line 164

def not_run?
  !@ran
end

#ran?Boolean

Returns:

  • (Boolean)


168
169
170
# File 'lib/xspec.rb', line 168

def ran?
  @ran
end

#run!Object



184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/xspec.rb', line 184

def run!
  if not_run?
    begin
      @ran = true
      output = compiled_xspec.transform_with_named_template(Saxon::S9API::QName.fromClarkName('{http://www.jenitennison.com/xslt/xspec}main'))
      check_failures(output).each do |failure|
        @failures << test_label(failure)
      end
    rescue Exception => e
      @errored = true
      @error = e.to_s
    end
  end
end

#successful?Boolean

Returns:

  • (Boolean)


180
181
182
# File 'lib/xspec.rb', line 180

def successful?
  !(failures? || errored?)
end