opal-rspec-formatter 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c18b7c448071807ba181cfe4aa8ac6b515265af1
4
+ data.tar.gz: 717b8483156f782172de643fb72dcab27b198144
5
+ SHA512:
6
+ metadata.gz: 61a36ba9e3817522f08bb980864d47147f1b158ee3af1ad2b335e970ab603fe8f73444e1f70e52ce88db5690ec17bd13071f2f5ef671759ab4fe235ae4735ad3
7
+ data.tar.gz: 62b14e729fc312ecc4084dfd895d433b620e62d7d400f135e93673e050211e9e625fe429b7c0a972d282abe5859438bfcf9106eea0069c5a1b7db6eaaadfc9c3
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ pkg
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "opal-rspec"]
2
+ path = opal-rspec
3
+ url = https://github.com/wied03/opal-rspec.git
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1
7
+
8
+ before_install:
9
+ - git submodule update --init
10
+ - (cd opal-rspec; git submodule update --init)
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ # Remove this once we use an opal-rspec GEM
5
+ system 'git submodule update --init; (cd opal-rspec; git submodule update --init)' unless Dir.glob('opal-rspec/**').any?
6
+ gem 'opal', git: 'https://github.com/opal/opal.git'
7
+ # Until opal-rspec is updated
8
+ gem 'opal-rspec', path: 'opal-rspec'
9
+
10
+ gem 'nokogiri'
11
+ gem 'rspec-expectations'
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # opal-rspec-formatter
2
+
3
+ [![Build Status](http://img.shields.io/travis/wied03/opal-rspec-formatter/master.svg?style=flat)](http://travis-ci.org/wied03/opal-rspec-formatter)
4
+
5
+ An attempt at making the builder XML gem work with Opal
6
+
7
+ ## Usage
8
+
9
+ Add `opal-rspec-formatter` to your Gemfile (once this is published to Rubygems, TBD):
10
+
11
+ ```ruby
12
+ gem 'opal-rspec-formatter'
13
+ ```
14
+
15
+ ### Use in your application
16
+
17
+ In your Rakefile, make the following change
18
+
19
+ ```ruby
20
+ # Note this require replaces require 'opal/rspec/rake_task'
21
+ require 'opal/rspec-formatter/rake_task'
22
+ # Can make the usual adjustments as documented in the opal-rspec project by supplying a block
23
+ Opal::RSpec::RakeTask.new(:default)
24
+ ```
25
+
26
+ #### JUnit
27
+
28
+ Now on the command line, supply the SPEC_OPTS environment variable. Example:
29
+
30
+ ```bash
31
+ SPEC_OPTS="--require opal/rspec/formatters/junit --format Opal::RSpec::Formatters::Junit" rake
32
+ ```
33
+
34
+ If you omit either of these settings, the default opal-rspec formatter will be used (TextFormatter)
35
+
36
+ #### TeamCity
37
+
38
+ Example:
39
+ ```bash
40
+ SPEC_OPTS="--append_exp_from_load_path patch/bdd --append_exp_from_load_path patch/common --require opal/rspec/formatters/teamcity --format Opal::RSpec::Formatters::TeamCity" rake
41
+ ```
42
+
43
+ 'append_exp_from_load_path' is there to avoid distributing a copy of the TeamCity formatter, we only include the patches here. TeamCity and Rubymine usually include the load path to their formatters when they launch Ruby. The append_exp_from_load_path parameter will cause this GEM to selectively add items in the Ruby load path that match the given expression to the Opal load path.
44
+
45
+ #### Custom
46
+ This GEM currently includes a JUnit XML formatter and patches to make the TeamCity/Rubymine runner work, but you can use any formatter you can get working with Opal.
47
+
48
+ ## Limitations:
49
+
50
+ ### General
51
+ * This is still under development, so right now, the XML is just echo'ed to the console. A wrapper task is planned that will write the XML to a file for you.
52
+ * The formatter must be on the Opal load path. If it's not, you'll need to append_paths when you define your Rake task (see opal-rspec info)
53
+ * Of the various SPEC_OPTS possibilities RSpec supports, only --require and --format are supported with this GEM
54
+
55
+ ### TeamCity
56
+ * Does not support output capturing
57
+ * Tweaks how example start/finish reporting works in order to work better with implicit subjects (see https://youtrack.jetbrains.com/issue/RUBY-15519). The side effect is that although test durations will be correct, the test start event is not reported until the test finishes.
58
+
59
+ ## Contributing
60
+
61
+ Install required gems at required versions:
62
+
63
+ $ bundle install
64
+
65
+ A simple rake task should run the example specs in `spec/`:
66
+
67
+ $ bundle exec rake
68
+
69
+ ### Run in the browser
70
+
71
+ Run attached rack app to handle building:
72
+
73
+ $ bundle exec rackup
74
+
75
+ Visit the page in any browser and view the console:
76
+
77
+ $ open http://localhost:9292
78
+
79
+ ## License
80
+
81
+ Authors: Brady Wied
82
+
83
+ Copyright (c) 2015, BSW Technology Consulting LLC
84
+ All rights reserved.
85
+
86
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
87
+
88
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
89
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
90
+
91
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
92
+
93
+ TeamCity and RubyMine are Copyright 2000-2015 JetBrains s.r.o
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ require 'opal/rspec-formatter/rake_task'
7
+ require 'rspec/core/rake_task'
8
+
9
+ Opal::RSpec::RakeTask.new(:raw_specs)
10
+ RSpec::Core::RakeTask.new(:default) do |s|
11
+ s.pattern = 'spec_mri/**/*_spec.rb'
12
+ end
13
+
14
+ # TODO: Create a new Rake task that parses the XML from stdout and writes it to a file
@@ -0,0 +1,7 @@
1
+ require 'opal'
2
+ require 'opal-builder'
3
+
4
+ Opal.append_path File.expand_path('../../opal', __FILE__).untaint
5
+ # Not using use_gem because we don't want the RSpec dependencies rspec_junit_formatter has
6
+ junit = Gem::Specification.find_by_name('rspec_junit_formatter')
7
+ Opal.append_path File.join(junit.gem_dir, 'lib')
@@ -0,0 +1,27 @@
1
+ require 'opal/rspec/rake_task'
2
+
3
+ class Opal::RSpec::RakeTask
4
+ # Monkey patching the constructor without duplicating it here
5
+ alias_method :orig_init, :initialize
6
+
7
+ def initialize(name = 'opal:rspec', &block)
8
+ # We'll add our formatter set code before any main code that uses this task runs. This also should work
9
+ # out of the box with opal-rails, which uses a different server.main util than others
10
+ runner_block = lambda do |server|
11
+ block[server] if block
12
+ run_before_this = server.main
13
+ # TODO: Surely a better way than environment variables to pass this on?
14
+ ENV['opal_rspec_after_formatter_set'] = run_before_this
15
+ server.main = 'opal/rspec/sprockets_runner_customformat'
16
+ regexes = ENV['SPEC_OPTS'].scan /--append_exp_from_load_path (\S+)/
17
+ regexes.each do |r|
18
+ exp = Regexp.new(Regexp.escape(r[0]))
19
+ matches = $:.select {|path| exp.match(path)}
20
+ matches.each do |load_path|
21
+ server.append_path load_path
22
+ end
23
+ end
24
+ end
25
+ orig_init name, &runner_block
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ module Opal
2
+ module RSpec
3
+ module Formatter
4
+ VERSION = '1.0.0'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/opal/rspec-formatter/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'opal-rspec-formatter'
6
+ s.version = Opal::RSpec::Formatter::VERSION
7
+ s.author = 'Brady Wied'
8
+ s.email = 'brady@bswtechconsulting.com'
9
+ s.summary = 'Allows command line control over Opal-RSpec formatters'
10
+ s.description = 'Allows controlling what formatter the opal-rspec Rake task uses, includes JUnit and TeamCity formtter patches'
11
+ s.homepage = 'https://github.com/wied03/opal-rspec-formatter'
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+
15
+ s.require_paths = ['lib']
16
+
17
+ s.add_dependency 'opal', ['>= 0.7.0', '< 0.9']
18
+ # This isn't released yet, but still need to reflect it in here
19
+ s.add_dependency 'opal-rspec', '> 0.4'
20
+ s.add_dependency 'opal-builder', '~> 3.2'
21
+ s.add_dependency 'rspec_junit_formatter'
22
+ s.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1,43 @@
1
+ require 'rspec_junit_formatter'
2
+ require 'opal/rspec/formatters/phantom_util'
3
+
4
+ module Opal
5
+ module RSpec
6
+ module Formatters
7
+ class Junit < ::RSpecJUnitFormatter
8
+ include Opal::RSpec::Formatters::PhantomUtil
9
+ ::RSpec::Core::Formatters.register self,
10
+ :start,
11
+ :stop,
12
+ :dump_summary
13
+
14
+ def initialize
15
+ # with console output, new lines will be all over the place
16
+ super output=StringIO.new
17
+ end
18
+
19
+ def dump_summary(notification)
20
+ @summary_notification = notification
21
+ xml_dump
22
+ puts '---begin xml---'
23
+ puts output.string
24
+ puts '---end xml---'
25
+ finish_phantom notification
26
+ end
27
+
28
+ # class name based on filename is not that meaningful in the JS world
29
+ def classname_for(notification)
30
+ group = notification.example.example_group
31
+ # Don't need to show the top level/example group
32
+ show = group.parent_groups.reject {|g| g == ::RSpec::Core::ExampleGroup}
33
+ show.reverse.map {|g| g.description}.join '::'
34
+ end
35
+
36
+ # Since we include most of the description under classname, only need stuff for this example here
37
+ def description_for(notification)
38
+ notification.example.description
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,28 @@
1
+ module Opal
2
+ module RSpec
3
+ module Formatters
4
+ module PhantomUtil
5
+ def finish_phantom(notification)
6
+ if notification.pending_count > 0
7
+ finish_with_code(1)
8
+ elsif notification.failure_count == 0
9
+ finish_with_code(0)
10
+ else
11
+ finish_with_code(1)
12
+ end
13
+ end
14
+
15
+ def finish_with_code(code)
16
+ %x{
17
+ if (typeof(phantom) !== "undefined") {
18
+ phantom.exit(code);
19
+ }
20
+ else {
21
+ Opal.global.OPAL_SPEC_CODE = code;
22
+ }
23
+ }
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ require 'opal/rspec/formatters/teamcity/formatter_initializer'
2
+
3
+ # Not including teamcity/spec/runner/formatter/teamcity/formatter because the require File.expand... in there trip up Opal, plus
4
+ # we're using RSpec 3 anyways
5
+
6
+ require 'teamcity/spec/runner/formatter/teamcity/rspec3_formatter'
7
+ require 'opal/rspec/formatters/teamcity/formatter'
8
+ require 'opal/rspec/formatters/teamcity/rspec3_formatter'
9
+ require 'opal/rspec/formatters/teamcity/message_factory'
10
+ require 'opal/rspec/formatters/teamcity/runner_common'
11
+ # Now that we have a base working formatter, we need to add some PhantomJS related code to exit properly
12
+ require 'opal/rspec/formatters/teamcity/opal_formatter'
13
+ require 'opal/rspec/formatters/teamcity/std_capture_helper'
@@ -0,0 +1,21 @@
1
+ require 'teamcity/utils/logger_util'
2
+
3
+ module Rake
4
+ module TeamCity
5
+ module Utils
6
+ class ConsoleLogger < FileLogger
7
+ def initialize(enabled)
8
+ @enabled = enabled
9
+ @log_file = $stdout
10
+ end
11
+
12
+ def log_msg(msg, add_proc_thread_info=false)
13
+ if @enabled
14
+ # Threads don't exist on JS
15
+ @log_file << "[#{Time.now}] : #{" " + msg}\n"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ require 'opal/rspec/formatters/teamcity/debug_logger'
2
+
3
+ # Since we didn't use the main file, we need to add some missing dependencies
4
+ # We can't log to files
5
+ SPEC_FORMATTER_LOG = ::Rake::TeamCity::Utils::ConsoleLogger.new(enabled=false)
@@ -0,0 +1,8 @@
1
+ module Spec
2
+ module Runner
3
+ module Formatter
4
+ RSPEC_VERSION_2 = false
5
+ RSPEC_VERSION_3 = true
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ module Rake::TeamCity::MessageFactory
2
+ # Can't use gsub! in Opal and removed copy_of_text.encode!('UTF-8') if copy_of_text.respond_to? :encode! since we don't exactly have encoding
3
+ def self.replace_escaped_symbols(text)
4
+ copy_of_text = String.new(text)
5
+
6
+ copy_of_text = copy_of_text.gsub(/\|/, "||")
7
+
8
+ copy_of_text = copy_of_text.gsub(/'/, "|'")
9
+ copy_of_text = copy_of_text.gsub(/\n/, "|n")
10
+ copy_of_text = copy_of_text.gsub(/\r/, "|r")
11
+ copy_of_text = copy_of_text.gsub(/\]/, "|]")
12
+
13
+ copy_of_text = copy_of_text.gsub(/\[/, "|[")
14
+
15
+ begin
16
+ copy_of_text = copy_of_text.gsub(/\u0085/, "|x") # next line
17
+ copy_of_text = copy_of_text.gsub(/\u2028/, "|l") # line separator
18
+ copy_of_text = copy_of_text.gsub(/\u2029/, "|p") # paragraph separator
19
+ rescue
20
+ # it is not an utf-8 compatible string :(
21
+ end
22
+
23
+ copy_of_text
24
+ end
25
+ end
@@ -0,0 +1,48 @@
1
+ require 'opal/rspec/formatters/phantom_util'
2
+
3
+ module Opal
4
+ module RSpec
5
+ module Formatters
6
+ # Now that we have a base working formatter, we need to add some PhantomJS related code to exit properly
7
+ class TeamCity < ::Spec::Runner::Formatter::TeamcityFormatter
8
+ include Opal::RSpec::Formatters::PhantomUtil
9
+
10
+ ::RSpec::Core::Formatters.register self, :start, :close,
11
+ :example_group_started, :example_group_finished,
12
+ :example_started, :example_passed,
13
+ :example_pending, :example_failed,
14
+ :dump_summary, :seed
15
+
16
+ # TeamCity doesn't yet identify fluent style examples. In Javascript/Opal, the effect of this is even more pronounced
17
+ # since filenames and line numbers do not mean as much, so waiting to tell TeamCity the example started until it's finished,
18
+ # that way we know the full description - https://youtrack.jetbrains.com/issue/RUBY-15519
19
+
20
+ alias_method :orig_example_started, :example_started
21
+
22
+ def example_started(notification)
23
+ end
24
+
25
+ def dump_summary(notification)
26
+ super
27
+ # Otherwise we won't know when to exit
28
+ finish_phantom notification
29
+ end
30
+
31
+ def example_passed(notification)
32
+ orig_example_started notification
33
+ super
34
+ end
35
+
36
+ def example_pending(notification)
37
+ orig_example_started notification
38
+ super
39
+ end
40
+
41
+ def example_failed(notification)
42
+ orig_example_started notification
43
+ super
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,70 @@
1
+ class Spec::Runner::Formatter::TeamcityFormatter
2
+ # mutable strings
3
+ def dump_summary(summary_notification)
4
+ duration = summary_notification.duration
5
+ example_count = summary_notification.example_count
6
+ failure_count = summary_notification.failure_count
7
+ pending_count = summary_notification.pending_count
8
+ # Repairs stdout and stderr just in case
9
+ repair_process_output
10
+ totals = "#{example_count} example#{'s' unless example_count == 1}"
11
+ totals += ", #{failure_count} failure#{'s' unless failure_count == 1}"
12
+ totals += ", #{example_count - failure_count - pending_count} passed"
13
+ totals += ", #{pending_count} pending" if pending_count > 0
14
+
15
+ # Total statistic
16
+ debug_log(totals)
17
+ log(totals)
18
+
19
+ # Time statistic from Spec Runner
20
+ status_message = "Finished in #{duration} seconds"
21
+ debug_log(status_message)
22
+ log(status_message)
23
+
24
+ #Really must be '@example_count == example_count', it is hack for spec trunk tests
25
+ if !@setup_failed && @example_count > example_count
26
+ msg = "#{RUNNER_ISNT_COMPATIBLE_MESSAGE}Error: Not all examples have been run! (#{example_count} of #{@example_count})\n#{gather_unfinished_examples_name}"
27
+
28
+ log_and_raise_internal_error msg
29
+ debug_log(msg)
30
+ end unless @groups_stack.empty?
31
+
32
+ unless @@RUNNING_EXAMPLES_STORAGE.empty?
33
+ # unfinished examples statistics
34
+ msg = RUNNER_ISNT_COMPATIBLE_MESSAGE + gather_unfinished_examples_name
35
+ log_and_raise_internal_error msg
36
+ end
37
+
38
+ # finishing
39
+ @@RUNNING_EXAMPLES_STORAGE.clear
40
+
41
+ debug_log("Summary finished.")
42
+ end
43
+
44
+ # mutable strings
45
+ def gather_unfinished_examples_name
46
+ if @@RUNNING_EXAMPLES_STORAGE.empty?
47
+ return ""
48
+ end
49
+
50
+ msg = "Following examples weren't finished:"
51
+ count = 1
52
+ @@RUNNING_EXAMPLES_STORAGE.each { |key, value|
53
+ msg += "\n #{count}. Example : '#{value.full_name}'"
54
+ sout_str, serr_str = get_redirected_stdout_stderr_from_files(value.stdout_file_new, value.stderr_file_new)
55
+ unless sout_str.empty?
56
+ msg += "\n[Example Output]:\n#{sout_str}"
57
+ end
58
+ unless serr_str.empty?
59
+ msg += "\n[Example Error Output]:\n#{serr_str}"
60
+ end
61
+
62
+ count += 1
63
+ }
64
+ msg
65
+ end
66
+
67
+ # We can't flush @sout and @serr and we disabled output capturing anyways
68
+ def repair_process_output
69
+ end
70
+ end
@@ -0,0 +1,8 @@
1
+ module Rake::TeamCity::RunnerCommon
2
+ # Opal.IO does not support flush
3
+ def send_msg(msg)
4
+ #@@original_stdout.flush
5
+ @@original_stdout.puts("\n#{msg}")
6
+ #@@original_stdout.flush
7
+ end
8
+ end
@@ -0,0 +1,18 @@
1
+ module Rake::TeamCity::StdCaptureHelper
2
+ # flush /captureis not supported on STDOUT or STDERR
3
+
4
+ def isCaptureDisabled()
5
+ true
6
+ end
7
+
8
+ # flush is not supported on STDOUT or STDERR and it was at the beginning of this method
9
+ def capture_output_end_external(old_out, old_err, new_out, new_err)
10
+ if isCaptureDisabled()
11
+ return "", ""
12
+ end
13
+
14
+ reopen_stdout_stderr(old_out, old_err)
15
+
16
+ return get_redirected_stdout_stderr_from_files(new_out, new_err)
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ require 'opal'
2
+ require 'opal-rspec'
3
+ <%
4
+ spec_opts = ENV['SPEC_OPTS']
5
+ formatter_require_matches = spec_opts.scan /--require (\S+)/
6
+ formatter_class_match = /--format (\S+)/.match(spec_opts)
7
+ if formatter_require_matches.any? and formatter_class_match
8
+ formatter_class = formatter_class_match.captures[0]
9
+
10
+ formatter_require_matches.flatten.each do |format_req|
11
+ %>
12
+ require '<%= format_req %>'
13
+ <% end %>
14
+
15
+ RSpec.configure do |config|
16
+ config.default_formatter = <%= formatter_class %>
17
+ end
18
+
19
+ <% end %>
20
+
21
+ # We've interrupted the usual opal-rspec flow to set the formatter, now run the rest of the 's.main' code
22
+ # This environment variable was set in the Rake task monkey patch in this GEM
23
+ require <%= ENV['opal_rspec_after_formatter_set'].inspect %>
data/spec/test_spec.rb ADDED
@@ -0,0 +1,11 @@
1
+ describe 'foobar' do
2
+ subject { true }
3
+
4
+ context 'succeeds' do
5
+ it { is_expected.to eq true }
6
+ end
7
+
8
+ context 'fails' do
9
+ it { is_expected.to eq false }
10
+ end
11
+ end
@@ -0,0 +1,42 @@
1
+ require 'nokogiri'
2
+
3
+ describe 'JUnit' do
4
+ RSpec::Matchers.define :have_xpath do |xpath|
5
+ get_item = lambda do |document|
6
+ results = document.xpath(xpath)
7
+ results = results.map {|r| r.text }
8
+ results.length == 1 ? results[0] : results
9
+ end
10
+
11
+ match do |document|
12
+ actual = get_item[document]
13
+ @value.is_a?(Regexp) ? @value.match(actual) : (actual == @value)
14
+ end
15
+
16
+ failure_message do |document|
17
+ "Expected #{@value} but got #{get_item[document]}"
18
+ end
19
+
20
+ chain :with_value do |value|
21
+ @value = value
22
+ end
23
+ end
24
+
25
+ before :all do
26
+ # this is expensive to run!
27
+ output = `SPEC_OPTS="--require opal/rspec/formatters/junit --format Opal::RSpec::Formatters::Junit" rake raw_specs`
28
+ xml = /<\?xml.*\<\/testsuite\>/m.match(output)[0]
29
+ @@parsed = Nokogiri::XML xml do |config|
30
+ config.strict
31
+ end
32
+ end
33
+
34
+ subject { @@parsed }
35
+
36
+ it { is_expected.to have_xpath('/testsuite/@tests').with_value('2') }
37
+ it { is_expected.to have_xpath('/testsuite/@failures').with_value('1') }
38
+ it { is_expected.to have_xpath('/testsuite/@errors').with_value('0') }
39
+ it { is_expected.to have_xpath('/testsuite/testcase/@classname').with_value(%w{foobar::succeeds foobar::fails}) }
40
+ it { is_expected.to have_xpath('/testsuite/testcase/@name').with_value(['should eq true', 'should eq false']) }
41
+ it { is_expected.to have_xpath('/testsuite/testcase[@classname="foobar::fails"]/failure/@message').with_value(/expected: false.*got: true/m) }
42
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opal-rspec-formatter
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brady Wied
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: opal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.7.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '0.9'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.7.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.9'
33
+ - !ruby/object:Gem::Dependency
34
+ name: opal-rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.4'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.4'
47
+ - !ruby/object:Gem::Dependency
48
+ name: opal-builder
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.2'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.2'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec_junit_formatter
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ description: Allows controlling what formatter the opal-rspec Rake task uses, includes
90
+ JUnit and TeamCity formtter patches
91
+ email: brady@bswtechconsulting.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - ".gitmodules"
98
+ - ".travis.yml"
99
+ - Gemfile
100
+ - README.md
101
+ - Rakefile
102
+ - lib/opal-rspec-formatter.rb
103
+ - lib/opal/rspec-formatter/rake_task.rb
104
+ - lib/opal/rspec-formatter/version.rb
105
+ - opal-rspec-formatter.gemspec
106
+ - opal/opal/rspec/formatters/junit.rb
107
+ - opal/opal/rspec/formatters/phantom_util.rb
108
+ - opal/opal/rspec/formatters/teamcity.rb
109
+ - opal/opal/rspec/formatters/teamcity/debug_logger.rb
110
+ - opal/opal/rspec/formatters/teamcity/formatter.rb
111
+ - opal/opal/rspec/formatters/teamcity/formatter_initializer.rb
112
+ - opal/opal/rspec/formatters/teamcity/message_factory.rb
113
+ - opal/opal/rspec/formatters/teamcity/opal_formatter.rb
114
+ - opal/opal/rspec/formatters/teamcity/rspec3_formatter.rb
115
+ - opal/opal/rspec/formatters/teamcity/runner_common.rb
116
+ - opal/opal/rspec/formatters/teamcity/std_capture_helper.rb
117
+ - opal/opal/rspec/sprockets_runner_customformat.rb.erb
118
+ - spec/test_spec.rb
119
+ - spec_mri/junit_spec.rb
120
+ homepage: https://github.com/wied03/opal-rspec-formatter
121
+ licenses: []
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.4.5
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Allows command line control over Opal-RSpec formatters
143
+ test_files: []