mutant-rspec 0.5.21 → 0.5.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 064467b2c0694b44ad583fc3d479b9220b74b9ea
4
- data.tar.gz: 36b97933202ddd5e21f940690740a57c0aeb31cf
3
+ metadata.gz: 1e655905aa30d6df975efd30f80bda241a3feea5
4
+ data.tar.gz: 38bf05fd4651d53707c6bdd153753d1ba7ef27db
5
5
  SHA512:
6
- metadata.gz: 119a43e58d595fdd3d3dfa51f80818767ae4fb755354483351190ae776e41125a5ab08ad82ccde2a771e37803145f68e592dc409f4e5fe10a524d3cad350c26a
7
- data.tar.gz: 73c464175709ac56a6a6a3012a52a35ae1fc23e62204588a929cd7f9e9f44f326cff5342d379c528767dc3c22191e8ffcdf3acba9fd0352339e2b78b7d94a82e
6
+ metadata.gz: 997e686cb3add7fde95533e79bd5115bdfc951588fda02183f70b5b26bbbd3531d858f3d84e92bc2c2a3bd67e07d5d166855026b4159380a18816d4e2ba7cdc5
7
+ data.tar.gz: a01a00191b2b9ddec5210229748c885055fab54ec4b00ea2d9895448a3b9e9294a5177c218b5ebda286d24fa7618082e34a7af89c68e16636e83db3e529cf5d4
@@ -0,0 +1,111 @@
1
+ # encoding: UTF-8
2
+ require 'rspec/core'
3
+ require 'rspec/core/version'
4
+
5
+ require 'rspec/core/formatters/base_text_formatter'
6
+
7
+ module Mutant
8
+ class Integration
9
+ # Shared parts of rspec2/3 integration
10
+ class Rspec < self
11
+ include AbstractType
12
+
13
+ # Setup rspec integration
14
+ #
15
+ # @return [self]
16
+ #
17
+ # @api private
18
+ #
19
+ def setup
20
+ options.configure(configuration)
21
+ configuration.load_spec_files
22
+ self
23
+ end
24
+ memoize :setup
25
+
26
+ # Return report for test
27
+ #
28
+ # @param [Rspec::Test] test
29
+ #
30
+ # @return [Test::Report]
31
+ #
32
+ # @api private
33
+ #
34
+ def run(test)
35
+ output = StringIO.new
36
+ success = false
37
+ reporter = new_reporter(output)
38
+ reporter.report(1) do
39
+ success = example_group_index.fetch(test.expression.syntax).run(reporter)
40
+ end
41
+ output.rewind
42
+ Test::Report.new(
43
+ test: self,
44
+ output: output.read,
45
+ success: success
46
+ )
47
+ end
48
+
49
+ # Return all available tests
50
+ #
51
+ # @return [Enumerable<Test>]
52
+ #
53
+ # @api private
54
+ #
55
+ def all_tests
56
+ example_group_index.keys.each_with_object([]) do |full_description, aggregate|
57
+ expression = Expression.try_parse(full_description) or next
58
+
59
+ aggregate << Test.new(self, expression)
60
+ end
61
+ end
62
+ memoize :all_tests
63
+
64
+ private
65
+
66
+ # Return all example groups
67
+ #
68
+ # @return [Hash<String, RSpec::Core::ExampleGroup]
69
+ #
70
+ # @api private
71
+ #
72
+ def example_group_index
73
+ Hash[RSpec.world.example_groups.flat_map(&:descendants).map do |example_group|
74
+ [full_description(example_group), example_group]
75
+ end]
76
+ end
77
+ memoize :example_group_index
78
+
79
+ # Return configuration
80
+ #
81
+ # @return [RSpec::Core::Configuration]
82
+ #
83
+ # @api private
84
+ #
85
+ def configuration
86
+ RSpec::Core::Configuration.new
87
+ end
88
+ memoize :configuration, freezer: :noop
89
+
90
+ # Return options
91
+ #
92
+ # @return [RSpec::Core::ConfigurationOptions]
93
+ #
94
+ # @api private
95
+ #
96
+ def options
97
+ RSpec::Core::ConfigurationOptions.new(%w[--fail-fast spec])
98
+ end
99
+ memoize :options, freezer: :noop
100
+
101
+ end # Rspec
102
+ end # Integration
103
+ end # Mutant
104
+
105
+ RSPEC_2_VERSION_PREFIX = '2.'.freeze
106
+
107
+ if RSpec::Core::Version::STRING.start_with?(RSPEC_2_VERSION_PREFIX)
108
+ require 'mutant/integration/rspec2'
109
+ else
110
+ require 'mutant/integration/rspec3'
111
+ end
@@ -0,0 +1,48 @@
1
+ module Mutant
2
+ class Integration
3
+ # Rspec2 integration
4
+ class Rspec2 < Rspec
5
+
6
+ register 'rspec'
7
+
8
+ private
9
+
10
+ # Return options
11
+ #
12
+ # @return [RSpec::Core::ConfigurationOptions]
13
+ #
14
+ # @api private
15
+ #
16
+ def options
17
+ super.tap(&:parse_options)
18
+ end
19
+
20
+ # Return full description of example group
21
+ #
22
+ # @param [RSpec::Core::ExampleGroup] example_group
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @api private
27
+ #
28
+ def full_description(example_group)
29
+ example_group.metadata.fetch(:example_group).fetch(:full_description)
30
+ end
31
+
32
+ # Return new reporter
33
+ #
34
+ # @param [StringIO] output
35
+ #
36
+ # @return [RSpec::Core::Reporter]
37
+ #
38
+ # @api private
39
+ #
40
+ def new_reporter(output)
41
+ formatter = RSpec::Core::Formatters::BaseTextFormatter.new(output)
42
+
43
+ RSpec::Core::Reporter.new(formatter)
44
+ end
45
+
46
+ end # Rspec2
47
+ end # Integration
48
+ end # Mutant
@@ -0,0 +1,41 @@
1
+ module Mutant
2
+ class Integration
3
+ # Rspec3 integration
4
+ class Rspec3 < Rspec
5
+
6
+ register 'rspec'
7
+
8
+ private
9
+
10
+ # Return full description for example group
11
+ #
12
+ # @param [RSpec::Core::ExampleGroup] example_group
13
+ #
14
+ # @return [String]
15
+ #
16
+ # @api private
17
+ #
18
+ def full_description(example_group)
19
+ example_group.metadata.fetch(:full_description)
20
+ end
21
+
22
+ # Return new reporter
23
+ #
24
+ # @param [StringIO] output
25
+ #
26
+ # @return [RSpec::Core::Reporter]
27
+ #
28
+ # @api private
29
+ #
30
+ def new_reporter(output)
31
+ formatter = RSpec::Core::Formatters::BaseTextFormatter.new(output)
32
+ notifications = RSpec::Core::Formatters::Loader.allocate.send(:notifications_for, formatter.class)
33
+
34
+ RSpec::Core::Reporter.new(configuration).tap do |reporter|
35
+ reporter.register_listener(formatter, *notifications)
36
+ end
37
+ end
38
+
39
+ end # Rspec3
40
+ end # Integration
41
+ end # Mutant
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutant-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.21
4
+ version: 0.5.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-15 00:00:00.000000000 Z
11
+ date: 2014-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mutant
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.21
19
+ version: 0.5.24
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.21
26
+ version: 0.5.24
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec-core
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -75,9 +75,9 @@ extra_rdoc_files:
75
75
  files:
