Sha256: c718b7d04e06124df3682288fd0d5943919e0969709689c1b7bea69b571434e7
Contents?: true
Size: 910 Bytes
Versions: 2
Compression:
Stored size: 910 Bytes
Contents
def setup_instances instances.create random_values_for_attributes instances.create random_values_for_attributes stub_instances_total_pages example.metadata[:min_pages] end def instances example.metadata[:resource_name].singularize.constantize end def assert_instances(json) expect(json).not_to be_empty end def existing(key) -> { instances.pluck(key).first } end def unknown(key) keys = 0.downto(-Float::INFINITY).lazy -> { keys.reject {|value| instances.exists? key => value}.first } end def apply(method_name, options = {}) proc = options[:to] -> { proc.call.send method_name } end def stub_instances_total_pages(total_pages) return unless instances.respond_to?(:page) and total_pages.present? page_method = instances.method :page instances.stub(:page) do |page| page_method.call(page).tap do |proxy| proxy.stub(:total_pages).and_return total_pages end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rspec-api-0.0.3 | lib/rspec-api/instances_helper.rb |
rspec-api-0.0.2 | lib/rspec-api/instances_helper.rb |