Skip to content

Commit a76cdd4

Browse files
authored
fix(hooks): changed context to ScenarioContext for BEFORE/AFTER_STEP hook (#175)
fix: correct spelling of ScopedFeatureContext in ContextManager and related files
1 parent b0a312c commit a76cdd4

File tree

6 files changed

+21
-25
lines changed

6 files changed

+21
-25
lines changed

cucumber_cpp/library/engine/ContextManager.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ namespace cucumber_cpp::library::engine
7777
{
7878
}
7979

80-
ContextManager::ScopedFeautureContext::ScopedFeautureContext(ContextManager& contextManager)
80+
ContextManager::ScopedFeatureContext::ScopedFeatureContext(ContextManager& contextManager)
8181
: contextManager{ contextManager }
8282
{}
8383

84-
ContextManager::ScopedFeautureContext ::~ScopedFeautureContext()
84+
ContextManager::ScopedFeatureContext::~ScopedFeatureContext()
8585
{
8686
contextManager.DisposeFeatureContext();
8787
}
@@ -90,7 +90,7 @@ namespace cucumber_cpp::library::engine
9090
: contextManager{ contextManager }
9191
{}
9292

93-
ContextManager::ScopedRuleContext ::~ScopedRuleContext()
93+
ContextManager::ScopedRuleContext::~ScopedRuleContext()
9494
{
9595
contextManager.DisposeRuleContext();
9696
}
@@ -99,7 +99,7 @@ namespace cucumber_cpp::library::engine
9999
: contextManager{ contextManager }
100100
{}
101101

102-
ContextManager::ScopedScenarioContext ::~ScopedScenarioContext()
102+
ContextManager::ScopedScenarioContext::~ScopedScenarioContext()
103103
{
104104
contextManager.DisposeScenarioContext();
105105
}
@@ -129,12 +129,12 @@ namespace cucumber_cpp::library::engine
129129
return *programContext;
130130
}
131131

132-
ContextManager::ScopedFeautureContext ContextManager::CreateFeatureContext(const FeatureInfo& featureInfo)
132+
ContextManager::ScopedFeatureContext ContextManager::CreateFeatureContext(const FeatureInfo& featureInfo)
133133
{
134134
featureContext = std::make_shared<decltype(featureContext)::element_type>(*programContext, featureInfo);
135135
runnerContext.push(featureContext);
136136

137-
return ScopedFeautureContext{ *this };
137+
return ScopedFeatureContext{ *this };
138138
}
139139

140140
void ContextManager::DisposeFeatureContext()

cucumber_cpp/library/engine/ContextManager.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ namespace cucumber_cpp::library::engine
7474
cucumber_cpp::library::engine::ProgramContext& ProgramContext();
7575
[[nodiscard]] cucumber_cpp::library::engine::ProgramContext& ProgramContext() const;
7676

77-
struct ScopedFeautureContext;
77+
struct ScopedFeatureContext;
7878
struct ScopedRuleContext;
7979
struct ScopedScenarioContext;
8080
struct ScopedStepContext;
8181

82-
[[nodiscard]] ScopedFeautureContext CreateFeatureContext(const FeatureInfo& featureInfo);
82+
[[nodiscard]] ScopedFeatureContext CreateFeatureContext(const FeatureInfo& featureInfo);
8383
cucumber_cpp::library::engine::FeatureContext& FeatureContext();
8484

8585
[[nodiscard]] ScopedRuleContext CreateRuleContext(const RuleInfo& ruleInfo);
@@ -109,10 +109,10 @@ namespace cucumber_cpp::library::engine
109109
std::stack<std::shared_ptr<cucumber_cpp::library::engine::StepContext>> stepContext;
110110
};
111111

