Skip to content

Commit

Permalink
Fix rspec deprecations
Browse files Browse the repository at this point in the history
Thanks, @samphippen.
  • Loading branch information
calebhearth committed Apr 29, 2016
1 parent 28996b9 commit 52c24d5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions spec/helpers/title_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
stub_rails
stub_controller_and_action(:users, :show)
load_translations(users: { show: '%{name}' })
helper.stub_chain(:controller, :view_assigns).and_return('name' => 'Caleb')
allow(helper).to receive_message_chain(:controller, :view_assigns).and_return('name' => 'Caleb')

expect(helper.title).to eq('Caleb')
end
Expand All @@ -46,20 +46,21 @@
stub_rails
stub_controller_and_action(:users, :show)
load_translations(users: { show: '%{greeting} %{name}' })
helper.stub_chain(:controller, :view_assigns).and_return('name' => 'Caleb')
allow(helper).to receive_message_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).and_return({})
Rails.stub_chain(:application, :class).and_return('Dummy::Application')
allow(helper).to receive(:controller_path).and_return('dashboards')
allow(helper).to receive(:action_name)
allow(helper).to receive_message_chain(:controller, :view_assigns).and_return({})
allow(Rails).to receive_message_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)
allow(helper).to receive(:controller_path).and_return(controller.to_s)
allow(helper).to receive(:action_name).and_return(action.to_s)
end

def helper
Expand Down

0 comments on commit 52c24d5

Please sign in to comment.