spec/macros4cuke/templating/engine_spec.rb in macros4cuke-0.2.18 vs spec/macros4cuke/templating/engine_spec.rb in macros4cuke-0.2.19
- old
+ new
@@ -2,10 +2,11 @@
# File: engine_spec.rb
require_relative '../../spec_helper'
require_relative '../../../lib/macros4cuke/templating/engine' # Load the class under test
+
module Macros4Cuke
module Templating # Open this namespace to get rid of module qualifier prefixes
@@ -169,13 +170,18 @@
it "should complain when a placeholder is empty or blank" do
text_w_empty_arg = sample_template.sub(/userid/, '')
error_message = %Q|An empty or blank argument occurred in 'And I fill in "Username" with "<>"'.|
lambda { Engine.new text_w_empty_arg }.should raise_error(Macros4Cuke::EmptyArgumentError, error_message)
+ end
+ it "should complain when a placeholder contains an invalid character" do
+ text_w_empty_arg = sample_template.sub(/userid/, 'user%id')
+ error_message = "The invalid sign '%' occurs in the argument/tag 'user%id'."
+ lambda { Engine.new text_w_empty_arg }.should raise_error(Macros4Cuke::InvalidCharError, error_message)
end
- end
+ end # context
context "Provided services" do
it "should know the variable(s) it contains" do
# Case using the sample template
@@ -206,11 +212,11 @@
And I fill in "Password" with ""
And I click "Sign in"
SNIPPET
rendered_text.should == expected
-
+
# Case of an actual that's not a String
locals = {'userid' => "johndoe", "password" => 12345678 }
rendered_text = subject.render(Object.new, locals)
expected = <<-SNIPPET
Given I landed in the homepage
@@ -218,13 +224,13 @@
And I fill in "Username" with "johndoe"
And I fill in "Password" with "12345678"
And I click "Sign in"
SNIPPET
- rendered_text.should == expected
-
+ rendered_text.should == expected
+
# Place actual value in context object
Context = Struct.new(:userid, :password)
context = Context.new("sherlock", "holmes")
rendered_text = subject.render(context, {'userid' => 'susan'})
expected = <<-SNIPPET
@@ -234,10 +240,10 @@
And I fill in "Password" with "holmes"
And I click "Sign in"
SNIPPET
rendered_text.should == expected
-
+
# Case of an empty source template text
instance = Engine.new ''
instance.render(nil, {}).should be_empty
end
\ No newline at end of file