Follow rspec 2.99

This commit is contained in:
uu59 2014-06-02 11:07:37 +09:00
parent 31f63320a6
commit 7bf5aa2a2e
5 changed files with 36 additions and 33 deletions

View File

@ -29,7 +29,7 @@ describe Fluentd::Agent do
end end
describe "#recent_errors" do 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 context "have 0 error log" do
let(:logfile) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) } let(:logfile) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) }
@ -88,14 +88,14 @@ describe Fluentd::Agent do
end end
describe "#start" do describe "#start" do
before { instance.stub(:running?).and_return { running } } before { instance.stub(:running?).and_return(running) }
context "running" do context "running" do
let(:running) { true } let(:running) { true }
subject { instance.start } subject { instance.start }
it { should be_true } it { should be_truthy }
end end
context "not running" do context "not running" do
@ -104,52 +104,52 @@ describe Fluentd::Agent do
subject { instance.start } subject { instance.start }
before do before do
instance.stub(:actual_start).and_return { start_result } instance.stub(:actual_start).and_return(start_result)
end end
context "actual start success" do context "actual start success" do
let(:start_result) { true } let(:start_result) { true }
it { should be_true } it { should be_truthy }
end end
context "actual start failed" do context "actual start failed" do
let(:start_result) { false } let(:start_result) { false }
it { should be_false } it { should be_falsy }
end end
end end
end end
describe "#stop" do describe "#stop" do
before { instance.stub(:running?).and_return { running } } before { instance.stub(:running?).and_return(running) }
subject { instance.stop } subject { instance.stop }
context "running" do context "running" do
let(:running) { true } 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 context "actual stop success" do
let(:stop_result) { true } let(:stop_result) { true }
it { should be_true } it { should be_truthy }
end end
context "actual stop failed" do context "actual stop failed" do
let(:stop_result) { false } let(:stop_result) { false }
it { should be_false } it { should be_falsy }
end end
end end
context "not running" do context "not running" do
let(:running) { false } let(:running) { false }
it { should be_true } it { should be_truthy }
end end
end end
describe "#restart" do describe "#restart" do
before { instance.stub(:stop).and_return { stop_result } } before { instance.stub(:stop).and_return(stop_result) }
before { instance.stub(:start).and_return { start_result } } before { instance.stub(:start).and_return(start_result) }
subject { instance.restart } subject { instance.restart }
describe "return true only if #stop and #start success" do describe "return true only if #stop and #start success" do
@ -158,12 +158,12 @@ describe Fluentd::Agent do
context" #start success" do context" #start success" do
let(:start_result) { true } let(:start_result) { true }
it { should be_true } it { should be_truthy }
end end
context" #start fail" do context" #start fail" do
let(:start_result) { false } let(:start_result) { false }
it { should be_false } it { should be_falsy }
end end
end end
@ -172,12 +172,12 @@ describe Fluentd::Agent do
context" #start success" do context" #start success" do
let(:start_result) { true } let(:start_result) { true }
it { should be_false } it { should be_falsy }
end end
context" #start fail" do context" #start fail" do
let(:start_result) { false } let(:start_result) { false }
it { should be_false } it { should be_falsy }
end end
end end
end end

View File

@ -154,12 +154,12 @@ describe Fluentd do
context "doesn't exists" do context "doesn't exists" do
before { File.unlink(config_file) if File.exist?(config_file) } 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 end
context "already exists" do context "already exists" do
before { FileUtils.touch(config_file) } before { FileUtils.touch(config_file) }
it { File.exist?(subject).should be_true } it { File.exist?(subject).should be_truthy }
end end
end end
end end

View File

@ -17,13 +17,13 @@ describe LoginToken do
describe "#active" do describe "#active" do
subject { LoginToken.active } subject { LoginToken.active }
it { subject.count.should == 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 end
describe "#inactive" do describe "#inactive" do
subject { LoginToken.inactive } subject { LoginToken.inactive }
it { subject.count.should == 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 end
end end

View File

@ -4,7 +4,7 @@ describe Plugin do
let(:plugin) { build(:plugin) } let(:plugin) { build(:plugin) }
before do 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 end
after do after do
@ -51,8 +51,8 @@ describe Plugin do
describe "#install!" do describe "#install!" do
describe "invoke fluent_gem" do describe "invoke fluent_gem" do
after do after do
plugin.stub(:valid?).and_return { valid } plugin.stub(:valid?).and_return(valid)
plugin.stub(:installed?).and_return { installed } plugin.stub(:installed?).and_return(installed)
plugin.install! plugin.install!
end end
@ -86,7 +86,7 @@ describe Plugin do
end end
context "system command error" do 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! } } subject { expect { plugin.install! } }
it "raise GemError" do it "raise GemError" do
@ -100,7 +100,7 @@ describe Plugin do
describe "after install succeed" do describe "after install succeed" do
before do before do
plugin.stub(:fluent_gem).and_return { true } plugin.stub(:fluent_gem).and_return(true)
plugin.install! plugin.install!
end end
@ -113,7 +113,7 @@ describe Plugin do
let(:installed_plugin) { build(:plugin, gem_name: "fluent-plugin-foobar") } let(:installed_plugin) { build(:plugin, gem_name: "fluent-plugin-foobar") }
before do before do
installed_plugin.stub(:fluent_gem).and_return { true } installed_plugin.stub(:fluent_gem).and_return(true)
installed_plugin.install! installed_plugin.install!
Plugin.pristine! Plugin.pristine!
end end
@ -132,7 +132,7 @@ describe Plugin do
let(:target_version) { "1.2.0" } let(:target_version) { "1.2.0" }
before 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
installed_plugin.install! installed_plugin.install!
Plugin.pristine! Plugin.pristine!
installed_plugin.upgrade!(target_version) installed_plugin.upgrade!(target_version)
@ -145,7 +145,7 @@ describe Plugin do
describe ".installed" do describe ".installed" do
before do before do
plugin.stub(:fluent_gem).and_return { true } plugin.stub(:fluent_gem).and_return(true)
plugin.install! plugin.install!
end end
@ -159,7 +159,7 @@ describe Plugin do
let(:gem_version) { Gem::Version.new("1.0.0") } let(:gem_version) { Gem::Version.new("1.0.0") }
before do 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)) stub_request(:get, /rubygems.org/).to_return(body: JSON.dump(api_response))
end end
@ -170,7 +170,7 @@ describe Plugin do
[{number: gem_version.bump}, {number: gem_version}] [{number: gem_version.bump}, {number: gem_version}]
end end
it { subject.should be_false } it { subject.should be_falsy }
end end
context "unavailable updates" do context "unavailable updates" do
@ -178,13 +178,13 @@ describe Plugin do
[{number: gem_version}] [{number: gem_version}]
end end
it { subject.should be_true } it { subject.should be_truthy }
end end
end end
describe "#installed_version" do describe "#installed_version" do
before 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! plugin.install!
end end

View File

@ -55,6 +55,9 @@ RSpec.configure do |config|
# --seed 1234 # --seed 1234
config.order = "random" config.order = "random"
# rspec 2.99
config.infer_spec_type_from_file_location!
config.before(:suite) do config.before(:suite) do
DatabaseCleaner.strategy = :transaction DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation) DatabaseCleaner.clean_with(:truncation)