mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Remove new
from reserved keywords
This effectively allows stubs to be placed on the `new` method for types. A strange issue arose when the keyword was allowed. The compiler failed to resolve the Stub type from the Double initializer. The error trace goes through null_double_spec.cr. Running just that spec file confirms the issue is there, but running other individual files doesn't produce the error. As a workaround, I've put the full path of Stub in the initializer.
This commit is contained in:
parent
fe88eefa86
commit
2e5f822e1d
3 changed files with 4 additions and 7 deletions
|
@ -21,12 +21,9 @@ Spectator.describe "GitHub Issue #32" do
|
||||||
let(test_instance) { test_class.new }
|
let(test_instance) { test_class.new }
|
||||||
|
|
||||||
describe "something else" do
|
describe "something else" do
|
||||||
# mock TestFoo::TestClass do
|
inject_mock TestFoo::TestClass
|
||||||
# stub self.new
|
|
||||||
# stub test
|
|
||||||
# end
|
|
||||||
|
|
||||||
xit "must test when new is called", pending: "Mock redesign" do
|
it "must test when new is called" do
|
||||||
expect(test_class).to receive(:new).with(no_args).and_return(test_instance)
|
expect(test_class).to receive(:new).with(no_args).and_return(test_instance)
|
||||||
expect(test_instance).to receive(:test)
|
expect(test_instance).to receive(:test)
|
||||||
expect(test_class.new).to be(test_instance)
|
expect(test_class.new).to be(test_instance)
|
||||||
|
|
|
@ -2,6 +2,6 @@ module Spectator
|
||||||
module DSL
|
module DSL
|
||||||
# Keywords that cannot be used in specs using the DSL.
|
# Keywords that cannot be used in specs using the DSL.
|
||||||
# These are either problematic or reserved for internal use.
|
# These are either problematic or reserved for internal use.
|
||||||
RESERVED_KEYWORDS = %i[initialize finalize class new allocate]
|
RESERVED_KEYWORDS = %i[initialize finalize class allocate]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,7 +74,7 @@ module Spectator
|
||||||
# Creates the double.
|
# Creates the double.
|
||||||
#
|
#
|
||||||
# An initial set of *stubs* can be provided.
|
# An initial set of *stubs* can be provided.
|
||||||
def initialize(@stubs : Array(Stub) = [] of Stub)
|
def initialize(@stubs : Array(::Spectator::Stub) = [] of ::Spectator::Stub)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates the double.
|
# Creates the double.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue