From ebd01ff27d3a4b2a57566632ce37873de4acf810 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 8 Jun 2017 14:37:44 +0200 Subject: TableBuilder spec: Stub a `params` global Since the `TableBuilder` depends on the controller's `params` hash (the link builder needs the controller, action, etc. in order to build a link), we need to stub `params` in order for the helper call to work in our test. Still not a fan of this implicit dependency, but we'll see. I might keep it in because maybe it makes more sense and would require less change to keep it the way it is. The link builder is highly dynamic and seems like it would be tricky to make non-dynamic. Needs more thought. Refs #3479 --- spec/helpers/table_builder_helper_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/helpers/table_builder_helper_spec.rb b/spec/helpers/table_builder_helper_spec.rb index e9d1afed3..085ed5a81 100644 --- a/spec/helpers/table_builder_helper_spec.rb +++ b/spec/helpers/table_builder_helper_spec.rb @@ -7,6 +7,12 @@ describe TableBuilderHelper, type: :helper do build_stubbed(:referential) ] + allow(helper).to receive(:params).and_return({ + :controller => 'workbenches', + :action => 'show', + :id => workbenches[0].workbench.id + }) + expected = <<-HTML -- cgit v1.2.3