rspec-xunit 0.5.0 → 0.6.0

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
  SHA256:
3
- metadata.gz: 713f3c53c0bd3aad430437522e74b80d908906ab961722eb20d9a69b22172dde
4
- data.tar.gz: 04d407dfa15abe6a3916a9352d456a0b6397beebadfb6add22246889cca546ba
3
+ metadata.gz: 299943c479de4ea203b6feeedf989a0521f68e70fb577753d477dbceb022e59b
4
+ data.tar.gz: df306b202b8bf9c61ff1ad3c1426425565bd3e5742fe7be0891f37bcc2737401
5
5
  SHA512:
6
- metadata.gz: e34fc54d2bc49c960802fbb767c53a3d30d4021f0fc02d9992d20b8c93eeca98a69f769f7361097f88919b132672cfea0284a24d7663bbc62fc475ca2dc2e353
7
- data.tar.gz: 8e8e894a5ecefd0d7aba030909924a578c61ea707466354961bcce8c8b091a9c2ba0f5422362b3fc7b6cfff9d2ce4e8b4ea9bf0464b94eb58172851454030b27
6
+ metadata.gz: 25dbc4a0a9a5781deca309ab71bb8c1324c23aa3d1a04166efb520aebe8aadb1cd366db33cf5c31cd87eab0033159ebc11753211e72f9db12ac4e2d9664c9ab1
7
+ data.tar.gz: 242ee142fe42210f19d804ab55e946de5e924b19d529135fb7d492d8a159ac2dc3f8a23fb6635fc8459d14c94b7a6d8efe61c5576fc035f01293c7d9a86fa4e5
data/Gemfile CHANGED
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in rspec-xunit.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rspec-mocks'
8
+ gem "rspec-mocks"
9
+ gem "standard"
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
1
  require "bundler/gem_tasks"
2
- task :default => :spec
2
+ task default: :spec
data/lib/rspec-xunit.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rspec/xunit'
3
+ require "rspec/xunit"
data/lib/rspec/xunit.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rspec/core'
4
- require 'rspec/expectations'
5
- require 'rspec/xunit/assertions'
6
- require 'rspec/xunit/syntax'
3
+ require "rspec/core"
4
+ require "rspec/expectations"
5
+ require "rspec/xunit/assertions"
6
+ require "rspec/xunit/syntax"
@@ -15,19 +15,15 @@ module RSpec
15
15
  # - `assert_not_eq` roughly `expect(action).to_not eq(expected)`
16
16
  def assertion_match(matcher, suffix = matcher)
17
17
  define_method "assert_#{suffix}" do |value, *args, &block|
18
- begin
19
- expect(value).to send(matcher, *args, &block)
20
- rescue Expectations::ExpectationNotMetError => e
21
- raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
22
- end
18
+ expect(value).to send(matcher, *args, &block)
19
+ rescue Expectations::ExpectationNotMetError => e
20
+ raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
23
21
  end
24
22
 
25
23
  define_method "assert_not_#{suffix}" do |value, *args, &block|
26
- begin
27
- expect(value).to_not send(matcher, *args, &block)
28
- rescue Expectations::ExpectationNotMetError => e
29
- raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
30
- end
24
+ expect(value).to_not send(matcher, *args, &block)
25
+ rescue Expectations::ExpectationNotMetError => e
26
+ raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
31
27
  end
32
28
  end
33
29
 
@@ -41,19 +37,15 @@ module RSpec
41
37
  # - `assert_not_raises` roughly `expect { bloc }.to_not raise_error`
42
38
  def assertion_match_block(matcher, suffix = matcher)
43
39
  define_method "assert_#{suffix}" do |*args, &block|
44
- begin
45
- expect(&block).to send(matcher, *args)
46
- rescue Expectations::ExpectationNotMetError => e
47
- raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
48
- end
40
+ expect(&block).to send(matcher, *args)
41
+ rescue Expectations::ExpectationNotMetError => e
42
+ raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
49
43
  end
50
44
 
51
45
  define_method "assert_not_#{suffix}" do |*args, &block|
52
- begin
53
- expect(&block).to_not send(matcher, *args)
54
- rescue Expectations::ExpectationNotMetError => e
55
- raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
56
- end
46
+ expect(&block).to_not send(matcher, *args)
47
+ rescue Expectations::ExpectationNotMetError => e
48
+ raise e, e.message, adjust_for_better_failure_message(e.backtrace), cause: nil
57
49
  end
58
50
  end
59
51
  end
@@ -92,17 +84,39 @@ module RSpec
92
84
  Expectations::ExpectationTarget.for(value, block)
