diff --git a/spec/models/fluentd/agent_spec.rb b/spec/models/fluentd/agent_spec.rb index 6c46dd1..01bcd32 100644 --- a/spec/models/fluentd/agent_spec.rb +++ b/spec/models/fluentd/agent_spec.rb @@ -29,7 +29,7 @@ describe Fluentd::Agent do end describe "#recent_errors" do - before { instance.stub(:log_file).and_return { logfile } } + before { instance.stub(:log_file).and_return(logfile) } context "have 0 error log" do let(:logfile) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) } @@ -88,14 +88,14 @@ describe Fluentd::Agent do end describe "#start" do - before { instance.stub(:running?).and_return { running } } + before { instance.stub(:running?).and_return(running) } context "running" do let(:running) { true } subject { instance.start } - it { should be_true } + it { should be_truthy } end context "not running" do @@ -104,52 +104,52 @@ describe Fluentd::Agent do subject { instance.start } before do - instance.stub(:actual_start).and_return { start_result } + instance.stub(:actual_start).and_return(start_result) end context "actual start success" do let(:start_result) { true } - it { should be_true } + it { should be_truthy } end context "actual start failed" do let(:start_result) { false } - it { should be_false } + it { should be_falsy } end end end describe "#stop" do - before { instance.stub(:running?).and_return { running } } + before { instance.stub(:running?).and_return(running) } subject { instance.stop } context "running" do let(:running) { true } - before { instance.stub(:actual_stop).and_return { stop_result } } + before { instance.stub(:actual_stop).and_return(stop_result) } context "actual stop success" do let(:stop_result) { true } - it { should be_true } + it { should be_truthy } end context "actual stop failed" do let(:stop_result) { false } - it { should be_false } + it { should be_falsy } end end context "not running" do let(:running) { false } - it { should be_true } + it { should be_truthy } end end describe "#restart" do - before { instance.stub(:stop).and_return { stop_result } } - before { instance.stub(:start).and_return { start_result } } + before { instance.stub(:stop).and_return(stop_result) } + before { instance.stub(:start).and_return(start_result) } subject { instance.restart } describe "return true only if #stop and #start success" do @@ -158,12 +158,12 @@ describe Fluentd::Agent do context" #start success" do let(:start_result) { true } - it { should be_true } + it { should be_truthy } end context" #start fail" do let(:start_result) { false } - it { should be_false } + it { should be_falsy } end end @@ -172,12 +172,12 @@ describe Fluentd::Agent do context" #start success" do let(:start_result) { true } - it { should be_false } + it { should be_falsy } end context" #start fail" do let(:start_result) { false } - it { should be_false } + it { should be_falsy } end end end diff --git a/spec/models/fluentd_spec.rb b/spec/models/fluentd_spec.rb index 75ce9b0..7d66bd6 100644 --- a/spec/models/fluentd_spec.rb +++ b/spec/models/fluentd_spec.rb @@ -154,12 +154,12 @@ describe Fluentd do context "doesn't exists" do before { File.unlink(config_file) if File.exist?(config_file) } - it { File.exist?(subject).should be_true } + it { File.exist?(subject).should be_truthy } end context "already exists" do before { FileUtils.touch(config_file) } - it { File.exist?(subject).should be_true } + it { File.exist?(subject).should be_truthy } end end end diff --git a/spec/models/login_token_spec.rb b/spec/models/login_token_spec.rb index 87c7c61..b1d7e57 100644 --- a/spec/models/login_token_spec.rb +++ b/spec/models/login_token_spec.rb @@ -17,13 +17,13 @@ describe LoginToken do describe "#active" do subject { LoginToken.active } it { subject.count.should == active } - it { subject.all?{|t| t.expired_at > Time.now}.should be_true } + it { subject.all?{|t| t.expired_at > Time.now}.should be_truthy } end describe "#inactive" do subject { LoginToken.inactive } it { subject.count.should == inactive } - it { subject.all?{|t| t.expired_at <= Time.now}.should be_true } + it { subject.all?{|t| t.expired_at <= Time.now}.should be_truthy } end end end diff --git a/spec/models/plugin_spec.rb b/spec/models/plugin_spec.rb index 3f60678..6e556db 100644 --- a/spec/models/plugin_spec.rb +++ b/spec/models/plugin_spec.rb @@ -4,7 +4,7 @@ describe Plugin do let(:plugin) { build(:plugin) } before do - Plugin.stub(:gemfile_path).and_return { Rails.root + "tmp/fluentd-ui-test-gemfile.plugins" } + Plugin.stub(:gemfile_path).and_return(Rails.root + "tmp/fluentd-ui-test-gemfile.plugins" ) end after do @@ -51,8 +51,8 @@ describe Plugin do describe "#install!" do describe "invoke fluent_gem" do after do - plugin.stub(:valid?).and_return { valid } - plugin.stub(:installed?).and_return { installed } + plugin.stub(:valid?).and_return(valid) + plugin.stub(:installed?).and_return(installed) plugin.install! end @@ -86,7 +86,7 @@ describe Plugin do end context "system command error" do - before { plugin.should_receive(:system).and_return { false } } + before { plugin.should_receive(:system).and_return(false) } subject { expect { plugin.install! } } it "raise GemError" do @@ -100,7 +100,7 @@ describe Plugin do describe "after install succeed" do before do - plugin.stub(:fluent_gem).and_return { true } + plugin.stub(:fluent_gem).and_return(true) plugin.install! end @@ -113,7 +113,7 @@ describe Plugin do let(:installed_plugin) { build(:plugin, gem_name: "fluent-plugin-foobar") } before do - installed_plugin.stub(:fluent_gem).and_return { true } + installed_plugin.stub(:fluent_gem).and_return(true) installed_plugin.install! Plugin.pristine! end @@ -132,7 +132,7 @@ describe Plugin do let(:target_version) { "1.2.0" } before do - Plugin.any_instance.stub(:fluent_gem).and_return { true } # NOTE: not `plugin.stub` because upgrade! creates new Plugin instance internally + Plugin.any_instance.stub(:fluent_gem).and_return(true) # NOTE: not `plugin.stub` because upgrade! creates new Plugin instance internally installed_plugin.install! Plugin.pristine! installed_plugin.upgrade!(target_version) @@ -145,7 +145,7 @@ describe Plugin do describe ".installed" do before do - plugin.stub(:fluent_gem).and_return { true } + plugin.stub(:fluent_gem).and_return(true) plugin.install! end @@ -159,7 +159,7 @@ describe Plugin do let(:gem_version) { Gem::Version.new("1.0.0") } before do - plugin.stub(:installed_version).and_return { gem_version.to_s } + plugin.stub(:installed_version).and_return(gem_version.to_s) stub_request(:get, /rubygems.org/).to_return(body: JSON.dump(api_response)) end @@ -170,7 +170,7 @@ describe Plugin do [{number: gem_version.bump}, {number: gem_version}] end - it { subject.should be_false } + it { subject.should be_falsy } end context "unavailable updates" do @@ -178,13 +178,13 @@ describe Plugin do [{number: gem_version}] end - it { subject.should be_true } + it { subject.should be_truthy } end end describe "#installed_version" do before do - Plugin.any_instance.stub(:fluent_gem).and_return { true } # NOTE: not `plugin.stub` because upgrade! creates new Plugin instance internally + Plugin.any_instance.stub(:fluent_gem).and_return(true) # NOTE: not `plugin.stub` because upgrade! creates new Plugin instance internally plugin.install! end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 897babc..82f09b3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -55,6 +55,9 @@ RSpec.configure do |config| # --seed 1234 config.order = "random" + # rspec 2.99 + config.infer_spec_type_from_file_location! + config.before(:suite) do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation)