aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZog2017-12-15 17:01:49 +0100
committerZog2017-12-19 17:02:37 +0100
commitc3ce5e25c3596329bd1ff9542d73354e1a2bb368 (patch)
treee26784690d9ae563e265681ddb52e453b0f96bc1
parent74da4b28490d0b8822e74ddf8a7e897d1fc24588 (diff)
downloadchouette-core-c3ce5e25c3596329bd1ff9542d73354e1a2bb368.tar.bz2
Ref #5291@2h; Specs setup
- Refactor specs helper to be more generic - Write missing specs for the Workbenches#show view We now have failing tests highlighting the bug
-rw-r--r--spec/support/integration_spec_helper.rb36
-rw-r--r--spec/views/offer_workbenches/show.html.erb_spec.rb1
2 files changed, 21 insertions, 16 deletions
diff --git a/spec/support/integration_spec_helper.rb b/spec/support/integration_spec_helper.rb
index 5bcf0bd3a..6edec2a05 100644
--- a/spec/support/integration_spec_helper.rb
+++ b/spec/support/integration_spec_helper.rb
@@ -1,26 +1,32 @@
module IntegrationSpecHelper
- def with_permission permission, &block
- context "with permission #{permission}" do
- let(:permissions){ [permission] }
- context('', &block) if block_given?
- end
+ def paginate_collection klass, decorator, page=1
+ ModelDecorator.decorate( klass.page(page), with: decorator )
+ end
- 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
- 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
+ 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|
diff --git a/spec/views/offer_workbenches/show.html.erb_spec.rb b/spec/views/offer_workbenches/show.html.erb_spec.rb
index cc01c9d0e..138a1560d 100644
--- a/spec/views/offer_workbenches/show.html.erb_spec.rb
+++ b/spec/views/offer_workbenches/show.html.erb_spec.rb
@@ -53,5 +53,4 @@ describe "workbenches/show", :type => :view do
expect(rendered).to have_box_for_item different_organisation_referential, true
end
end
-
end