Skip to content

Commit

Permalink
Fix issue with RSPEC_NAMESPACE conflicts with other gems
Browse files Browse the repository at this point in the history
  • Loading branch information
splittingred committed Feb 13, 2019
1 parent 64a3416 commit a45783b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ Changelog for the gruf-rspec gem.

### Pending release

### 0.1.2

* Fix issue with RSPEC_NAMESPACE conflicts with other gems

### 0.1.1

* Add be_a_successful_rpc matcher that matches on success and the appropriate response class
Expand Down
14 changes: 7 additions & 7 deletions lib/gruf/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
begin
require 'rspec/core'
require 'rspec/expectations'
RSPEC_NAMESPACE = RSpec
RSPEC_RUNNER = RSpec
GRUF_RSPEC_NAMESPACE = RSpec
GRUF_RSPEC_RUNNER = RSpec
rescue LoadError # old rspec compat
require 'spec'
RSPEC_NAMESPACE = Spec
RSPEC_RUNNER = Spec::Runner
GRUF_RSPEC_NAMESPACE = Spec
GRUF_RSPEC_RUNNER = Spec::Runner
end

require_relative 'rspec/version'
Expand All @@ -37,7 +37,7 @@ module Rspec

Gruf::Rspec.reset # initial reset

RSPEC_RUNNER.configure do |config|
GRUF_RSPEC_RUNNER.configure do |config|
config.include Gruf::Rspec::Helpers

config.define_derived_metadata(file_path: Regexp.new(Gruf::Rspec.rpc_spec_path)) do |metadata|
Expand Down Expand Up @@ -68,7 +68,7 @@ module Rspec
end
end

RSPEC_NAMESPACE::Matchers.define :raise_rpc_error do |expected_error_class|
GRUF_RSPEC_NAMESPACE::Matchers.define :raise_rpc_error do |expected_error_class|
supports_block_expectations

def with_serialized(&block)
Expand All @@ -90,7 +90,7 @@ def with_serialized(&block)
end
end

RSPEC_NAMESPACE::Matchers.define :be_a_successful_rpc do |_|
GRUF_RSPEC_NAMESPACE::Matchers.define :be_a_successful_rpc do |_|
match do |actual|
if !gruf_controller || actual.is_a?(GRPC::BadStatus) || actual.is_a?(GRPC::Core::CallError)
false
Expand Down
2 changes: 1 addition & 1 deletion lib/gruf/rspec/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
#
module Gruf
module Rspec
VERSION = '0.1.1'.freeze
VERSION = '0.1.2'.freeze
end
end

0 comments on commit a45783b

Please sign in to comment.