Module: Appfuel::TestingSpec::Helpers
- Defined in:
- lib/appfuel/testing_spec/helpers.rb
Instance Method Summary collapse
- #allow_const_defined(mod, name, result) ⇒ Object
- #allow_const_defined_as_false(mod, name) ⇒ Object
- #allow_const_defined_as_true(mod, name) ⇒ Object
- #allow_const_get(mod, name, result) ⇒ Object
- #allow_db_column_names(db_class, cols) ⇒ Object
- #allow_db_entity_attributes(db_class, hash) ⇒ Object
- #allow_db_type(name, type) ⇒ Object
- #allow_domain_type(name, type) ⇒ Object
- #allow_type(name, type) ⇒ Object
- #build_container(data = {}) ⇒ Object
- #mock_db_class(name, cols = []) ⇒ Object
Instance Method Details
#allow_const_defined(mod, name, result) ⇒ Object
12 13 14 |
# File 'lib/appfuel/testing_spec/helpers.rb', line 12 def allow_const_defined(mod, name, result) allow(mod).to receive(:const_defined?).with(name) { result } end |
#allow_const_defined_as_false(mod, name) ⇒ Object
8 9 10 |
# File 'lib/appfuel/testing_spec/helpers.rb', line 8 def allow_const_defined_as_false(mod, name) allow_const_defined(mod, name, false) end |
#allow_const_defined_as_true(mod, name) ⇒ Object
4 5 6 |
# File 'lib/appfuel/testing_spec/helpers.rb', line 4 def allow_const_defined_as_true(mod, name) allow_const_defined(mod, name, true) end |
#allow_const_get(mod, name, result) ⇒ Object
16 17 18 |
# File 'lib/appfuel/testing_spec/helpers.rb', line 16 def allow_const_get(mod, name, result) allow(mod).to receive(:const_get).with(name) { result } end |
#allow_db_column_names(db_class, cols) ⇒ Object
45 46 47 |
# File 'lib/appfuel/testing_spec/helpers.rb', line 45 def allow_db_column_names(db_class, cols) allow(db_class).to receive(:column_names).with(no_args) { cols } end |
#allow_db_entity_attributes(db_class, hash) ⇒ Object
49 50 51 |
# File 'lib/appfuel/testing_spec/helpers.rb', line 49 def allow_db_entity_attributes(db_class, hash) allow(db_class).to receive(:entity_attributes).with(no_args) { hash } end |
#allow_db_type(name, type) ⇒ Object
40 41 42 43 |
# File 'lib/appfuel/testing_spec/helpers.rb', line 40 def allow_db_type(name, type) allow(Types::Db).to receive(:key?).with(name) { true } allow(Types::Db).to receive(:[]).with(name) { type } end |
#allow_domain_type(name, type) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/appfuel/testing_spec/helpers.rb', line 32 def allow_domain_type(name, type) basename = name.to_s.split('.').last allow_type(name, type) allow(type).to receive(:domain_name).with(no_args) { name } allow(type).to receive(:domain_basename).with(no_args) { basename } type end |
#allow_type(name, type) ⇒ Object
26 27 28 29 30 |
# File 'lib/appfuel/testing_spec/helpers.rb', line 26 def allow_type(name, type) allow(Types).to receive(:key?).with(name) { true } allow(Types).to receive(:[]).with(name) { type } type end |
#build_container(data = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/appfuel/testing_spec/helpers.rb', line 20 def build_container(data = {}) container = Dry::Container.new data.each {|key, value| container.register(key, value)} container end |
#mock_db_class(name, cols = []) ⇒ Object
53 54 |
# File 'lib/appfuel/testing_spec/helpers.rb', line 53 def mock_db_class(name, cols = []) end |