細かいことは置いておいて、CI::Reporter 1.9.1を使おうとすると落ちるようになりました。
Jenkinsでテスト結果集計に使っていたりなんかすると非常に困ります。
で、適当に対策してみました。
以下のコードをRailsなら
config/initializers/ci_reporter.rbなどの適当なinitializerに追加します。Rails以外は知らないので適当に読み替えてください。実行後に警告は出ますが一応動くようになります。気になる人は自分でなんとかしてください。
module CI
module Reporter
class RSpec
def example_group_started(example_group)
@formatter.example_group_started(::RSpec::Core::Notifications::GroupNotification.new(example_group))
new_suite(description_for(example_group))
end
def example_started(name_or_example)
@formatter.example_started(::RSpec::Core::Notifications::ExampleNotification.new(name_or_example))
spec = TestCase.new
@suite.testcases << spec
spec.start
end
def example_failed(name_or_example, *rest)
@formatter.example_failed(::RSpec::Core::Notifications::ExampleNotification.new(name_or_example), *rest)
# In case we fail in before(:all)
example_started(name_or_example) if @suite.testcases.empty?
if name_or_example.respond_to?(:execution_result) # RSpec 2
failure = RSpec2Failure.new(name_or_example, @formatter)
else
failure = RSpecFailure.new(rest[1]) # example_failed(name, counter, failure) in RSpec 1
end
spec = @suite.testcases.last
spec.finish
spec.name = description_for(name_or_example)
spec.failures << failure
end
def example_passed(name_or_example)
@formatter.example_passed(::RSpec::Core::Notifications::ExampleNotification.new(name_or_example))
spec = @suite.testcases.last
spec.finish
spec.name = description_for(name_or_example)
end
def example_pending(*args)
@formatter.example_pending(::RSpec::Core::Notifications::ExampleNotification.new(*args))
name = description_for(args[0])
spec = @suite.testcases.last
spec.finish
spec.name = "#{name} (PENDING)"
spec.skipped = true
end
def dump_summary(*args)
if args.size == 4
notification = ::RSpec::Core::Notifications::SummaryNotification.new(*args)
args = []
args[0] = notification
end
@formatter.dump_summary(*args)
write_report
@formatter.dump_failures(::RSpec::Core::Notifications::SummaryNotification.new)
end
def method_missing(meth,*args,&block)
case meth.to_sym
when :message then
unless args[0].methods.include? :message
args[0] = ::RSpec::Core::Notifications::MessageNotification.new(args[0])
end
when :start
unless args[0].methods.include? :count
args[0] = ::RSpec::Core::Notifications::CountNotification.new(args[0])
end
when :seed
unless args[0].methods.include? :seed
args[0] = ::RSpec::Core::Notifications::SeedNotification.new(args[0], true)
end
when :example_group_finished
unless args[0].methods.include? :seed
args[0] = ::RSpec::Core::Notifications::GroupNotification(args[0])
end
when :close, :start_dump, :dump_pending, :dump_failures, :dump_profile, :stop
args[0] = ::RSpec::Core::Notifications::SummaryNotification.new if args.size == 0
end
@formatter.send(meth,*args,&block)
end
end
end
end
このコードはRSpecとCI::Reporterの実装に強く依存しているのでバージョンが変わったら動かなくなる可能性が高いです。あくまで暫定対処なのでその点はご了承ください。
0 件のコメント:
コメントを投稿