Method: MiniSpec::InstanceAPI#__ms__run_test

Defined in:
lib/minispec/api/instance.rb

#__ms__run_test(label) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/minispec/api/instance.rb', line 113

def __ms__run_test label
  Minispec.tests += 1
  __ms__prepare_test
  runner = proc do
    # running :before hooks, if any
    self.class.before?(label).each {|(l,m,b)| instance_exec(l,m,&b)}

    # running test
    catch :__ms__stop_evaluation do
      instance_exec(&self.class.tests[label].last)
    end

    # running :after hooks, if any
    self.class.after?(label).each {|(l,m,b)| instance_exec(l,m,&b)}
  end

  if around = self.class.around?(label).last
    self.instance_exec(runner, &around.last)
  else
    runner.call
  end

  __ms__mocks__validate_expectations
  __ms__mocks__restore_originals
  @__ms__failures
rescue Exception => e
  [e]
ensure
  __ms__mocks__reset_variables
end