spec/draper/base_spec.rb in draper-0.17.0 vs spec/draper/base_spec.rb in draper-0.18.0
- old
+ new
@@ -374,10 +374,19 @@
subject.context = :admin
subject.each { |decorated| decorated.context.should == :admin }
end
end
+ context "when given a struct" do
+ # Struct objects implement #each
+ let(:source) { Struct.new(:title).new("Godzilla") }
+
+ it "returns a wrapped object" do
+ subject.should be_instance_of(Draper::Base)
+ end
+ end
+
context "when given a collection of sequel models" do
# Sequel models implement #each
let(:source) { [SequelProduct.new, SequelProduct.new] }
it "returns a collection of wrapped objects" do
@@ -792,11 +801,12 @@
decorator.sample_truncate.should == "Once..."
end
it "is able to use l rather than helpers.l" do
now = Time.now
- decorator.helpers.instance_variable_get(:@helpers).should_receive(:localize).with(now)
- decorator.l now
+ helper_proxy = decorator.helpers.instance_variable_get(:@helpers)
+ helper_proxy.should_receive(:localize).with(now, :format => :long)
+ decorator.l now, :format => :long
end
it "is able to access html_escape, a private method" do
decorator.sample_html_escaped_text.should == '<script>danger</script>'
end