application_helper_spec.rb
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'rails_helper'
describe ApplicationHelper, :type => :helper do
describe 't_hint' do
let(:class_key) { :compound_metric_configuration }
let(:attribute_key) { :script }
context 'without class_key' do
let!(:translation) { "translated test" }
before :each do
helper.expects(:t).with("activemodel.hints.#{helper.controller_name}.#{attribute_key}", {}).returns(translation)
end
it 'is expected to return the hint for the given attribute' do
expect(helper.t_hint(attribute_key)).to eq(translation)
end
end
context 'with class_key' do
it 'is expected to return the hint for the given attribute' do
expect(helper.t_hint(attribute_key, class_key)).to eq(I18n.t("activemodel.hints.#{class_key}.#{attribute_key}"))
end
end
end
describe 't_action' do
let!(:model) { mock "Model" }
let!(:model_name) { mock "Model Name" }
let(:action) { :edit }
before :each do
model.expects(:model_name).twice.returns(model_name)
model_name.expects(:i18n_key).returns(:model)
model_name.expects(:human).with(count: 1).returns("Model")
helper.expects(:t).with("helpers.submit.model.edit", {default: "helpers.submit.edit".to_sym, model: "Model"}).returns("Edit Model")
end
it "is expected to return the Model's edit action translation" do
expect(helper.t_action(action, model)).to eq("Edit Model")
end
end
end