mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:21:18 +08:00
Convert specs to RSpec 2.99.2 syntax with Transpec
This conversion is done by Transpec 3.1.0 with the following command: transpec * 424 conversions from: obj.should to: expect(obj).to * 325 conversions from: == expected to: eq(expected) * 38 conversions from: obj.should_not to: expect(obj).not_to * 15 conversions from: =~ /pattern/ to: match(/pattern/) * 9 conversions from: it { should ... } to: it { is_expected.to ... } * 5 conversions from: lambda { }.should_not to: expect { }.not_to * 4 conversions from: lambda { }.should to: expect { }.to * 2 conversions from: -> { }.should to: expect { }.to * 2 conversions from: -> { }.should_not to: expect { }.not_to * 1 conversion from: === expected to: be === expected * 1 conversion from: =~ [1, 2] to: match_array([1, 2]) For more details: https://github.com/yujinakayama/transpec#supported-conversions
This commit is contained in:
@ -33,24 +33,24 @@ describe SiteSettingExtension do
|
||||
it "will reset to default if provider vanishes" do
|
||||
settings.setting(:hello, 1)
|
||||
settings.hello = 100
|
||||
settings.hello.should == 100
|
||||
expect(settings.hello).to eq(100)
|
||||
|
||||
settings.provider.clear
|
||||
settings.refresh!
|
||||
|
||||
settings.hello.should == 1
|
||||
expect(settings.hello).to eq(1)
|
||||
end
|
||||
|
||||
it "will set to new value if provider changes" do
|
||||
|
||||
settings.setting(:hello, 1)
|
||||
settings.hello = 100
|
||||
settings.hello.should == 100
|
||||
expect(settings.hello).to eq(100)
|
||||
|
||||
settings.provider.save(:hello, 99, SiteSetting.types[:fixnum] )
|
||||
settings.refresh!
|
||||
|
||||
settings.hello.should == 99
|
||||
expect(settings.hello).to eq(99)
|
||||
end
|
||||
|
||||
it "Publishes changes cross sites" do
|
||||
@ -60,12 +60,12 @@ describe SiteSettingExtension do
|
||||
settings.hello = 100
|
||||
|
||||
settings2.refresh!
|
||||
settings2.hello.should == 100
|
||||
expect(settings2.hello).to eq(100)
|
||||
|
||||
settings.hello = 99
|
||||
|
||||
settings2.refresh!
|
||||
settings2.hello.should == 99
|
||||
expect(settings2.hello).to eq(99)
|
||||
end
|
||||
|
||||
end
|
||||
@ -75,7 +75,7 @@ describe SiteSettingExtension do
|
||||
settings.setting(:hello, 1)
|
||||
settings.hello = 100
|
||||
settings.provider.current_site = "boom"
|
||||
settings.hello.should == 1
|
||||
expect(settings.hello).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
@ -86,16 +86,16 @@ describe SiteSettingExtension do
|
||||
end
|
||||
|
||||
it "should have a key in all_settings" do
|
||||
settings.all_settings.detect {|s| s[:setting] == :test_setting }.should be_present
|
||||
expect(settings.all_settings.detect {|s| s[:setting] == :test_setting }).to be_present
|
||||
end
|
||||
|
||||
it "should have the correct desc" do
|
||||
I18n.expects(:t).with("site_settings.test_setting").returns("test description")
|
||||
settings.description(:test_setting).should == "test description"
|
||||
expect(settings.description(:test_setting)).to eq("test description")
|
||||
end
|
||||
|
||||
it "should have the correct default" do
|
||||
settings.test_setting.should == 77
|
||||
expect(settings.test_setting).to eq(77)
|
||||
end
|
||||
|
||||
context "when overidden" do
|
||||
@ -105,29 +105,29 @@ describe SiteSettingExtension do
|
||||
|
||||
it "should have the correct override" do
|
||||
settings.test_setting = 100
|
||||
settings.test_setting.should == 100
|
||||
expect(settings.test_setting).to eq(100)
|
||||
end
|
||||
|
||||
it "should coerce correct string to int" do
|
||||
settings.test_setting = "101"
|
||||
settings.test_setting.should.eql? 101
|
||||
expect(settings.test_setting).to.eql? 101
|
||||
end
|
||||
|
||||
it "should coerce incorrect string to 0" do
|
||||
settings.test_setting = "pie"
|
||||
settings.test_setting.should.eql? 0
|
||||
expect(settings.test_setting).to.eql? 0
|
||||
end
|
||||
|
||||
it "should not set default when reset" do
|
||||
settings.test_setting = 100
|
||||
settings.setting(:test_setting, 77)
|
||||
settings.refresh!
|
||||
settings.test_setting.should_not == 77
|
||||
expect(settings.test_setting).not_to eq(77)
|
||||
end
|
||||
|
||||
it "can be overridden with set" do
|
||||
settings.set("test_setting", 12)
|
||||
settings.test_setting.should == 12
|
||||
expect(settings.test_setting).to eq(12)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -148,7 +148,7 @@ describe SiteSettingExtension do
|
||||
end
|
||||
|
||||
it "should have the correct default" do
|
||||
settings.test_str.should == "str"
|
||||
expect(settings.test_str).to eq("str")
|
||||
end
|
||||
|
||||
context "when overridden" do
|
||||
@ -158,12 +158,12 @@ describe SiteSettingExtension do
|
||||
|
||||
it "should coerce int to string" do
|
||||
settings.test_str = 100
|
||||
settings.test_str.should.eql? "100"
|
||||
expect(settings.test_str).to.eql? "100"
|
||||
end
|
||||
|
||||
it "can be overridden with set" do
|
||||
settings.set("test_str", "hi")
|
||||
settings.test_str.should == "hi"
|
||||
expect(settings.test_str).to eq("hi")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -180,7 +180,7 @@ describe SiteSettingExtension do
|
||||
message = e.message
|
||||
end
|
||||
|
||||
message.should =~ /oops/
|
||||
expect(message).to match(/oops/)
|
||||
end
|
||||
end
|
||||
|
||||
@ -191,7 +191,7 @@ describe SiteSettingExtension do
|
||||
end
|
||||
|
||||
it "should have the correct default" do
|
||||
settings.test_hello?.should == false
|
||||
expect(settings.test_hello?).to eq(false)
|
||||
end
|
||||
|
||||
context "when overridden" do
|
||||
@ -201,29 +201,29 @@ describe SiteSettingExtension do
|
||||
|
||||
it "should have the correct override" do
|
||||
settings.test_hello = true
|
||||
settings.test_hello?.should == true
|
||||
expect(settings.test_hello?).to eq(true)
|
||||
end
|
||||
|
||||
it "should coerce true strings to true" do
|
||||
settings.test_hello = "true"
|
||||
settings.test_hello?.should.eql? true
|
||||
expect(settings.test_hello?).to.eql? true
|
||||
end
|
||||
|
||||
it "should coerce all other strings to false" do
|
||||
settings.test_hello = "f"
|
||||
settings.test_hello?.should.eql? false
|
||||
expect(settings.test_hello?).to.eql? false
|
||||
end
|
||||
|
||||
it "should not set default when reset" do
|
||||
settings.test_hello = true
|
||||
settings.setting(:test_hello?, false)
|
||||
settings.refresh!
|
||||
settings.test_hello?.should_not == false
|
||||
expect(settings.test_hello?).not_to eq(false)
|
||||
end
|
||||
|
||||
it "can be overridden with set" do
|
||||
settings.set("test_hello", true)
|
||||
settings.test_hello?.should == true
|
||||
expect(settings.test_hello?).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -256,7 +256,7 @@ describe SiteSettingExtension do
|
||||
end
|
||||
|
||||
it 'should not hose all_settings' do
|
||||
settings.all_settings.detect {|s| s[:setting] == :test_enum }.should be_present
|
||||
expect(settings.all_settings.detect {|s| s[:setting] == :test_enum }).to be_present
|
||||
end
|
||||
|
||||
context 'when overridden' do
|
||||
@ -284,7 +284,7 @@ describe SiteSettingExtension do
|
||||
end
|
||||
|
||||
it "should return the category in all_settings" do
|
||||
settings.all_settings.find {|s| s[:setting] == :test_setting }[:category].should == :tests
|
||||
expect(settings.all_settings.find {|s| s[:setting] == :test_setting }[:category]).to eq(:tests)
|
||||
end
|
||||
|
||||
context "when overidden" do
|
||||
@ -294,12 +294,12 @@ describe SiteSettingExtension do
|
||||
|
||||
it "should have the correct override" do
|
||||
settings.test_setting = 101
|
||||
settings.test_setting.should == 101
|
||||
expect(settings.test_setting).to eq(101)
|
||||
end
|
||||
|
||||
it "should still have the correct category" do
|
||||
settings.test_setting = 102
|
||||
settings.all_settings.find {|s| s[:setting] == :test_setting }[:category].should == :tests
|
||||
expect(settings.all_settings.find {|s| s[:setting] == :test_setting }[:category]).to eq(:tests)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -317,7 +317,7 @@ describe SiteSettingExtension do
|
||||
it "stores valid values" do
|
||||
EmailSettingValidator.any_instance.expects(:valid_value?).returns(true)
|
||||
settings.validated_setting = 'success@example.com'
|
||||
settings.validated_setting.should == 'success@example.com'
|
||||
expect(settings.validated_setting).to eq('success@example.com')
|
||||
end
|
||||
|
||||
it "rejects invalid values" do
|
||||
@ -325,12 +325,12 @@ describe SiteSettingExtension do
|
||||
EmailSettingValidator.any_instance.expects(:valid_value?).returns(false)
|
||||
settings.validated_setting = 'nope'
|
||||
}.to raise_error(Discourse::InvalidParameters)
|
||||
settings.validated_setting.should == "info@example.com"
|
||||
expect(settings.validated_setting).to eq("info@example.com")
|
||||
end
|
||||
|
||||
it "allows blank values" do
|
||||
settings.validated_setting = ''
|
||||
settings.validated_setting.should == ''
|
||||
expect(settings.validated_setting).to eq('')
|
||||
end
|
||||
end
|
||||
|
||||
@ -362,12 +362,12 @@ describe SiteSettingExtension do
|
||||
|
||||
it "filters domain" do
|
||||
settings.set("white_listed_spam_host_domains", "http://www.discourse.org/")
|
||||
settings.white_listed_spam_host_domains.should == "www.discourse.org"
|
||||
expect(settings.white_listed_spam_host_domains).to eq("www.discourse.org")
|
||||
end
|
||||
|
||||
it "returns invalid domain as is, without throwing exception" do
|
||||
settings.set("white_listed_spam_host_domains", "test!url")
|
||||
settings.white_listed_spam_host_domains.should == "test!url"
|
||||
expect(settings.white_listed_spam_host_domains).to eq("test!url")
|
||||
end
|
||||
end
|
||||
|
||||
@ -378,19 +378,19 @@ describe SiteSettingExtension do
|
||||
end
|
||||
|
||||
it "is in the `hidden_settings` collection" do
|
||||
settings.hidden_settings.include?(:superman_identity).should == true
|
||||
expect(settings.hidden_settings.include?(:superman_identity)).to eq(true)
|
||||
end
|
||||
|
||||
it "can be retrieved" do
|
||||
settings.superman_identity.should == "Clark Kent"
|
||||
expect(settings.superman_identity).to eq("Clark Kent")
|
||||
end
|
||||
|
||||
it "is not present in all_settings by default" do
|
||||
settings.all_settings.find {|s| s[:setting] == :superman_identity }.should be_blank
|
||||
expect(settings.all_settings.find {|s| s[:setting] == :superman_identity }).to be_blank
|
||||
end
|
||||
|
||||
it "is present in all_settings when we ask for hidden" do
|
||||
settings.all_settings(true).find {|s| s[:setting] == :superman_identity }.should be_present
|
||||
expect(settings.all_settings(true).find {|s| s[:setting] == :superman_identity }).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
@ -402,17 +402,17 @@ describe SiteSettingExtension do
|
||||
end
|
||||
|
||||
it "should not add the key to the shadowed_settings collection" do
|
||||
settings.shadowed_settings.include?(:trout_api_key).should == false
|
||||
expect(settings.shadowed_settings.include?(:trout_api_key)).to eq(false)
|
||||
end
|
||||
|
||||
it "can return the default value" do
|
||||
settings.trout_api_key.should == 'evil'
|
||||
expect(settings.trout_api_key).to eq('evil')
|
||||
end
|
||||
|
||||
it "can overwrite the default" do
|
||||
settings.trout_api_key = 'tophat'
|
||||
settings.refresh!
|
||||
settings.trout_api_key.should == 'tophat'
|
||||
expect(settings.trout_api_key).to eq('tophat')
|
||||
end
|
||||
end
|
||||
|
||||
@ -424,16 +424,16 @@ describe SiteSettingExtension do
|
||||
end
|
||||
|
||||
it "should return the global setting instead of default" do
|
||||
settings.trout_api_key.should == 'purringcat'
|
||||
expect(settings.trout_api_key).to eq('purringcat')
|
||||
end
|
||||
|
||||
it "should return the global setting after a refresh" do
|
||||
settings.refresh!
|
||||
settings.trout_api_key.should == 'purringcat'
|
||||
expect(settings.trout_api_key).to eq('purringcat')
|
||||
end
|
||||
|
||||
it "should add the key to the shadowed_settings collection" do
|
||||
settings.shadowed_settings.include?(:trout_api_key).should == true
|
||||
expect(settings.shadowed_settings.include?(:trout_api_key)).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user