From e10df661b8f0b3d424b89154388a9849b20c92f1 Mon Sep 17 00:00:00 2001 From: Yomi Colledge Date: Wed, 21 Apr 2010 11:20:57 +0100 Subject: [PATCH] Added partial spec, where we'll centralise our legend view specs. --- spec/views/features/_legend.html.erb_spec.rb | 47 ++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 spec/views/features/_legend.html.erb_spec.rb diff --git a/spec/views/features/_legend.html.erb_spec.rb b/spec/views/features/_legend.html.erb_spec.rb new file mode 100644 index 00000000..45d10d0f --- /dev/null +++ b/spec/views/features/_legend.html.erb_spec.rb @@ -0,0 +1,47 @@ +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') + +describe "/features/_legend.html.erb" do + context "display for file changes" do + before(:each) do + render :locals => {:diff_for => "file"} + end + + it "should have a legend displaying system changes as green" do + response.should have_selector :div, attribute = {:id => "legend"} do |legend_wrapper| + legend_wrapper.should have_selector :span, attribute = {:class => "gd"} do |content| + content.should contain "Removing from file" + end + end + end + + it "should have a legend displaying file changes as red" do + response.should have_selector :div, attribute = {:id => "legend"} do |legend_wrapper| + legend_wrapper.should have_selector :span, attribute = {:class => "gi"} do |content| + content.should contain "Adding to file" + end + end + end + end + + context "display for system changes" do + before(:each) do + render :locals => {:diff_for => "system"} + end + + it "should have a legend displaying system changes as green" do + response.should have_selector :div, attribute = {:id => "legend"} do |legend_wrapper| + legend_wrapper.should have_selector :span, attribute = {:class => "gi"} do |content| + content.should contain "Adding to system" + end + end + end + + it "should have a legend displaying file changes as red" do + response.should have_selector :div, attribute = {:id => "legend"} do |legend_wrapper| + legend_wrapper.should have_selector :span, attribute = {:class => "gd"} do |content| + content.should contain "Removing from system" + end + end + end + end +end \ No newline at end of file