112-
struct ContextManager::ScopedFeautureContext : library::util::Immoveable
112+
struct ContextManager::ScopedFeatureContext : library::util::Immoveable
113113
{
114-
explicit ScopedFeautureContext(ContextManager& contextManager);
115-
~ScopedFeautureContext();
114+
explicit ScopedFeatureContext(ContextManager& contextManager);
115+
~ScopedFeatureContext();
116116

117117
private:
118118
ContextManager& contextManager;

cucumber_cpp/library/engine/HookExecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace cucumber_cpp::library::engine
6464
{}
6565

6666
HookExecutor::StepScope::StepScope(cucumber_cpp::library::engine::ContextManager& contextManager)
67-
: ScopedHook{ contextManager.StepContext(), stepHooks, contextManager.ScenarioContext().info.Tags() }
67+
: ScopedHook{ contextManager.ScenarioContext(), stepHooks, contextManager.ScenarioContext().info.Tags() }
6868
{}
6969

7070
HookExecutorImpl::HookExecutorImpl(cucumber_cpp::library::engine::ContextManager& contextManager)

cucumber_cpp/library/engine/TestExecution.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace cucumber_cpp::library::engine
5151
FeatureScope(cucumber_cpp::library::engine::ContextManager& contextManager, report::ReportForwarder& reportHandler, HookExecutor& hookExecution, const cucumber_cpp::library::engine::FeatureInfo& featureInfo);
5252

5353
private:
54-
cucumber_cpp::library::engine::ContextManager::ScopedFeautureContext scopedFeatureContext;
54+
cucumber_cpp::library::engine::ContextManager::ScopedFeatureContext scopedFeatureContext;
5555
report::ReportForwarder::FeatureScope scopedFeatureReport;
5656
HookExecutor::FeatureScope scopedFeatureHook;
5757
};

cucumber_cpp/library/engine/test/TestHookExecutor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ namespace cucumber_cpp::library::engine
5252

5353
TEST_F(TestHookExecutor, ExecuteBeforeStep)
5454
{
55-
ASSERT_FALSE(contextManagerInstance.StepContext().Contains("hookBeforeStep"));
56-
ASSERT_FALSE(contextManagerInstance.StepContext().Contains("hookAfterStep"));
55+
ASSERT_FALSE(contextManagerInstance.ScenarioContext().Contains("hookBeforeStep"));
56+
ASSERT_FALSE(contextManagerInstance.ScenarioContext().Contains("hookAfterStep"));
5757

5858
{
5959
auto scope = hookExecutor.StepStart();
60-
EXPECT_TRUE(contextManagerInstance.StepContext().Contains("hookBeforeStep"));
60+
EXPECT_TRUE(contextManagerInstance.ScenarioContext().Contains("hookBeforeStep"));
6161
}
62-
EXPECT_TRUE(contextManagerInstance.StepContext().Contains("hookAfterStep"));
62+
EXPECT_TRUE(contextManagerInstance.ScenarioContext().Contains("hookAfterStep"));
6363
}
6464
}

cucumber_cpp/library/engine/test_helper/ContextManagerInstance.hpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ namespace cucumber_cpp::library::engine::test_helper
2222
{
2323
ContextManagerInstance()
2424
: cucumber_cpp::library::engine::ContextManager{ contextStorageFactory }
25-
, featureContextScope{ CreateFeatureContext(feature) }
26-
, ruleContextScope{ CreateRuleContext(rule) }
27-
, scenarioContextScope{ CreateScenarioContext(scenario) }
28-
, stepContextScope{ CreateStepContext(step) }
2925
{
3026
}
3127

@@ -35,10 +31,10 @@ namespace cucumber_cpp::library::engine::test_helper
3531
cucumber_cpp::library::engine::ScenarioInfo scenario{ rule, {}, {}, {}, {}, {} };
3632
cucumber_cpp::library::engine::StepInfo step{ scenario, {}, {}, {}, {}, {} };
3733

38-
ContextManager::ScopedFeautureContext featureContextScope;
39-
ContextManager::ScopedRuleContext ruleContextScope;
40-
ContextManager::ScopedScenarioContext scenarioContextScope;
41-
ContextManager::ScopedStepContext stepContextScope;
34+
ContextManager::ScopedFeatureContext featureContextScope{ CreateFeatureContext(feature) };
35+
ContextManager::ScopedRuleContext ruleContextScope{ CreateRuleContext(rule) };
36+
ContextManager::ScopedScenarioContext scenarioContextScope{ CreateScenarioContext(scenario) };
37+
ContextManager::ScopedStepContext stepContextScope{ CreateStepContext(step) };
4238
};
4339
}
4440

0 commit comments

Comments
 (0)