spec/adhearsion/plugin_spec.rb in adhearsion-2.5.4 vs spec/adhearsion/plugin_spec.rb in adhearsion-2.6.0
- old
+ new
@@ -10,34 +10,34 @@
before :all do
defined?(FooBar) and Object.send(:remove_const, :"FooBar")
end
before do
- Adhearsion::PunchblockPlugin::Initializer.stub :start => true
+ allow(Adhearsion::PunchblockPlugin::Initializer).to receive_messages :start => true
end
describe "inheritance" do
after do
defined?(FooBar) and Object.send(:remove_const, :"FooBar")
end
it "should provide the plugin name in a plugin class" do
::FooBar = Class.new Adhearsion::Plugin
- ::FooBar.plugin_name.should be == "foo_bar"
+ expect(::FooBar.plugin_name).to eq("foo_bar")
end
it "should provide the plugin name in a plugin instance" do
::FooBar = Class.new Adhearsion::Plugin
- ::FooBar.new.plugin_name.should be == "foo_bar"
+ expect(::FooBar.new.plugin_name).to eq("foo_bar")
end
it "should provide a setter for plugin name" do
::FooBar = Class.new Adhearsion::Plugin do
self.plugin_name = "bar_foo"
end
- ::FooBar.plugin_name.should be == "bar_foo"
+ expect(::FooBar.plugin_name).to eq("bar_foo")
end
end
describe "While configuring plugins" do
after(:each) do
@@ -52,32 +52,38 @@
host "localhost", :desc => "valid IP or hostname"
end
end
}
- its(:plugin_name) { should be == :bar_foo }
+ describe '#plugin_name' do
+ subject { super().plugin_name }
+ it { is_expected.to eq(:bar_foo) }
+ end
- its(:config) { should be_instance_of Loquacious::Configuration }
+ describe '#config' do
+ subject { super().config }
+ it { is_expected.to be_instance_of Loquacious::Configuration }
+ end
it "should keep a default configuration and a description" do
[:name, :password, :host].each do |value|
- subject.config.should respond_to value
+ expect(subject.config).to respond_to value
end
- subject.config.name.should be == "user"
- subject.config.password.should be == "password"
- subject.config.host.should be == "localhost"
+ expect(subject.config.name).to eq("user")
+ expect(subject.config.password).to eq("password")
+ expect(subject.config.host).to eq("localhost")
end
it "should return a description of configuration options" do
- subject.show_description.should be_kind_of Loquacious::Configuration::Help
+ expect(subject.show_description).to be_kind_of Loquacious::Configuration::Help
end
describe "while updating config values" do
it "should return the updated value" do
subject.config.name = "usera"
- subject.config.name.should be == "usera"
+ expect(subject.config.name).to eq("usera")
end
end
end
@@ -85,19 +91,19 @@
AhnPluginDemo = Class.new Adhearsion::Plugin
it "should add plugins on the air" do
Adhearsion::Plugin.delete_all
Adhearsion::Plugin.add AhnPluginDemo
- Adhearsion::Plugin.count.should eql 1
+ expect(Adhearsion::Plugin.count).to eql 1
end
it "should delete plugins on the air" do
Adhearsion::Plugin.delete_all
Adhearsion::Plugin.add AhnPluginDemo
- Adhearsion::Plugin.count.should eql 1
+ expect(Adhearsion::Plugin.count).to eql 1
Adhearsion::Plugin.delete AhnPluginDemo
- Adhearsion::Plugin.count.should eql 0
+ expect(Adhearsion::Plugin.count).to eql 0
end
end
describe "#count" do
after(:each) do
@@ -105,11 +111,11 @@
end
it "should count the number of registered plugins" do
number = Adhearsion::Plugin.count
FooBar = Class.new Adhearsion::Plugin
- Adhearsion::Plugin.count.should eql(number + 1)
+ expect(Adhearsion::Plugin.count).to eql(number + 1)
end
end
describe "Adhearsion::Plugin.init_plugins" do
before(:all) do
@@ -140,11 +146,11 @@
describe "while registering plugins initializers" do
it "should do nothing with a Plugin that has no init method call" do
FooBar = Class.new Adhearsion::Plugin
# 1 => Punchblock. Must be empty once punchblock initializer is an external Plugin
- Adhearsion::Plugin.initializers.should have(1).initializers
+ expect(Adhearsion::Plugin.initializers.size).to eq(1)
Adhearsion::Plugin.init_plugins
end
it "should add a initializer when Plugin defines it" do
FooBar = Class.new Adhearsion::Plugin do
@@ -153,12 +159,12 @@
end
def self.log
end
end
- FooBar.should_receive(:log).once
- Adhearsion::Plugin.initializers.length.should be 1
+ expect(FooBar).to receive(:log).once
+ expect(Adhearsion::Plugin.initializers.length).to be 1
Adhearsion::Plugin.init_plugins
end
it "should initialize all Plugin children, including deep childs" do
FooBar = Class.new Adhearsion::Plugin do
@@ -179,11 +185,11 @@
init :foo_bar_bazz do
FooBar.log "foo bar bazz"
end
end
- FooBar.should_receive(:log).exactly(3).times
+ expect(FooBar).to receive(:log).exactly(3).times
Adhearsion::Plugin.init_plugins
end
it "should allow to include an initializer before another one" do
FooBar = Class.new Adhearsion::Plugin do
@@ -199,12 +205,12 @@
init :foo_bar_baz, :before => :foo_bar do
FooBar.log "foo bar baz"
end
end
- Adhearsion::Plugin.initializers.tsort.first.name.should eql :foo_bar_baz
- Adhearsion::Plugin.initializers.tsort.last.name.should eql :foo_bar
+ expect(Adhearsion::Plugin.initializers.tsort.first.name).to eql :foo_bar_baz
+ expect(Adhearsion::Plugin.initializers.tsort.last.name).to eql :foo_bar
end
it "should allow to include an initializer after another one" do
FooBar = Class.new Adhearsion::Plugin do
init :foo_bar do
@@ -225,22 +231,22 @@
init :foo_bar_bazz do
FooBar.log "foo bar bazz"
end
end
- Adhearsion::Plugin.initializers.length.should eql 3
- Adhearsion::Plugin.initializers.tsort.first.name.should eql :foo_bar
- Adhearsion::Plugin.initializers.tsort.last.name.should eql :foo_bar_baz
+ expect(Adhearsion::Plugin.initializers.length).to eql 3
+ expect(Adhearsion::Plugin.initializers.tsort.first.name).to eql :foo_bar
+ expect(Adhearsion::Plugin.initializers.tsort.last.name).to eql :foo_bar_baz
end
end
describe "while registering plugins runners" do
it "should do nothing with a Plugin that has no run method call" do
FooBar = Class.new Adhearsion::Plugin
# May become 1 if Punchblock defines a runner.
- Adhearsion::Plugin.runners.should have(0).runners
+ expect(Adhearsion::Plugin.runners.size).to eq(0)
Adhearsion::Plugin.run_plugins
end
it "should add a runner when Plugin defines it" do
FooBar = Class.new Adhearsion::Plugin do
@@ -249,12 +255,12 @@
end
def self.log
end
end
- FooBar.should_receive(:log).once
- Adhearsion::Plugin.runners.length.should be 1
+ expect(FooBar).to receive(:log).once
+ expect(Adhearsion::Plugin.runners.length).to be 1
Adhearsion::Plugin.run_plugins
end
it "should run all Plugin children, including deep childs" do
FooBar = Class.new Adhearsion::Plugin do
@@ -275,11 +281,11 @@
run :foo_bar_bazz do
FooBar.log "foo bar bazz"
end
end
- FooBar.should_receive(:log).exactly(3).times
+ expect(FooBar).to receive(:log).exactly(3).times
Adhearsion::Plugin.run_plugins
end
it "should allow to execute one runner before another one" do
FooBar = Class.new Adhearsion::Plugin do
@@ -295,12 +301,12 @@
run :foo_bar_baz, :before => :foo_bar do
FooBar.log "foo bar baz"
end
end
- Adhearsion::Plugin.runners.tsort.first.name.should eql :foo_bar_baz
- Adhearsion::Plugin.runners.tsort.last.name.should eql :foo_bar
+ expect(Adhearsion::Plugin.runners.tsort.first.name).to eql :foo_bar_baz
+ expect(Adhearsion::Plugin.runners.tsort.last.name).to eql :foo_bar
end
it "should allow to include an runner after another one" do
FooBar = Class.new Adhearsion::Plugin do
run :foo_bar do
@@ -321,13 +327,13 @@
run :foo_bar_bazz do
FooBar.log "foo bar bazz"
end
end
- Adhearsion::Plugin.runners.length.should eql 3
- Adhearsion::Plugin.runners.tsort.first.name.should eql :foo_bar
- Adhearsion::Plugin.runners.tsort.last.name.should eql :foo_bar_baz
+ expect(Adhearsion::Plugin.runners.length).to eql 3
+ expect(Adhearsion::Plugin.runners.tsort.first.name).to eql :foo_bar
+ expect(Adhearsion::Plugin.runners.tsort.last.name).to eql :foo_bar_baz
end
end
end
describe "while loading rake tasks" do
@@ -338,44 +344,47 @@
end
subject { Adhearsion::Plugin.tasks }
it "should return an Array" do
- subject.should be_instance_of Array
+ expect(subject).to be_instance_of Array
end
- its(:length) { should be == 0 }
+ describe '#length' do
+ subject { super().length }
+ it { is_expected.to eq(0) }
+ end
it "should not load a new task when there is no block in the method call" do
- subject.length.should be == 0
+ expect(subject.length).to eq(0)
FooBar = Class.new Adhearsion::Plugin do
tasks
end
- subject.length.should be == 0
+ expect(subject.length).to eq(0)
end
it "should load a new task when there is a block in the method call" do
- subject.length.should be == 0
+ expect(subject.length).to eq(0)
FooBar = Class.new Adhearsion::Plugin do
tasks do
puts "foo bar"
end
end
- Adhearsion::Plugin.tasks.length.should be == 1
+ expect(Adhearsion::Plugin.tasks.length).to eq(1)
end
it "should execute the tasks blocks while loading rake tasks" do
- subject.length.should be == 0
+ expect(subject.length).to eq(0)
FooBar = Class.new Adhearsion::Plugin do
tasks do
FooBar.foo
end
def self.foo
end
end
- FooBar.should_receive(:foo).once
+ expect(FooBar).to receive(:foo).once
Adhearsion::Plugin.load_tasks
end
end
@@ -390,11 +399,11 @@
it "should add the generator to the index" do
FooBar = Class.new Adhearsion::Plugin do
generators :gen1 => TestGenerator1, :gen2 => TestGenerator2
end
- Adhearsion::Generators.mappings[:gen1].should be TestGenerator1
- Adhearsion::Generators.mappings[:gen2].should be TestGenerator2
+ expect(Adhearsion::Generators.mappings[:gen1]).to be TestGenerator1
+ expect(Adhearsion::Generators.mappings[:gen2]).to be TestGenerator2
end
end
end