Files
mozo-backend/spec/helpers/application_helper_spec.rb
T
2014-07-14 14:51:39 +02:00

37 lines
1.1 KiB
Ruby

require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the ApplicationHelper. For example:
#
# describe ApplicationHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe ApplicationHelper, type: :helper do
subject{ helper }
describe "onload_javascript" do
it "should add a normal string when given" do
subject.onload_javascript "alert('hi')"
subject.onload_javascript.should == "alert('hi')"
end
it "should concatenate separate statements correctly" do
subject.onload_javascript "alert('hi')"
subject.onload_javascript "alert('ho')"
subject.onload_javascript.should == "alert('hi');alert('ho')"
end
it "should accept a block as argument" do
subject.onload_javascript do
"alert('hi')"
end
subject.onload_javascript.should == "alert('hi')"
end
it "should accept a lambda as argument" do
subject.onload_javascript ->{ "alert('hi')" }
subject.onload_javascript.should == "alert('hi')"
end
end
end