93
85
  end
94
86
 
87
+ # Mock any instance of is an XUnit alternative to the
88
+ # `expect_any_instance_of` based mocking syntax.
89
+ #
90
+ # `mock_any_instance_of(Post).to receive(:comments)`
91
+ def mock_any_instance_of(klass)
92
+ RSpec::Mocks::AnyInstanceExpectationTarget.new(klass)
93
+ end
94
+
95
95
  # Stub is an XUnit alternative to the `allow` based mocking syntax.
96
96
  def stub(target)
97
97
  RSpec::Mocks::AllowanceTarget.new(target)
98
98
  end
99
99
 
100
+ # Stub any instance of is an XUnit alternative to the `allow` based
101
+ # mocking syntax.
102
+ def stub_any_instance_of(klass)
103
+ RSpec::Mocks::AnyInstanceAllowanceTarget.new(klass)
104
+ end
105
+
100
106
  private
101
107
 
102
108
  ASSERTION_REGEX = /^assert_(.*)$/.freeze
103
109
  ASSERTION_PREDICATE_REGEX = /^assert_(.*)\?$/.freeze
110
+ ASSERTION_NEGATIVE_PREDICATE_REGEX = /^assert_not_(.*)\?$/.freeze
104
111
 
105
112
  def method_missing(method, *args, &block)
113
+ return if ASSERTION_NEGATIVE_PREDICATE_REGEX.match(method.to_s) do |match|
114
+ value = args.shift
115
+ matcher = "be_#{match[1]}"
116
+
117
+ expect(value).to_not Matchers::BuiltIn::BePredicate.new(matcher, *args, &block)
118
+ end
119
+
106
120
  return if ASSERTION_PREDICATE_REGEX.match(method.to_s) do |match|
107
121
  value = args.shift
108
122
  matcher = "be_#{match[1]}"
@@ -2,11 +2,11 @@
2
2
 
3
3
  RSpec::Core::ExampleGroup.define_example_group_method :case
4
4
  RSpec::Core::ExampleGroup.define_example_group_method :fcase, focus: true
5
- RSpec::Core::ExampleGroup.define_example_group_method :xcase, skip: 'Temporarily skipped with xcase'
5
+ RSpec::Core::ExampleGroup.define_example_group_method :xcase, skip: "Temporarily skipped with xcase"
6
6
 
7
7
  RSpec::Core::ExampleGroup.define_example_method :test
8
8
  RSpec::Core::ExampleGroup.define_example_method :ftest, focus: true
9
- RSpec::Core::ExampleGroup.define_example_method :xtest, skip: 'Temporarily skipped with xtest'
9
+ RSpec::Core::ExampleGroup.define_example_method :xtest, skip: "Temporarily skipped with xtest"
10
10
 
11
11
  RSpec::Core::Hooks.module_eval do
12
12
  alias_method :setup, :before
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module XUnit
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
data/rspec-xunit.gemspec CHANGED
@@ -1,29 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'rspec/xunit/version'
5
+ require "rspec/xunit/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'rspec-xunit'
9
- spec.version = RSpec::XUnit::VERSION
10
- spec.authors = ['Genadi Samokovarov']
11
- spec.email = ['gsamokovarov@gmail.com']
12
- spec.summary = 'XUnit syntax for RSpec'
13
- spec.description = 'XUnit syntax for RSpec'
14
- spec.homepage = 'https://github.com/gsamokovarov/rspec-xunit'
15
- spec.license = 'MIT'
8
+ spec.name = "rspec-xunit"
9
+ spec.version = RSpec::XUnit::VERSION
10
+ spec.authors = ["Genadi Samokovarov"]
11
+ spec.email = ["gsamokovarov@gmail.com"]
12
+ spec.summary = "XUnit syntax for RSpec"
13
+ spec.description = "XUnit syntax for RSpec"
14
+ spec.homepage = "https://github.com/gsamokovarov/rspec-xunit"
15
+ spec.license = "MIT"
16
16
 
17
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
18
18
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
19
  end
20
- spec.bindir = 'exe'
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ['lib']
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
23
 
24
- spec.add_dependency 'rspec-core', '>= 3.0'
25
- spec.add_dependency 'rspec-expectations', '>= 3.0'
24
+ spec.add_dependency "rspec-core", ">= 3.0"
25
+ spec.add_dependency "rspec-expectations", ">= 3.0"
26
26
 
27
- spec.add_development_dependency 'bundler', '~> 2.0'
28
- spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency "bundler", "~> 2.0"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-xunit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genadi Samokovarov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-08 00:00:00.000000000 Z
11
+ date: 2020-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core