Fix issue with implicit vs. explicit subject

Addresses the issue pointed out in !25

There was a recent change that set a subject to the first argument of 
`describe` and `context`. This prevented an explicitly defined subject 
from being accessible in nested groups.
This commit is contained in:
Michael Miller 2020-01-16 18:36:40 -07:00 committed by Arina Shmeleva
parent cf448576e2
commit f825a34771
2 changed files with 10 additions and 2 deletions

View file

@ -24,11 +24,11 @@ module Spectator
{{what}} {{what}}
end end
def subject(*args) def _spectator_implicit_subject(*args)
described_class.new(*args) described_class.new(*args)
end end
{% else %} {% else %}
def subject def _spectator_implicit_subject(*args)
{{what}} {{what}}
end end
{% end %} {% end %}

View file

@ -6,6 +6,14 @@ require "./spectator/dsl"
class SpectatorTest class SpectatorTest
include ::Spectator::DSL include ::Spectator::DSL
def _spectator_implicit_subject
nil
end
def subject
_spectator_implicit_subject
end
def initialize(@spectator_test_values : ::Spectator::TestValues) def initialize(@spectator_test_values : ::Spectator::TestValues)
end end
end end