spec/synvert/node_ext_spec.rb in synvert-0.0.2 vs spec/synvert/node_ext_spec.rb in synvert-0.0.3
- old
+ new
@@ -33,19 +33,38 @@
it 'gets for block node' do
node = parse('RSpec.configure do |config|; end')
expect(node.arguments.map(&:to_s)).to eq ['config']
end
+
+ it 'gets for defined? node' do
+ node = parse('defined?(Bundler)')
+ expect(node.arguments).to eq [parse('Bundler')]
+ end
end
describe '#caller' do
it 'gets for block node' do
node = parse('RSpec.configure do |config|; end')
expect(node.caller).to eq parse('RSpec.configure')
end
end
+ describe '#body' do
+ it 'gets for block node' do
+ node = parse('RSpec.configure do |config|; include EmailSpec::Helpers; end')
+ expect(node.body).to eq parse('include EmailSpec::Helpers')
+ end
+ end
+
+ describe "#condition" do
+ it 'gets for if node' do
+ node = parse('if defined?(Bundler); end')
+ expect(node.condition).to eq parse('defined?(Bundler)')
+ end
+ end
+
describe '#to_s' do
it 'gets for const node' do
node = parse('Synvert')
expect(node.to_s).to eq 'Synvert'
@@ -58,11 +77,11 @@
expect(node.to_s).to eq ':synvert'
end
it 'gets for str node' do
node = parse("'synvert'")
- expect(node.to_s).to eq 'synvert'
+ expect(node.to_s).to eq "'synvert'"
end
it 'gets for lvar node' do
node = parse("user = User.find 1; user.valid?").grep_node(type: 'lvar')
expect(node.to_s).to eq 'user'
@@ -74,9 +93,19 @@
end
it 'gets for arg node' do
node = parse("RSpec.configure do |config|; end").grep_node(type: 'arg')
expect(node.to_s).to eq 'config'
+ end
+
+ it 'gets for self node' do
+ node = parse('self')
+ expect(node.to_s).to eq 'self'
+ end
+
+ it 'gets for send node' do
+ node = parse('email')
+ expect(node.to_s).to eq 'email'
end
end
describe '#indent' do
it 'gets column number' do