show.html.haml_spec.rb
1.17 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
44
45
46
47
48
49
50
51
52
53
54
55
56
require 'spec_helper'
describe "apps/show.html.haml" do
let(:app) { stub_model(App) }
let(:user) { stub_model(User) }
let(:action_bar) do
view.content_for(:action_bar)
end
before do
view.stub(:app).and_return(app)
view.stub(:all_errs).and_return(false)
view.stub(:deploys).and_return([])
controller.stub(:current_user) { user }
end
describe "content_for :action_bar" do
it "should confirm the 'cancel' link" do
render
action_bar.should have_selector('a.button', :text => 'all errs')
end
end
context "without errs" do
it 'see no errs' do
render
rendered.should match(/No errs have been/)
end
end
context "with user watch application" do
before do
user.stub(:watching?).with(app).and_return(true)
end
it 'see the unwatch button' do
render
expect(action_bar).to include(I18n.t('apps.show.unwatch'))
end
end
context "with user not watch application" do
before do
user.stub(:watching?).with(app).and_return(false)
end
it 'not see the unwatch button' do
render
expect(action_bar).to_not include(I18n.t('apps.show.unwatch'))
end
end
end