vaguerent/test/unit/vagrant/errors_test.rb
Fabio Rehm 54656151cf Convert specs to RSpec 2.14.8 syntax with Transpec
This conversion is done by Transpec 1.10.2 with the following command:
    transpec test/unit/

* 507 conversions
    from: obj.should
      to: expect(obj).to

* 394 conversions
    from: == expected
      to: eq(expected)

* 260 conversions
    from: obj.should_receive(:message)
      to: expect(obj).to receive(:message)

* 85 conversions
    from: obj.stub(:message)
      to: allow(obj).to receive(:message)

* 25 conversions
    from: its(:attr) { }
      to: describe '#attr' do subject { super().attr }; it { } end

* 19 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 7 conversions
    from: obj.should_not_receive(:message)
      to: expect(obj).not_to receive(:message)

* 3 conversions
    from: Klass.any_instance.should_receive(:message)
      to: expect_any_instance_of(Klass).to receive(:message)
2014-03-14 12:02:07 -03:00

57 lines
1.4 KiB
Ruby

require File.expand_path("../../base", __FILE__)
describe Vagrant::Errors::VagrantError do
describe "subclass with error key" do
let(:klass) do
Class.new(described_class) do
error_key("test_key")
end
end
subject { klass.new }
it "should use the translation for the message" do
expect(subject.to_s).to eq("test value")
end
describe '#status_code' do
subject { super().status_code }
it { should eq(1) }
end
end
describe "passing error key through options" do
subject { described_class.new(_key: "test_key") }
it "should use the translation for the message" do
expect(subject.to_s).to eq("test value")
end
end
describe "subclass with error message" do
let(:klass) do
Class.new(described_class) do
error_message("foo")
end
end
subject { klass.new(data: "yep") }
it "should use the translation for the message" do
expect(subject.to_s).to eq("foo")
end
it "should expose translation keys to the user" do
expect(subject.extra_data.length).to eql(1)
expect(subject.extra_data).to have_key(:data)
expect(subject.extra_data[:data]).to eql("yep")
end
it "should use a symbol initializer as a key" do
subject = klass.new(:test_key)
expect(subject.extra_data).to be_empty
expect(subject.to_s).to eql("test value")
end
end
end