cleaned up the spec
This commit is contained in:
parent
c12592a1de
commit
12bf16f051
|
@ -1,4 +1,3 @@
|
|||
require 'pry'
|
||||
module Draper
|
||||
module ViewContext
|
||||
def self.current
|
||||
|
|
|
@ -1,57 +1,45 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Draper::DecoratedEnumerableProxy do
|
||||
describe "View context" do
|
||||
before(:each){ ApplicationController.new.view_context }
|
||||
subject{ ProductsDecorator.new(source, ProductDecorator) }
|
||||
let(:source){ Product.new }
|
||||
let(:non_active_model_source){ NonActiveModelProduct.new }
|
||||
before(:each){ ApplicationController.new.view_context }
|
||||
subject{ ProductsDecorator.new(source, ProductDecorator) }
|
||||
let(:source){ Product.new }
|
||||
let(:non_active_model_source){ NonActiveModelProduct.new }
|
||||
|
||||
context(".helpers") do
|
||||
it "have a valid view_context" do
|
||||
subject.helpers.should be
|
||||
end
|
||||
|
||||
it "is aliased to .h" do
|
||||
subject.h.should == subject.helpers
|
||||
end
|
||||
context(".helpers") do
|
||||
it "have a valid view_context" do
|
||||
subject.helpers.should be
|
||||
end
|
||||
|
||||
context(".decorates") do
|
||||
it "sets the model for the decorated" do
|
||||
EnumerableProxy.new([source], ProductDecorator).first.model.should == source
|
||||
end
|
||||
it "is aliased to .h" do
|
||||
subject.h.should == subject.helpers
|
||||
end
|
||||
|
||||
it "decorates an empty array with the klass" do
|
||||
EnumerableProxy.decorates([], klass: ProductDecorator).should be
|
||||
end
|
||||
|
||||
it "discerns collection items decorator by the name of the decorator" do
|
||||
ProductsDecorator.decorates([]).should be
|
||||
end
|
||||
|
||||
it "methods in decorated empty array should work" do
|
||||
ProductsDecorator.decorates([]).some_method.should == "some method works"
|
||||
end
|
||||
|
||||
it "raises when decorates an empty array without the klass" do
|
||||
lambda{EnumerableProxy.decorates([])}.should raise_error
|
||||
end
|
||||
it "build a new view context" do
|
||||
Thread.current[:current_view_context] = nil
|
||||
subject.helpers.should be
|
||||
end
|
||||
end
|
||||
|
||||
describe "No View Context" do
|
||||
subject{ ProductsDecorator.new(source, ProductDecorator) }
|
||||
let(:source){ Product.new }
|
||||
context(".decorates") do
|
||||
it "sets the model for the decorated" do
|
||||
EnumerableProxy.new([source], ProductDecorator).first.model.should == source
|
||||
end
|
||||
|
||||
context(".helpers") do
|
||||
it "have a valid view_context" do
|
||||
subject.helpers.should be
|
||||
end
|
||||
it "decorates an empty array with the klass" do
|
||||
EnumerableProxy.decorates([], klass: ProductDecorator).should be
|
||||
end
|
||||
|
||||
it "is aliased to .h" do
|
||||
subject.h.should == subject.helpers
|
||||
end
|
||||
it "discerns collection items decorator by the name of the decorator" do
|
||||
ProductsDecorator.decorates([]).should be
|
||||
end
|
||||
|
||||
it "methods in decorated empty array should work" do
|
||||
ProductsDecorator.decorates([]).some_method.should == "some method works"
|
||||
end
|
||||
|
||||
it "raises when decorates an empty array without the klass" do
|
||||
lambda{EnumerableProxy.decorates([])}.should raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue