aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support
diff options
context:
space:
mode:
authorLuc Donnet2017-12-19 17:39:29 +0100
committerGitHub2017-12-19 17:39:29 +0100
commitdb4c94186ce8a5b52cc5c2b54fe84899729cbfa6 (patch)
treeb6c0a3c3c9290022177e1b9cd44c91f361cd7644 /spec/support
parent84739968d68c561f6317b9fa21a476dc0dcb240b (diff)
parent12924f238cc02a671a4c535b49320cd3b0ce7302 (diff)
downloadchouette-core-db4c94186ce8a5b52cc5c2b54fe84899729cbfa6.tar.bz2
Merge pull request #153 from af83/5291-disable-useless-checkboxes-on-referentials-index
5291 disable useless checkboxes on referentials index
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/integration_spec_helper.rb47
1 files changed, 42 insertions, 5 deletions
diff --git a/spec/support/integration_spec_helper.rb b/spec/support/integration_spec_helper.rb
index 182cadf24..78efb9027 100644
--- a/spec/support/integration_spec_helper.rb
+++ b/spec/support/integration_spec_helper.rb
@@ -1,12 +1,49 @@
module IntegrationSpecHelper
- def with_permission permission, &block
- context "with permission #{permission}" do
- let(:permissions){ [permission] }
- context('', &block) if block_given?
+
+ def paginate_collection klass, decorator, page=1
+ ModelDecorator.decorate( klass.page(page), with: decorator )
+ end
+
+ def build_paginated_collection factory, decorator, opts={}
+ count = opts.delete(:count) || 2
+ page = opts.delete(:page) || 1
+ klass = nil
+ count.times { klass ||= create(factory, opts).class }
+ paginate_collection klass, decorator, page
+ end
+
+ module Methods
+ def with_permission permission, &block
+ context "with permission #{permission}" do
+ let(:permissions){ [permission] }
+ context('', &block) if block_given?
+ end
end
end
+
+ def self.included into
+ into.extend Methods
+ end
end
RSpec.configure do |config|
- config.extend IntegrationSpecHelper, type: :view
+ config.include IntegrationSpecHelper, type: :view
+end
+
+RSpec::Matchers.define :have_link_for_each_item do |collection, name, href|
+ match do |actual|
+ collection.each do |item|
+ expect(rendered).to have_selector("tr.#{TableBuilderHelper.item_row_class_name(collection)}-#{item.id} .actions a[href='#{href.call(item)}']", count: 1)
+ end
+ end
+ description { "have #{name} link for each item" }
+end
+
+RSpec::Matchers.define :have_the_right_number_of_links do |collection, count|
+ match do |actual|
+ collection.each do |item|
+ expect(rendered).to have_selector("tr.#{TableBuilderHelper.item_row_class_name(collection)}-#{item.id} .actions a", count: count)
+ end
+ end
+ description { "have #{count} links for each item" }
end