Commit d17899012dbb54916c5462a969bc0caa7bdaad12
1 parent
60840259
Exists in
master
and in
1 other branch
refactor errs/show view spec
Showing
1 changed file
with
19 additions
and
19 deletions
Show diff stats
spec/views/errs/show.html.haml_spec.rb
@@ -14,36 +14,36 @@ describe "errs/show.html.haml" do | @@ -14,36 +14,36 @@ describe "errs/show.html.haml" do | ||
14 | end | 14 | end |
15 | 15 | ||
16 | describe "content_for :action_bar" do | 16 | describe "content_for :action_bar" do |
17 | + def action_bar | ||
18 | + view.content_for(:action_bar) | ||
19 | + end | ||
17 | 20 | ||
18 | it "should confirm the 'resolve' link by default" do | 21 | it "should confirm the 'resolve' link by default" do |
19 | render | 22 | render |
20 | - action_bar = String.new(view.view_flow.get(:action_bar)) | ||
21 | - resolve_link = action_bar.match(/(<a href.*?(class="resolve").*?>)/)[0] | ||
22 | - resolve_link.should =~ /data-confirm="Seriously\?"/ | 23 | + |
24 | + action_bar.should have_selector('a.resolve[data-confirm="Seriously?"]') | ||
23 | end | 25 | end |
24 | 26 | ||
25 | it "should confirm the 'resolve' link if configuration is unset" do | 27 | it "should confirm the 'resolve' link if configuration is unset" do |
26 | Errbit::Config.stub(:confirm_resolve_err).and_return(nil) | 28 | Errbit::Config.stub(:confirm_resolve_err).and_return(nil) |
27 | render | 29 | render |
28 | - action_bar = String.new(view.view_flow.get(:action_bar)) | ||
29 | - resolve_link = action_bar.match(/(<a href.*?(class="resolve").*?>)/)[0] | ||
30 | - resolve_link.should =~ /data-confirm="Seriously\?"/ | 30 | + |
31 | + action_bar.should have_selector('a.resolve[data-confirm="Seriously?"]') | ||
31 | end | 32 | end |
32 | 33 | ||
33 | it "should not confirm the 'resolve' link if configured not to" do | 34 | it "should not confirm the 'resolve' link if configured not to" do |
34 | Errbit::Config.stub(:confirm_resolve_err).and_return(false) | 35 | Errbit::Config.stub(:confirm_resolve_err).and_return(false) |
35 | render | 36 | render |
36 | - action_bar = String.new(view.view_flow.get(:action_bar)) | ||
37 | - resolve_link = action_bar.match(/(<a href.*?(class="resolve").*?>)/)[0] | ||
38 | - resolve_link.should_not =~ /data-confirm=/ | 37 | + |
38 | + action_bar.should_not have_selector('a.resolve[data-confirm]') | ||
39 | end | 39 | end |
40 | 40 | ||
41 | it "should link 'up' to HTTP_REFERER if is set" do | 41 | it "should link 'up' to HTTP_REFERER if is set" do |
42 | url = 'http://localhost:3000/errs' | 42 | url = 'http://localhost:3000/errs' |
43 | controller.request.env['HTTP_REFERER'] = url | 43 | controller.request.env['HTTP_REFERER'] = url |
44 | render | 44 | render |
45 | - action_bar = String.new(view.view_flow.get(:action_bar)) | ||
46 | - action_bar.should =~ /<span><a href=\"#{url}\" class=\"up\">up<\/a><\/span>/ | 45 | + |
46 | + action_bar.should have_selector("span a.up[href='#{url}']", :text => 'up') | ||
47 | end | 47 | end |
48 | 48 | ||
49 | it "should link 'up' to app_errs_path if HTTP_REFERER isn't set'" do | 49 | it "should link 'up' to app_errs_path if HTTP_REFERER isn't set'" do |
@@ -52,8 +52,8 @@ describe "errs/show.html.haml" do | @@ -52,8 +52,8 @@ describe "errs/show.html.haml" do | ||
52 | assign :problem, problem | 52 | assign :problem, problem |
53 | assign :app, problem.app | 53 | assign :app, problem.app |
54 | render | 54 | render |
55 | - action_bar = String.new(view.view_flow.get(:action_bar)) | ||
56 | - action_bar.should =~ /<span><a href=\"#{app_errs_path(problem.app)}\" class=\"up\">up<\/a><\/span>/ | 55 | + |
56 | + action_bar.should have_selector("span a.up[href='#{app_errs_path(problem.app)}']", :text => 'up') | ||
57 | end | 57 | end |
58 | 58 | ||
59 | end | 59 | end |
@@ -68,9 +68,9 @@ describe "errs/show.html.haml" do | @@ -68,9 +68,9 @@ describe "errs/show.html.haml" do | ||
68 | assign :problem, problem | 68 | assign :problem, problem |
69 | assign :app, problem.app | 69 | assign :app, problem.app |
70 | render | 70 | render |
71 | - comments_section = String.new(view.view_flow.get(:comments)) | ||
72 | - comments_section.should =~ /Test comment/ | ||
73 | - comments_section.should =~ /Add a comment/ | 71 | + |
72 | + view.content_for(:comments).should include('Test comment') | ||
73 | + view.content_for(:comments).should include('Add a comment') | ||
74 | end | 74 | end |
75 | 75 | ||
76 | context "with issue tracker" do | 76 | context "with issue tracker" do |
@@ -92,9 +92,9 @@ describe "errs/show.html.haml" do | @@ -92,9 +92,9 @@ describe "errs/show.html.haml" do | ||
92 | problem.reload | 92 | problem.reload |
93 | with_issue_tracker(problem) | 93 | with_issue_tracker(problem) |
94 | render | 94 | render |
95 | - comments_section = String.new(view.view_flow.get(:comments)) | ||
96 | - comments_section.should =~ /Test comment/ | ||
97 | - comments_section.should_not =~ /Add a comment/ | 95 | + |
96 | + view.content_for(:comments).should include('Test comment') | ||
97 | + view.content_for(:comments).should_not include('Add a comment') | ||
98 | end | 98 | end |
99 | end | 99 | end |
100 | end | 100 | end |