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.



127
128
129
130
131
132
133
# File 'lib/xspec.rb', line 127

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.



125
126
127
# File 'lib/xspec.rb', line 125

def compiled_xspec
  @compiled_xspec
end

#errorObject (readonly)

Returns the value of attribute error.



125
126
127
# File 'lib/xspec.rb', line 125

def error
  @error
end

#failuresObject (readonly)

Returns the value of attribute failures.



125
126
127
# File 'lib/xspec.rb', line 125

def failures
  @failures
end

#pathObject (readonly)

Returns the value of attribute path.



125
126
127
# File 'lib/xspec.rb', line 125

def path
  @path
end

#processorObject (readonly)

Returns the value of attribute processor.



125
126
127
# File 'lib/xspec.rb', line 125

def processor
  @processor
end

Instance Method Details

#errored?Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/xspec.rb', line 147

def errored?
  @errored
end

#failures?Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/xspec.rb', line 143

def failures?
  !@failures.empty?
end

#not_run?Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/xspec.rb', line 135

def not_run?
  !@ran
end

#ran?Boolean

Returns:

  • (Boolean)


139
140
141
# File 'lib/xspec.rb', line 139

def ran?
  @ran
end

#run!Object



155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/xspec.rb', line 155

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)


151
152
153
# File 'lib/xspec.rb', line 151

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