76
76
  - LICENSE
77
77
  - TODO
78
- - lib/mutant/rspec.rb
79
- - lib/mutant/rspec/strategy.rb
80
- - lib/mutant/rspec/test.rb
78
+ - lib/mutant/integration/rspec.rb
79
+ - lib/mutant/integration/rspec2.rb
80
+ - lib/mutant/integration/rspec3.rb
81
81
  homepage: https://github.com/mbj/mutant
82
82
  licenses:
83
83
  - MIT
data/lib/mutant/rspec.rb DELETED
@@ -1,13 +0,0 @@
1
- # encoding: UTF-8
2
- require 'rspec/core'
3
- require 'rspec/version'
4
-
5
- module Mutant
6
- # Rspec integration namespace
7
- module Rspec
8
- end # Rspec
9
- end # Mutant
10
-
11
- require 'mutant/rspec'
12
- require 'mutant/rspec/strategy'
13
- require 'mutant/rspec/test'
@@ -1,135 +0,0 @@
1
- module Mutant
2
- module Rspec
3
-
4
- # Rspec killer strategy
5
- class Strategy < Mutant::Strategy
6
-
7
- RSPEC_2_VERSION_PREFIX = '2.'.freeze
8
-
9
- register 'rspec'
10
-
11
- # Setup rspec strategy
12
- #
13
- # @return [self]
14
- #
15
- # @api private
16
- #
17
- def setup
18
- options.configure(configuration)
19
- configuration.load_spec_files
20
- self
21
- end
22
- memoize :setup
23
-
24
- # Test for rspec2
25
- #
26
- # @return [Boolean]
27
- #
28
- # @api private
29
- #
30
- def rspec2?
31
- RSpec::Core::Version::STRING.start_with?(RSPEC_2_VERSION_PREFIX)
32
- end
33
-
34
- # Return report for test
35
- #
36
- # @param [Rspec::Test] test
37
- #
38
- # @api private
39
- #
40
- def run(test)
41
- output = StringIO.new
42
- success = false
43
- reporter = new_reporter(output)
44
- reporter.report(1) do
45
- success = test.example_group.run(reporter)
46
- end
47
- output.rewind
48
- Test::Report.new(
49
- test: self,
50
- output: output.read,
51
- success: success
52
- )
53
- end
54
-
55
- # Return all available tests
56
- #
57
- # @return [Enumerable<Test>]
58
- #
59
- # @api private
60
- #
61
- def all_tests
62
- example_groups
63
- .flat_map(&:descendants)
64
- .map do |example_group|
65
- Test.new(self, example_group)
66
- end.select do |test|
67
- test.identification.split(' ', 2).first.eql?(test.identification)
68
- end
69
- end
70
- memoize :all_tests
71
-
72
- private
73
-
74
- # Return example groups
75
- #
76
- # @return [Enumerable<RSpec::Core::ExampleGroup>]
77
- #
78
- # @api private
79
- #
80
- def example_groups
81
- RSpec.world.example_groups
82
- end
83
-
84
- # Return new reporter
85
- #
86
- # @param [StringIO] output
87
- #
88
- # @return [RSpec::Core::Reporter]
89
- #
90
- # @api private
91
- #
92
- def new_reporter(output)
93
- reporter_class = RSpec::Core::Reporter
94
-
95
- # rspec3 does not require that one via a very indirect autoload setup
96
- require 'rspec/core/formatters/base_text_formatter'
97
- formatter = RSpec::Core::Formatters::BaseTextFormatter.new(output)
98
-
99
- if rspec2?
100
- reporter_class.new(formatter)
101
- else
102
- notifications = RSpec::Core::Formatters::Loader.allocate.send(:notifications_for, formatter.class)
103
- reporter = reporter_class.new(configuration)
104
- reporter.register_listener(formatter, *notifications)
105
- reporter
106
- end
107
- end
108
-
109
- # Return configuration
110
- #
111
- # @return [RSpec::Core::Configuration]
112
- #
113
- # @api private
114
- #
115
- def configuration
116
- RSpec::Core::Configuration.new
117
- end
118
- memoize :configuration, freezer: :noop
119
-
120
- # Return options
121
- #
122
- # @return [RSpec::Core::ConfigurationOptions]
123
- #
124
- # @api private
125
- #
126
- def options
127
- options = RSpec::Core::ConfigurationOptions.new(%w[--fail-fast spec])
128
- options.parse_options if rspec2?
129
- options
130
- end
131
- memoize :options, freezer: :noop
132
-
133
- end # Strategy
134
- end # Rspec
135
- end # Mutant
@@ -1,37 +0,0 @@
1
- module Mutant
2
- module Rspec
3
- # Rspec test abstraction
4
- class Test < Mutant::Test
5
- include Concord::Public.new(:strategy, :example_group)
6
-
7
- PREFIX = :rspec
8
-
9
- # Return subject identification
10
- #
11
- # @return [String]
12
- #
13
- # @api private
14
- #
15
- def subject_identification
16
- metadata = example_group.metadata
17
- if strategy.rspec2?
18
- metadata.fetch(:example_group).fetch(:full_description)
19
- else
20
- metadata.fetch(:full_description)
21
- end
22
- end
23
- memoize :subject_identification
24
-
25
- # Run test, return report
26
- #
27
- # @return [String]
28
- #
29
- # @api private
30
- #
31
- def run
32
- strategy.run(self)
33
- end
34
-
35
- end # Test
36
- end # Rspec
37
- end # Mutant