Reorganizing specs
This commit is contained in:
parent
5938954616
commit
fc8199cdfc
|
@ -11,27 +11,40 @@ describe Draper::Base do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return the wrapped object when converted to a model" do
|
context(".model / .to_model") do
|
||||||
subject.to_model.should == source
|
it "should return the wrapped object" do
|
||||||
|
subject.to_model.should == source
|
||||||
|
subject.model.should == source
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return the wrapped object when asked for model" do
|
context("selecting methods") do
|
||||||
subject.model.should == source
|
it "echos the methods of the wrapped class" do
|
||||||
end
|
source.methods.each do |method|
|
||||||
|
subject.should respond_to(method)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not override a defined method with a source method" do
|
||||||
|
DecoratorWithApplicationHelper.new(source).length.should == "overridden"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should always proxy to_param" do
|
||||||
|
source.send :class_eval, "def to_param; 1; end"
|
||||||
|
Draper::Base.new(source).to_param.should == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not copy the .class, .inspect, or other existing methods" do
|
||||||
|
source.class.should_not == subject.class
|
||||||
|
source.inspect.should_not == subject.inspect
|
||||||
|
source.to_s.should_not == subject.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "should wrap source methods so they still accept blocks" do
|
it "should wrap source methods so they still accept blocks" do
|
||||||
subject.gsub("Sample"){|match| "Super"}.should == "Super String"
|
subject.gsub("Sample"){|match| "Super"}.should == "Super String"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not override a defined method with a source method" do
|
|
||||||
DecoratorWithApplicationHelper.new(source).length.should == "overridden"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should always proxy to_param" do
|
|
||||||
source.send :class_eval, "def to_param; 1; end"
|
|
||||||
Draper::Base.new(source).to_param.should == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
context ".new" do
|
context ".new" do
|
||||||
it "should lookup the associated model when passed an integer" do
|
it "should lookup the associated model when passed an integer" do
|
||||||
pd = ProductDecorator.new(1)
|
pd = ProductDecorator.new(1)
|
||||||
|
@ -54,19 +67,7 @@ describe Draper::Base do
|
||||||
output.should be_instance_of(Draper::Base)
|
output.should be_instance_of(Draper::Base)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "echos the methods of the wrapped class" do
|
|
||||||
source.methods.each do |method|
|
|
||||||
subject.should respond_to(method)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should not copy the .class, .inspect, or other existing methods" do
|
|
||||||
source.class.should_not == subject.class
|
|
||||||
source.inspect.should_not == subject.inspect
|
|
||||||
source.to_s.should_not == subject.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "a sample usage with denies" do
|
describe "a sample usage with denies" do
|
||||||
before(:all) do
|
before(:all) do
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue