Sha256: 32cbc011e30a0149bd8a03995790367af3757af352f62732d540d9ace031affc
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Discoverer::Reader do describe "#from" do context "para la clase Klass" do it "should instance the class Reader::Klass" do module Reader class Klass end end Reader::Klass.should_receive :new class Klass include Discoverer::Reader end obj = Klass.new obj.from end it "should pass the currect object as argument" do module Reader class Klass end end class ::Klass include Discoverer::Reader end obj = ::Klass.new Reader::Klass.should_receive( :new ).with obj obj.from end it "should return the same reader if its called twice" do module Reader class Klass end end class ::Klass include Discoverer::Reader end obj = ::Klass.new reader = double 'reader' Reader::Klass.should_receive( :new ).with( obj ).and_return reader obj.from.should === reader obj.from.should === reader end end context "for a subclass" do it "should simply work, provided the pattern is right" do module Reader class UserR end end class Model include Discoverer::Reader end class UserR < Model end obj = UserR.new Reader::UserR.should_receive( :new ).with obj obj.from end end context "there is a reader" do it 'should fail with a descriptive error' do class Ponele include Discoverer::Reader end obj = Ponele.new expect { obj.from }.to raise_error Discoverer::Reader::MissingReaderError, "The reader for Ponele (Reader::Ponele) wasn't found, please create it" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
discoverer-0.0.3 | spec/discoverer/reader_spec.rb |