require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") describe Cardflex::BaseModule do class TestClass include Cardflex::BaseModule module Type A = 'a' B = 'b' C = 'c' end end it 'should assign instance variables from a hash' do TestClass.set_instance_variables_from_hash({ :test => 'value' }) expect(TestClass.instance_variables).to include :@test expect(TestClass.instance_variable_get("@test")).to eq 'value' end it 'should preserve nested hashes' do TestClass.set_instance_variables_from_hash({ :test => { :nest => 'nested' }}) expect(TestClass.instance_variable_get("@test")).to eq({ :nest => 'nested' }) end it 'should snake case a string' do expect(TestClass.snakecase('dash-case-variable')).to eq('dash_case_variable') end it 'should create helper methods' do TestClass.__send__(:create_helper_methods, TestClass::Type) expect(TestClass.methods).to include(:a, :b, :c) end end