Module: Chef::DSL::DataQuery
- Defined in:
- lib/chefspec/extensions/chef/data_query.rb
Instance Method Summary collapse
- #data_bag(bag) ⇒ Object
- #data_bag_item(bag, id) ⇒ Object
- #old_data_bag ⇒ Object
- #old_data_bag_item ⇒ Object
- #old_search ⇒ Object
- #search(*args, &block) ⇒ Object
Instance Method Details
#data_bag(bag) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/chefspec/extensions/chef/data_query.rb', line 22 def data_bag(bag) return old_data_bag(bag) unless Chef::Config[:solo] stub = ChefSpec::Stubs::DataBagRegistry.stub_for(bag) if stub.nil? raise ChefSpec::Error::DataBagNotStubbed.new(args: [bag]) end stub.result end |
#data_bag_item(bag, id) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/chefspec/extensions/chef/data_query.rb', line 36 def data_bag_item(bag, id) return old_data_bag_item(bag, id) unless Chef::Config[:solo] stub = ChefSpec::Stubs::DataBagItemRegistry.stub_for(bag, id) if stub.nil? raise ChefSpec::Error::DataBagItemNotStubbed.new(args: [bag, id]) end stub.result end |
#old_data_bag ⇒ Object
21 |
# File 'lib/chefspec/extensions/chef/data_query.rb', line 21 alias_method :old_data_bag, :data_bag |
#old_data_bag_item ⇒ Object
35 |
# File 'lib/chefspec/extensions/chef/data_query.rb', line 35 alias_method :old_data_bag_item, :data_bag_item |
#old_search ⇒ Object
5 |
# File 'lib/chefspec/extensions/chef/data_query.rb', line 5 alias_method :old_search, :search |
#search(*args, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/chefspec/extensions/chef/data_query.rb', line 6 def search(*args, &block) return old_search(*args, &block) unless Chef::Config[:solo] type = args[0] query = args[1] || '*:*' stub = ChefSpec::Stubs::SearchRegistry.stub_for(type, query) if stub.nil? raise ChefSpec::Error::SearchNotStubbed.new(args: [type, query]) end stub.result end |