spec/ rubocopied
This commit is contained in:
@@ -1,24 +1,26 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Plugin do
|
||||
subject(:plugin) { Plugin.new }
|
||||
|
||||
describe "#new" do
|
||||
context "with some infos" do
|
||||
describe '#new' do
|
||||
context 'with some infos' do
|
||||
subject(:plugin) { Plugin.new(infos) }
|
||||
let(:infos) { {:author => "John"} }
|
||||
let(:infos) { { author: 'John' } }
|
||||
|
||||
its(:author) { should === infos[:author] }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#run" do
|
||||
it "should raise a NotImplementedError" do
|
||||
describe '#run' do
|
||||
it 'should raise a NotImplementedError' do
|
||||
expect { plugin.run }.to raise_error(NotImplementedError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#register_options" do
|
||||
describe '#register_options' do
|
||||
after :each do
|
||||
if @exception
|
||||
expect { plugin.register_options(*@options) }.to raise_error(@exception)
|
||||
@@ -28,16 +30,22 @@ describe Plugin do
|
||||
end
|
||||
end
|
||||
|
||||
context "when an option is not an Array" do
|
||||
it "should raise an error" do
|
||||
@options = [["-v", "--verbose", "It's a valid option"], "Not a valid one"]
|
||||
@exception = "Each option must be an array, String supplied"
|
||||
context 'when an option is not an Array' do
|
||||
it 'should raise an error' do
|
||||
@options = [
|
||||
['-v', '--verbose', 'It\'s a valid option'],
|
||||
'Not a valid one'
|
||||
]
|
||||
@exception = 'Each option must be an array, String supplied'
|
||||
end
|
||||
end
|
||||
|
||||
context "when options are Arrays" do
|
||||
it "should register the options" do
|
||||
@options = [["-v", "--verbose", "Verbose mode"], ["-u", "--url TARGET_URL"]]
|
||||
context 'when options are Arrays' do
|
||||
it 'should register the options' do
|
||||
@options = [
|
||||
['-v', '--verbose', 'Verbose mode'],
|
||||
['-u', '--url TARGET_URL']
|
||||
]
|
||||
@expected = *@options
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
require "spec_helper"
|
||||
# encoding: UTF-8
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
class TestPlugin < Plugin
|
||||
def initialize
|
||||
register_options(["-u", "--url"])
|
||||
register_options(['-u', '--url'])
|
||||
end
|
||||
end
|
||||
|
||||
class AnotherPlugin < Plugin
|
||||
def initialize
|
||||
super(:author => "John")
|
||||
super(author: 'John')
|
||||
# No Options
|
||||
end
|
||||
end
|
||||
@@ -19,28 +21,28 @@ describe Plugins do
|
||||
let(:test_plugin) { TestPlugin.new }
|
||||
let(:another_plugin) { AnotherPlugin.new }
|
||||
|
||||
describe "#new" do
|
||||
context "without argument" do
|
||||
describe '#new' do
|
||||
context 'without argument' do
|
||||
its(:option_parser) { should be_a CustomOptionParser }
|
||||
|
||||
it "should be an Array" do
|
||||
it 'should be an Array' do
|
||||
plugins.should be_an Array
|
||||
end
|
||||
end
|
||||
|
||||
context "with an option_parser argument" do
|
||||
subject(:plugin) { Plugins.new(CustomOptionParser.new("the banner")) }
|
||||
context 'with an option_parser argument' do
|
||||
subject(:plugin) { Plugins.new(CustomOptionParser.new('the banner')) }
|
||||
|
||||
its(:option_parser) { should be_a CustomOptionParser }
|
||||
its("option_parser.banner") { should === "the banner" }
|
||||
its('option_parser.banner') { should === 'the banner' }
|
||||
|
||||
it "should raise an eror if the parser is not an instance of CustomOptionParser" do
|
||||
expect { Plugins.new(OptionParser.new) }.to raise_error("The parser must be an instance of CustomOptionParser, OptionParser supplied")
|
||||
it 'should raise an eror if the parser is not an instance of CustomOptionParser' do
|
||||
expect { Plugins.new(OptionParser.new) }.to raise_error('The parser must be an instance of CustomOptionParser, OptionParser supplied')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#register_plugin" do
|
||||
describe '#register_plugin' do
|
||||
after :each do
|
||||
if @exception
|
||||
expect { plugins.register_plugin(@plugin) }.to raise_error(@exception)
|
||||
@@ -51,27 +53,27 @@ describe Plugins do
|
||||
end
|
||||
end
|
||||
|
||||
context "when the argument supplied is not an instance of Plugin" do
|
||||
it "should raise an error" do
|
||||
@plugin = "I'am a String"
|
||||
@exception = "The argument must be an instance of Plugin, String supplied"
|
||||
context 'when the argument supplied is not an instance of Plugin' do
|
||||
it 'should raise an error' do
|
||||
@plugin = "I'am a String"
|
||||
@exception = 'The argument must be an instance of Plugin, String supplied'
|
||||
end
|
||||
end
|
||||
|
||||
it "should register the plugin" do
|
||||
it 'should register the plugin' do
|
||||
@plugin = TestPlugin.new
|
||||
@expected = [@plugin]
|
||||
end
|
||||
|
||||
it "should register 2 plugins (the order is important)" do
|
||||
it 'should register 2 plugins (the order is important)' do
|
||||
plugins.register_plugin(test_plugin)
|
||||
|
||||
@plugin = another_plugin
|
||||
@plugin = another_plugin
|
||||
@expected = [test_plugin, @plugin]
|
||||
end
|
||||
end
|
||||
|
||||
describe "#register" do
|
||||
describe '#register' do
|
||||
after :each do
|
||||
plugins.register(*@plugins_to_register)
|
||||
|
||||
@@ -83,11 +85,11 @@ describe Plugins do
|
||||
plugins.should === @plugins_to_register
|
||||
end
|
||||
|
||||
it "should register 1 plugin" do
|
||||
it 'should register 1 plugin' do
|
||||
@plugins_to_register = [test_plugin]
|
||||
end
|
||||
|
||||
it "should register 2 plugins" do
|
||||
it 'should register 2 plugins' do
|
||||
@plugins_to_register = [another_plugin, test_plugin]
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user