models with rspec3 syntax

This commit is contained in:
Luciano Sousa
2015-01-05 13:04:23 -03:00
parent 07540bcb49
commit b52f12948a
17 changed files with 537 additions and 535 deletions

View File

@ -2,23 +2,23 @@ require 'spec_helper'
describe SiteText do
it { should validate_presence_of :value }
it { is_expected.to validate_presence_of :value }
describe "#text_for" do
it "returns an empty string for a missing text_type" do
SiteText.text_for('something_random').should == ""
expect(SiteText.text_for('something_random')).to eq("")
end
it "returns the default value for a text` type with a default" do
SiteText.text_for("usage_tips").should be_present
expect(SiteText.text_for("usage_tips")).to be_present
end
it "correctly expires and bypasses cache" do
SiteSetting.enable_sso = false
text = SiteText.create!(text_type: "got.sso", value: "got sso: %{enable_sso}")
SiteText.text_for("got.sso").should == "got sso: false"
expect(SiteText.text_for("got.sso")).to eq("got sso: false")
SiteText.text_for("got.sso").frozen? == true
SiteSetting.enable_sso = true
@ -33,14 +33,14 @@ describe SiteText do
SiteText.text_for("got.sso") == "I gots sso: true"
end
SiteText.text_for("got.sso", enable_sso: "frog").should == "I gots sso: frog"
expect(SiteText.text_for("got.sso", enable_sso: "frog")).to eq("I gots sso: frog")
end
context "without replacements" do
let!(:site_text) { Fabricate(:site_text_basic) }
it "returns the simple string" do
SiteText.text_for('breaking.bad').should == "best show ever"
expect(SiteText.text_for('breaking.bad')).to eq("best show ever")
end
end
@ -50,15 +50,15 @@ describe SiteText do
let(:replacements) { {flower: 'roses', food: 'grapes'} }
it "returns the correct string with replacements" do
SiteText.text_for('great.poem', replacements).should == "roses are red. grapes are blue."
expect(SiteText.text_for('great.poem', replacements)).to eq("roses are red. grapes are blue.")
end
it "doesn't mind extra keys in the replacements" do
SiteText.text_for('great.poem', replacements.merge(extra: 'key')).should == "roses are red. grapes are blue."
expect(SiteText.text_for('great.poem', replacements.merge(extra: 'key'))).to eq("roses are red. grapes are blue.")
end
it "ignores missing keys" do
SiteText.text_for('great.poem', flower: 'roses').should == "roses are red. %{food} are blue."
expect(SiteText.text_for('great.poem', flower: 'roses')).to eq("roses are red. %{food} are blue.")
end
end
@ -68,12 +68,12 @@ describe SiteText do
it "replaces site_settings by default" do
SiteSetting.title = "Evil Trout"
SiteText.text_for('site.replacement').should == "Evil Trout is evil."
expect(SiteText.text_for('site.replacement')).to eq("Evil Trout is evil.")
end
it "allows us to override the default site settings" do
SiteSetting.title = "Evil Trout"
SiteText.text_for('site.replacement', title: 'Good Tuna').should == "Good Tuna is evil."
expect(SiteText.text_for('site.replacement', title: 'Good Tuna')).to eq("Good Tuna is evil.")
end
end