Sha256: 37c1d2312fe56b20f9ad216a2b5eb9f1dea38e149b185d4e27932dc14ba2b4e5
Contents?: true
Size: 876 Bytes
Versions: 3
Compression:
Stored size: 876 Bytes
Contents
Given(/^JSON data defined as:$/) do |code| json = nil context_module.module_eval code context_data[:json] = json end When(/^the JSON is parsed to a model instance as:$/) do |code| json = context_data[:json] instance = nil context_module.module_eval code context_data[:instance] = instance end Then(/^the instance attributes are as follows:$/) do |table| row_pairs = table.raw.each_slice(2) attribute_exprs = row_pairs.map( &:first ).reduce( :+ ) expected_exprs = row_pairs.map( &:last ).reduce( :+ ) instance = context_data[:instance] actuals = attribute_exprs .map{ |expr| eval( "instance.#{expr}" ) } expecteds = expected_exprs .map{ |expr| eval( expr ) } actual_hash = Hash[ attribute_exprs.zip( actuals ) ] expected_hash = Hash[ attribute_exprs.zip( expecteds ) ] expect( actual_hash ).to eq( expected_hash ) end
Version data entries
3 entries across 3 versions & 1 rubygems