test/lib/vedeu/common_test.rb in vedeu-0.7.4 vs test/lib/vedeu/common_test.rb in vedeu-0.8.0
- old
+ new
@@ -58,10 +58,104 @@
subject { instance.become(klass, attributes) }
it { subject.must_be_instance_of(Vedeu::Cells::Char) }
end
+ describe '#boolean' do
+ subject { instance.boolean(_value) }
+
+ context 'when the value is a TrueClass' do
+ let(:_value) { true }
+
+ it { subject.must_equal(true) }
+ end
+
+ context 'when the value is a FalseClass' do
+ let(:_value) { false }
+
+ it { subject.must_equal(false) }
+ end
+
+ context 'when the value is nil' do
+ let(:_value) {}
+
+ it { subject.must_equal(false) }
+ end
+
+ context 'when the value is anything else' do
+ let(:_value) { 'anything' }
+
+ it { subject.must_equal(true) }
+ end
+ end
+
+ describe '#boolean?' do
+ subject { instance.boolean?(_value) }
+
+ context 'when the value is a TrueClass' do
+ let(:_value) { true }
+
+ it { subject.must_equal(true) }
+ end
+
+ context 'when the value is a FalseClass' do
+ let(:_value) { false }
+
+ it { subject.must_equal(true) }
+ end
+
+ context 'when the value is anything else' do
+ let(:_value) { 'anything' }
+
+ it { subject.must_equal(false) }
+ end
+ end
+
+ describe '#falsy?' do
+ subject { instance.falsy?(_value) }
+
+ context 'when the value is a TrueClass' do
+ let(:_value) { true }
+
+ it { subject.must_equal(false) }
+ end
+
+ context 'when the value is a FalseClass' do
+ let(:_value) { false }
+
+ it { subject.must_equal(true) }
+ end
+
+ context 'when the value is nil' do
+ let(:_value) {}
+
+ it { subject.must_equal(true) }
+ end
+
+ context 'when the value is anything else' do
+ let(:_value) { 'anything' }
+
+ it { subject.must_equal(false) }
+ end
+ end
+
+ describe '#hash?' do
+ let(:_value) {}
+
+ subject { instance.hash?(_value) }
+
+ context 'when the value is a Hash' do
+ let(:_value) { { element: :hydrogen } }
+
+ it { subject.must_equal(true) }
+ end
+
+ context 'when the value is not a Hash' do
+ it { subject.must_equal(false) }
+ end
+ end
+
describe '#numeric?' do
let(:_value) {}
subject { instance.numeric?(_value) }
@@ -120,9 +214,53 @@
context 'when namespaced' do
let(:_name) { 'MyFirstApp::SomeController' }
it { subject.must_equal('my_first_app/some_controller') }
+ end
+ end
+
+ describe '#string?' do
+ let(:_value) {}
+
+ subject { instance.string?(_value) }
+
+ context 'when the value is string' do
+ let(:_value) { 'test' }
+
+ it { subject.must_equal(true) }
+ end
+
+ context 'when the value is not string' do
+ it { subject.must_equal(false) }
+ end
+ end
+
+ describe '#truthy?' do
+ subject { instance.truthy?(_value) }
+
+ context 'when the value is a TrueClass' do
+ let(:_value) { true }
+
+ it { subject.must_equal(true) }
+ end
+
+ context 'when the value is a FalseClass' do
+ let(:_value) { false }
+
+ it { subject.must_equal(false) }
+ end
+
+ context 'when the value is nil' do
+ let(:_value) {}
+
+ it { subject.must_equal(false) }
+ end
+
+ context 'when the value is anything else' do
+ let(:_value) { 'anything' }
+
+ it { subject.must_equal(true) }
end
end
end # Common