Sha256: d480dbb8d7e4eec1702fd3f90985ad2a36e9e4aa1d190b6af928f3c25d04dd3e
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
require 'representable' require 'representable/json' require 'representable/xml' require 'minitest/autorun' require 'test_xml/mini_test' require 'mocha/setup' class Album attr_accessor :songs, :best_song def initialize(songs=nil, best_song=nil) @songs = songs @best_song = best_song end def ==(other) songs == other.songs and best_song == other.best_song end end class Song attr_accessor :name, :track def initialize(name=nil, track=nil) @name = name @track = track end def ==(other) name == other.name and track == other.track end end module XmlHelper def xml(document) Nokogiri::XML(document).root end end module AssertJson module Assertions def assert_json(expected, actual, msg=nil) msg = message(msg, "") { diff expected, actual } assert(expected.split("").sort == actual.split("").sort, msg) end end end MiniTest::Spec.class_eval do include AssertJson::Assertions include XmlHelper def self.representer!(format=Representable::Hash, name=:representer, &block) let(name) do Module.new do include format instance_exec(&block) end end end module TestMethods def representer_for(modules=[Representable::Hash], &block) Module.new do extend TestMethods include *modules module_exec(&block) end end end include TestMethods end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
representable-1.5.3 | test/test_helper.rb |
representable-1.5.2 | test/test_helper.rb |
representable-1.5.1 | test/test_helper.rb |