spec/helpers/title_helper_spec.rb in title-0.0.4 vs spec/helpers/title_helper_spec.rb in title-0.0.5
- old
+ new
@@ -35,18 +35,27 @@
it 'can use view assigns' do
stub_rails
stub_controller_and_action(:users, :show)
load_translations(users: { show: '%{name}' })
- helper.stub_chain(:controller, :view_assigns, :symbolize_keys).and_return({ name: 'Caleb' })
+ helper.stub_chain(:controller, :view_assigns).and_return('name' => 'Caleb')
expect(helper.title).to eq('Caleb')
end
+ it 'can accept a hash of extra context in addition to the view assigns' do
+ stub_rails
+ stub_controller_and_action(:users, :show)
+ load_translations(users: { show: '%{greeting} %{name}' })
+ helper.stub_chain(:controller, :view_assigns).and_return('name' => 'Caleb')
+
+ expect(helper.title(greeting: 'Hello')).to eq('Hello Caleb')
+ end
+
def stub_rails
helper.stub(:controller_path).and_return('dashboards')
helper.stub(:action_name)
- helper.stub_chain(:controller, :view_assigns, :symbolize_keys).and_return({})
+ helper.stub_chain(:controller, :view_assigns).and_return({})
Rails.stub_chain(:application, :class).and_return('Dummy::Application')
end
def stub_controller_and_action(controller, action)
helper.stub(controller_path: controller.to_s, action_name: action.to_s)