From d17899012dbb54916c5462a969bc0caa7bdaad12 Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Fri, 1 Jun 2012 16:00:40 +0300 Subject: [PATCH] refactor errs/show view spec --- spec/views/errs/show.html.haml_spec.rb | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/spec/views/errs/show.html.haml_spec.rb b/spec/views/errs/show.html.haml_spec.rb index e66a4b7..0ffd99a 100644 --- a/spec/views/errs/show.html.haml_spec.rb +++ b/spec/views/errs/show.html.haml_spec.rb @@ -14,36 +14,36 @@ describe "errs/show.html.haml" do end describe "content_for :action_bar" do + def action_bar + view.content_for(:action_bar) + end it "should confirm the 'resolve' link by default" do render - action_bar = String.new(view.view_flow.get(:action_bar)) - resolve_link = action_bar.match(/()/)[0] - resolve_link.should =~ /data-confirm="Seriously\?"/ + + action_bar.should have_selector('a.resolve[data-confirm="Seriously?"]') end it "should confirm the 'resolve' link if configuration is unset" do Errbit::Config.stub(:confirm_resolve_err).and_return(nil) render - action_bar = String.new(view.view_flow.get(:action_bar)) - resolve_link = action_bar.match(/()/)[0] - resolve_link.should =~ /data-confirm="Seriously\?"/ + + action_bar.should have_selector('a.resolve[data-confirm="Seriously?"]') end it "should not confirm the 'resolve' link if configured not to" do Errbit::Config.stub(:confirm_resolve_err).and_return(false) render - action_bar = String.new(view.view_flow.get(:action_bar)) - resolve_link = action_bar.match(/()/)[0] - resolve_link.should_not =~ /data-confirm=/ + + action_bar.should_not have_selector('a.resolve[data-confirm]') end it "should link 'up' to HTTP_REFERER if is set" do url = 'http://localhost:3000/errs' controller.request.env['HTTP_REFERER'] = url render - action_bar = String.new(view.view_flow.get(:action_bar)) - action_bar.should =~ /up<\/a><\/span>/ + + action_bar.should have_selector("span a.up[href='#{url}']", :text => 'up') end 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 assign :problem, problem assign :app, problem.app render - action_bar = String.new(view.view_flow.get(:action_bar)) - action_bar.should =~ /up<\/a><\/span>/ + + action_bar.should have_selector("span a.up[href='#{app_errs_path(problem.app)}']", :text => 'up') end end @@ -68,9 +68,9 @@ describe "errs/show.html.haml" do assign :problem, problem assign :app, problem.app render - comments_section = String.new(view.view_flow.get(:comments)) - comments_section.should =~ /Test comment/ - comments_section.should =~ /Add a comment/ + + view.content_for(:comments).should include('Test comment') + view.content_for(:comments).should include('Add a comment') end context "with issue tracker" do @@ -92,9 +92,9 @@ describe "errs/show.html.haml" do problem.reload with_issue_tracker(problem) render - comments_section = String.new(view.view_flow.get(:comments)) - comments_section.should =~ /Test comment/ - comments_section.should_not =~ /Add a comment/ + + view.content_for(:comments).should include('Test comment') + view.content_for(:comments).should_not include('Add a comment') end end end -- libgit2 0.21.2