Commit d17899012dbb54916c5462a969bc0caa7bdaad12

Authored by Vasiliy Ermolovich
1 parent 60840259
Exists in master and in 1 other branch production

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 14 end
15 15  
16 16 describe "content_for :action_bar" do
  17 + def action_bar
  18 + view.content_for(:action_bar)
  19 + end
17 20  
18 21 it "should confirm the 'resolve' link by default" do
19 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 25 end
24 26  
25 27 it "should confirm the 'resolve' link if configuration is unset" do
26 28 Errbit::Config.stub(:confirm_resolve_err).and_return(nil)
27 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 32 end
32 33  
33 34 it "should not confirm the 'resolve' link if configured not to" do
34 35 Errbit::Config.stub(:confirm_resolve_err).and_return(false)
35 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 39 end
40 40  
41 41 it "should link 'up' to HTTP_REFERER if is set" do
42 42 url = 'http://localhost:3000/errs'
43 43 controller.request.env['HTTP_REFERER'] = url
44 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 47 end
48 48  
49 49 it "should link 'up' to app_errs_path if HTTP_REFERER isn't set'" do
... ... @@ -52,8 +52,8 @@ describe &quot;errs/show.html.haml&quot; do
52 52 assign :problem, problem
53 53 assign :app, problem.app
54 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 57 end
58 58  
59 59 end
... ... @@ -68,9 +68,9 @@ describe &quot;errs/show.html.haml&quot; do
68 68 assign :problem, problem
69 69 assign :app, problem.app
70 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 74 end
75 75  
76 76 context "with issue tracker" do
... ... @@ -92,9 +92,9 @@ describe &quot;errs/show.html.haml&quot; do
92 92 problem.reload
93 93 with_issue_tracker(problem)
94 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 98 end
99 99 end
100 100 end
... ...