spec/mongoid/fields/localized_spec.rb in mongoid-3.1.7 vs spec/mongoid/fields/localized_spec.rb in mongoid-4.0.0.alpha1
- old
+ new
@@ -7,11 +7,11 @@
let(:field) do
described_class.new(:description, localize: true, type: String)
end
it "defaults to nil" do
- field.default_val.should be_nil
+ expect(field.default_val).to be_nil
end
end
context "when a default is provided" do
@@ -25,11 +25,11 @@
type: String
)
end
it "defaults to the value" do
- field.default_val.should eq("No translation")
+ expect(field.default_val).to eq("No translation")
end
end
context "when the type is not a string" do
@@ -41,11 +41,11 @@
type: Integer
)
end
it "keeps the default in the proper type" do
- field.default_val.should eq(1)
+ expect(field.default_val).to eq(1)
end
end
end
describe "#demongoize" do
@@ -61,22 +61,22 @@
let(:value) do
field.demongoize(nil)
end
it "returns nil" do
- value.should be_nil
+ expect(value).to be_nil
end
end
context "when no locale is defined" do
let(:value) do
field.demongoize({ "en" => "This is a test" })
end
it "returns the string from the default locale" do
- value.should eq("This is a test")
+ expect(value).to eq("This is a test")
end
end
context "when a locale is provided" do
@@ -93,11 +93,11 @@
let(:value) do
field.demongoize({ "de" => "This is a test" })
end
it "returns the string from the set locale" do
- value.should eq("This is a test")
+ expect(value).to eq("This is a test")
end
end
context "when the value does not exist" do
@@ -106,11 +106,11 @@
let(:value) do
field.demongoize({ "en" => "testing" })
end
it "returns nil" do
- value.should be_nil
+ expect(value).to be_nil
end
end
context "when using fallbacks" do
@@ -130,33 +130,33 @@
let(:value) do
field.demongoize({ "en" => "testing" })
end
it "returns the fallback translation" do
- value.should eq("testing")
+ expect(value).to eq("testing")
end
end
context "when another fallback translation exists" do
let(:value) do
field.demongoize({ "es" => "pruebas" })
end
it "returns the fallback translation" do
- value.should eq("pruebas")
+ expect(value).to eq("pruebas")
end
end
context "when the fallback translation does not exist" do
let(:value) do
field.demongoize({ "fr" => "oui" })
end
it "returns nil" do
- value.should be_nil
+ expect(value).to be_nil
end
end
end
context "when no fallbacks are defined" do
@@ -168,11 +168,11 @@
let(:value) do
field.demongoize({ "es" => "pruebas" })
end
it "returns nil" do
- value.should be_nil
+ expect(value).to be_nil
end
end
end
end
end
@@ -189,22 +189,22 @@
let(:value) do
field.demongoize(nil)
end
it "returns nil" do
- value.should be_nil
+ expect(value).to be_nil
end
end
context "when no locale is defined" do
let(:value) do
field.demongoize({ "en" => 100 })
end
it "returns the value from the default locale" do
- value.should eq(100)
+ expect(value).to eq(100)
end
end
context "when a locale is provided" do
@@ -221,11 +221,11 @@
let(:value) do
field.demongoize({ "de" => 100 })
end
it "returns the value from the set locale" do
- value.should eq(100)
+ expect(value).to eq(100)
end
end
context "when the value does not exist" do
@@ -234,11 +234,11 @@
let(:value) do
field.demongoize({ "en" => 100 })
end
it "returns nil" do
- value.should be_nil
+ expect(value).to be_nil
end
end
context "when using fallbacks" do
@@ -258,33 +258,33 @@
let(:value) do
field.demongoize({ "en" => 1 })
end
it "returns the fallback translation" do
- value.should eq(1)
+ expect(value).to eq(1)
end
end
context "when another fallback translation exists" do
let(:value) do
field.demongoize({ "es" => 100 })
end
it "returns the fallback translation" do
- value.should eq(100)
+ expect(value).to eq(100)
end
end
context "when the fallback translation does not exist" do
let(:value) do
field.demongoize({ "fr" => 50 })
end
it "returns nil" do
- value.should be_nil
+ expect(value).to be_nil
end
end
end
context "when no fallbacks are defined" do
@@ -296,11 +296,11 @@
let(:value) do
field.demongoize({ "es" => 100 })
end
it "returns nil" do
- value.should be_nil
+ expect(value).to be_nil
end
end
end
end
end
@@ -320,11 +320,11 @@
let(:value) do
field.mongoize("This is a test")
end
it "returns the string in the default locale" do
- value.should eq({ "en" => "This is a test" })
+ expect(value).to eq({ "en" => "This is a test" })
end
end
context "when a locale is provided" do
@@ -339,11 +339,11 @@
let(:value) do
field.mongoize("This is a test")
end
it "returns the string in the set locale" do
- value.should eq({ "de" => "This is a test" })
+ expect(value).to eq({ "de" => "This is a test" })
end
end
end
context "when the type is not a string" do
@@ -357,11 +357,11 @@
let(:value) do
field.mongoize("100")
end
it "returns the value in the default locale" do
- value.should eq({ "en" => 100 })
+ expect(value).to eq({ "en" => 100 })
end
end
context "when a locale is provided" do
@@ -376,10 +376,10 @@
let(:value) do
field.mongoize("100")
end
it "returns the string in the set locale" do
- value.should eq({ "de" => 100 })
+ expect(value).to eq({ "de" => 100 })
end
end
end
end
end