-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with event bindings methodizing, Closes #273
- Loading branch information
Showing
2 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require 'spec_helper' | ||
|
||
describe Volt::ViewScope do | ||
describe "methodize strings" do | ||
def methodize(str) | ||
Volt::ViewScope.methodize_string(str) | ||
end | ||
|
||
it 'should methodize a method without args' do | ||
code = methodize('something') | ||
expect(code).to eq('method(:something)') | ||
end | ||
|
||
it 'should methodize a method without args2' do | ||
code = methodize('something?') | ||
expect(code).to eq('method(:something?)') | ||
end | ||
|
||
it 'should methodize a method wit args1' do | ||
code = methodize('set_something(true)') | ||
expect(code).to eq('set_something(true)') | ||
end | ||
|
||
it 'should not methodize a method call with args' do | ||
code = methodize('something(item1, item2)') | ||
expect(code).to eq('something(item1, item2)') | ||
end | ||
|
||
it 'should not methodize on assignment' do | ||
code = methodize('params._something = 5') | ||
expect(code).to eq('params._something = 5') | ||
end | ||
|
||
it 'should not methodize on hash lookup' do | ||
code = methodize('hash[:something]') | ||
expect(code).to eq('hash[:something]') | ||
end | ||
|
||
it 'should not methodize on instance variables' do | ||
code = methodize('@something.call') | ||
expect(code).to eq('@something.call') | ||
end | ||
end | ||
end |