Sha256: 2eb7c5725336de595585f23f48a5ba0e8571ee65ba0c693179c262ff15c468db

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

class MagicResource 
	extend NSConnector::Transforming 
	def initialize 
	end
	def self.type_id
		'magic'
	end
end

class MagicTarget 
	attr_reader :store
	extend NSConnector::Transforming
	def initialize 
		@store = {}
	end
	def field1=(v)
		@store[:field1] = v
	end
	class << self
		def type_id
			'target'
		end
		def fields
			[:field1]
		end
	end
end

describe NSConnector::Transforming do
	it 'transform! with no block works' do
		NSConnector::Restlet.should_receive(:execute!).with({
			:action => 'transform',
			:source_type_id => 'magic',
			:target_type_id => 'target',
			:source_id => 42,
			:data => {},
			:fields => [:field1]
		})

		MagicResource.transform!(MagicTarget, 42)
	end
	it 'transform! with no block works' do
		NSConnector::Restlet.should_receive(:execute!).with({
			:action => 'transform',
			:source_type_id => 'magic',
			:target_type_id => 'target',
			:source_id => 42,
			:data => {:field1 => 'value'},
			:fields => [:field1]
		})

		MagicResource.transform!(MagicTarget, 42) do |magic_target|
			magic_target.field1 = 'value'
		end
	end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ns_connector-0.1.0 spec/transforming_spec.rb
ns_connector-0.0.17 spec/transforming_spec.rb
ns_connector-0.0.16 spec/transforming_spec.rb
ns_connector-0.0.15 spec/transforming_spec.rb
ns_connector-0.0.14 spec/transforming_spec.rb
ns_connector-0.0.13 spec/transforming_spec.rb
ns_connector-0.0.12 spec/transforming_spec.rb
ns_connector-0.0.11 spec/transforming_spec.rb
ns_connector-0.0.10 spec/transforming_spec.rb
ns_connector-0.0.9 spec/transforming_spec.rb
ns_connector-0.0.8 spec/transforming_spec.rb
ns_connector-0.0.7 spec/transforming_spec.rb