Class: ViewSpec::ExecutableString

Inherits:
Object
  • Object
show all
Defined in:
lib/view_spec/executable_string.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, lang = nil) ⇒ ExecutableString

Returns a new instance of ExecutableString.



5
6
7
8
9
# File 'lib/view_spec/executable_string.rb', line 5

def initialize(str, lang = nil)
  @str = str
  @executable = lambda { render inline: str, type: lang || :erb }
  @lang = lang
end

Instance Attribute Details

#langObject (readonly)

Returns the value of attribute lang.



3
4
5
# File 'lib/view_spec/executable_string.rb', line 3

def lang
  @lang
end

Instance Method Details

#rawObject



19
20
21
# File 'lib/view_spec/executable_string.rb', line 19

def raw
  @str
end

#sourceObject



11
12
13
# File 'lib/view_spec/executable_string.rb', line 11

def source
  CGI.unescapeHTML @str.strip_heredoc.strip
end

#to_procObject



15
16
17
# File 'lib/view_spec/executable_string.rb', line 15

def to_proc
  @executable
end