Permalink
Browse files

Adding specs for views, testing without Rails.

Just test trough ERB see if variables are rendered.
  • Loading branch information...
1 parent 6140c7c commit 60b981342c66b1f9f16a2682ed2eb36b99a6aed7 Bèr Kessels committed Dec 11, 2012
View
20 spec/views/piwik_tracking_tag.html.erb_spec.rb
@@ -0,0 +1,20 @@
+require "erb"
+
+describe "views/piwik_tracking_tag.html.erb" do
+ before(:each) do
+ filename = File.join(File.dirname(__FILE__), '..', '..', 'app', 'views', 'piwik_analytics', 'piwik_tracking_tag.html.erb')
+ @template = ERB.new(File.read(filename))
+ end
+
+ it "should render url" do
+ url = "example.com"
+ id_site = nil
+ @template.result(binding).should =~ /http:\/\/example.com/
+ end
+
+ it "should render id_site" do
+ url = nil
+ id_site = 4
+ @template.result(binding).should =~ /"piwik\.php", 4/
+ end
+end
View
21 spec/views/piwik_tracking_tag_async.html.erb_spec.rb
@@ -0,0 +1,21 @@
+require "erb"
+
+describe "views/piwik_tracking_tag_async.html.erb" do
+ before(:each) do
+ filename = File.join(File.dirname(__FILE__), '..', '..', 'app', 'views', 'piwik_analytics', 'piwik_tracking_tag_async.html.erb')
+ @template = ERB.new(File.read(filename))
+ end
+
+ it "should render url" do
+ url = "example.com"
+ id_site = nil
+ @template.result(binding).should =~ /http:\/\/example.com/
+ end
+
+ it "should render id_site" do
+ url = nil
+ id_site = 4
+ @template.result(binding).should =~ /'setSiteId', 4/
+ end
+end
+

0 comments on commit 60b9813

Please sign in to comment.