Removed some deprecated Rspec syntax
This commit is contained in:
parent
7cc97d3f2b
commit
5b7d4aff9a
|
@ -168,7 +168,7 @@ module Draper
|
|||
decorator = CollectionDecorator.new(object)
|
||||
other = ProductsDecorator.new(object)
|
||||
|
||||
expect(decorator == other).to be_true
|
||||
expect(decorator == other).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -177,7 +177,7 @@ module Draper
|
|||
decorator = CollectionDecorator.new([Product.new, Product.new])
|
||||
other = ProductsDecorator.new([Product.new, Product.new])
|
||||
|
||||
expect(decorator == other).to be_false
|
||||
expect(decorator == other).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -187,7 +187,7 @@ module Draper
|
|||
decorator = CollectionDecorator.new(object)
|
||||
other = object.dup
|
||||
|
||||
expect(decorator == other).to be_true
|
||||
expect(decorator == other).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -196,7 +196,7 @@ module Draper
|
|||
decorator = CollectionDecorator.new([Product.new, Product.new])
|
||||
other = [Product.new, Product.new]
|
||||
|
||||
expect(decorator == other).to be_false
|
||||
expect(decorator == other).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -207,7 +207,7 @@ module Draper
|
|||
other = object.dup
|
||||
|
||||
decorator << Product.new.decorate
|
||||
expect(decorator == other).to be_false
|
||||
expect(decorator == other).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -48,21 +48,21 @@ module Draper
|
|||
|
||||
describe "#decorator_class?" do
|
||||
it "returns true for decoratable model" do
|
||||
expect(Product.new.decorator_class?).to be_true
|
||||
expect(Product.new.decorator_class?).to be_truthy
|
||||
end
|
||||
|
||||
it "returns false for non-decoratable model" do
|
||||
expect(Model.new.decorator_class?).to be_false
|
||||
expect(Model.new.decorator_class?).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
describe ".decorator_class?" do
|
||||
it "returns true for decoratable model" do
|
||||
expect(Product.decorator_class?).to be_true
|
||||
expect(Product.decorator_class?).to be_truthy
|
||||
end
|
||||
|
||||
it "returns false for non-decoratable model" do
|
||||
expect(Model.decorator_class?).to be_false
|
||||
expect(Model.decorator_class?).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -84,46 +84,46 @@ module Draper
|
|||
product = Product.new
|
||||
|
||||
product.should_receive(:==).and_return(true)
|
||||
expect(product === :anything).to be_true
|
||||
expect(product === :anything).to be_truthy
|
||||
end
|
||||
|
||||
it "is false when #== is false" do
|
||||
product = Product.new
|
||||
|
||||
product.should_receive(:==).and_return(false)
|
||||
expect(product === :anything).to be_false
|
||||
expect(product === :anything).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
describe ".====" do
|
||||
it "is true for an instance" do
|
||||
expect(Product === Product.new).to be_true
|
||||
expect(Product === Product.new).to be_truthy
|
||||
end
|
||||
|
||||
it "is true for a derived instance" do
|
||||
expect(Product === Class.new(Product).new).to be_true
|
||||
expect(Product === Class.new(Product).new).to be_truthy
|
||||
end
|
||||
|
||||
it "is false for an unrelated instance" do
|
||||
expect(Product === Model.new).to be_false
|
||||
expect(Product === Model.new).to be_falsey
|
||||
end
|
||||
|
||||
it "is true for a decorated instance" do
|
||||
decorator = double(object: Product.new)
|
||||
|
||||
expect(Product === decorator).to be_true
|
||||
expect(Product === decorator).to be_truthy
|
||||
end
|
||||
|
||||
it "is true for a decorated derived instance" do
|
||||
decorator = double(object: Class.new(Product).new)
|
||||
|
||||
expect(Product === decorator).to be_true
|
||||
expect(Product === decorator).to be_truthy
|
||||
end
|
||||
|
||||
it "is false for a decorated unrelated instance" do
|
||||
decorator = double(object: Model.new)
|
||||
|
||||
expect(Product === decorator).to be_false
|
||||
expect(Product === decorator).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -222,19 +222,19 @@ module Draper
|
|||
it "returns truthy when .object_class is set" do
|
||||
Decorator.stub(:object_class).and_return(Model)
|
||||
|
||||
expect(Decorator.object_class?).to be_true
|
||||
expect(Decorator.object_class?).to be_truthy
|
||||
end
|
||||
|
||||
it "returns false when .object_class is not inferrable" do
|
||||
Decorator.stub(:object_class).and_raise(UninferrableSourceError.new(Decorator))
|
||||
|
||||
expect(Decorator.object_class?).to be_false
|
||||
expect(Decorator.object_class?).to be_falsey
|
||||
end
|
||||
|
||||
it "is aliased to .source_class?" do
|
||||
Decorator.stub(:object_class).and_return(Model)
|
||||
|
||||
expect(Decorator.source_class?).to be_true
|
||||
expect(Decorator.source_class?).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -514,7 +514,7 @@ module Draper
|
|||
other = double(object: Model.new)
|
||||
|
||||
object.should_receive(:==).with(other).and_return(true)
|
||||
expect(decorator == other).to be_true
|
||||
expect(decorator == other).to be_truthy
|
||||
end
|
||||
|
||||
it "is false when object #== is false" do
|
||||
|
@ -523,7 +523,7 @@ module Draper
|
|||
other = double(object: Model.new)
|
||||
|
||||
object.should_receive(:==).with(other).and_return(false)
|
||||
expect(decorator == other).to be_false
|
||||
expect(decorator == other).to be_falsey
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -533,14 +533,14 @@ module Draper
|
|||
decorator = Decorator.new(Model.new)
|
||||
decorator.stub(:==).with(:anything).and_return(true)
|
||||
|
||||
expect(decorator === :anything).to be_true
|
||||
expect(decorator === :anything).to be_truthy
|
||||
end
|
||||
|
||||
it "is false when #== is false" do
|
||||
decorator = Decorator.new(Model.new)
|
||||
decorator.stub(:==).with(:anything).and_return(false)
|
||||
|
||||
expect(decorator === :anything).to be_false
|
||||
expect(decorator === :anything).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -659,14 +659,14 @@ module Draper
|
|||
Decorator.class_eval{private; def hello_world; end}
|
||||
decorator = Decorator.new(Model.new)
|
||||
|
||||
expect(decorator.respond_to?(:hello_world, true)).to be_true
|
||||
expect(decorator.respond_to?(:hello_world, true)).to be_truthy
|
||||
end
|
||||
|
||||
it "returns false for the object's private methods" do
|
||||
object = Class.new{private; def hello_world; end}.new
|
||||
decorator = Decorator.new(object)
|
||||
|
||||
expect(decorator.respond_to?(:hello_world, true)).to be_false
|
||||
expect(decorator.respond_to?(:hello_world, true)).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -722,27 +722,27 @@ module Draper
|
|||
it "pretends to be a kind of the source class" do
|
||||
decorator = Decorator.new(Model.new)
|
||||
|
||||
expect(decorator.kind_of?(Model)).to be_true
|
||||
expect(decorator.is_a?(Model)).to be_true
|
||||
expect(decorator.kind_of?(Model)).to be_truthy
|
||||
expect(decorator.is_a?(Model)).to be_truthy
|
||||
end
|
||||
|
||||
it "is still a kind of its own class" do
|
||||
decorator = Decorator.new(Model.new)
|
||||
|
||||
expect(decorator.kind_of?(Decorator)).to be_true
|
||||
expect(decorator.is_a?(Decorator)).to be_true
|
||||
expect(decorator.kind_of?(Decorator)).to be_truthy
|
||||
expect(decorator.is_a?(Decorator)).to be_truthy
|
||||
end
|
||||
|
||||
it "pretends to be an instance of the source class" do
|
||||
decorator = Decorator.new(Model.new)
|
||||
|
||||
expect(decorator.instance_of?(Model)).to be_true
|
||||
expect(decorator.instance_of?(Model)).to be_truthy
|
||||
end
|
||||
|
||||
it "is still an instance of its own class" do
|
||||
decorator = Decorator.new(Model.new)
|
||||
|
||||
expect(decorator.instance_of?(Decorator)).to be_true
|
||||
expect(decorator.instance_of?(Decorator)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ module Draper
|
|||
it "allows #method to be called on the view context" do
|
||||
helper_proxy = HelperProxy.new(double(foo: "bar"))
|
||||
|
||||
expect(helper_proxy.respond_to?(:foo)).to be_true
|
||||
expect(helper_proxy.respond_to?(:foo)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@ require 'spec_helper'
|
|||
|
||||
describe "A spec in this folder" do
|
||||
it "is a decorator spec" do
|
||||
expect(example.metadata[:type]).to be :decorator
|
||||
expect(RSpec.current_example.metadata[:type]).to be :decorator
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ shared_examples_for "a decoratable model" do
|
|||
described_class.create
|
||||
decorated = described_class.limit(1).decorate
|
||||
|
||||
expect(decorated).to have(1).items
|
||||
expect(decorated.size).to eq(1)
|
||||
expect(decorated).to be_decorated
|
||||
end
|
||||
end
|
||||
|
@ -18,7 +18,7 @@ shared_examples_for "a decoratable model" do
|
|||
other = described_class.first
|
||||
|
||||
expect(one).not_to be other
|
||||
expect(one == other.decorate).to be_true
|
||||
expect(one == other.decorate).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,9 +40,8 @@ describe Rails::Generators::DecoratorGenerator do
|
|||
|
||||
context "with an ApplicationDecorator" do
|
||||
before do
|
||||
Object.any_instance.stub(:require).with("application_decorator").and_return do
|
||||
stub_const "ApplicationDecorator", Class.new
|
||||
end
|
||||
Object.any_instance.stub(:require).with("application_decorator").and_return (
|
||||
stub_const "ApplicationDecorator", Class.new)
|
||||
end
|
||||
|
||||
before { run_generator %w(YourModel) }
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
shared_examples_for "decoration-aware #==" do |subject|
|
||||
it "is true for itself" do
|
||||
expect(subject == subject).to be_true
|
||||
expect(subject == subject).to be_truthy
|
||||
end
|
||||
|
||||
it "is false for another object" do
|
||||
expect(subject == Object.new).to be_false
|
||||
expect(subject == Object.new).to be_falsey
|
||||
end
|
||||
|
||||
it "is true for a decorated version of itself" do
|
||||
decorated = double(object: subject, decorated?: true)
|
||||
|
||||
expect(subject == decorated).to be_true
|
||||
expect(subject == decorated).to be_truthy
|
||||
end
|
||||
|
||||
it "is false for a decorated other object" do
|
||||
decorated = double(object: Object.new, decorated?: true)
|
||||
|
||||
expect(subject == decorated).to be_false
|
||||
expect(subject == decorated).to be_falsey
|
||||
end
|
||||
|
||||
it "is false for a decoratable object with a `object` association" do
|
||||
decoratable = double(object: subject, decorated?: false)
|
||||
|
||||
expect(subject == decoratable).to be_false
|
||||
expect(subject == decoratable).to be_falsey
|
||||
end
|
||||
|
||||
it "is false for an undecoratable object with a `object` association" do
|
||||
undecoratable = double(object: subject)
|
||||
|
||||
expect(subject == undecoratable).to be_false
|
||||
expect(subject == undecoratable).to be_falsey
|
||||
end
|
||||
|
||||
it "is true for a multiply-decorated version of itself" do
|
||||
decorated = double(object: subject, decorated?: true)
|
||||
redecorated = double(object: decorated, decorated?: true)
|
||||
|
||||
expect(subject == redecorated).to be_true
|
||||
expect(subject == redecorated).to be_truthy
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue