do some cleanup on gem test runs

* add test runner for broadcast_policy and fix a couple of tests that
  had been broken by accident
* add test runner for canvas_quiz_statistics and add a reference to
  iconv to it's Gemfile to allow tests to run in ruby 2
* add a test runner for canvas_sanitize
* remove leftover cruft from running gem builds in both rails 2 and 3

Change-Id: Iab2a0986f277a82c096e1fff2dab1d3a55b91733
Reviewed-on: https://gerrit.instructure.com/54518
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
Simon Williams 2015-05-18 14:05:54 -06:00
parent 1fa2ded491
commit 72415e8460
19 changed files with 64 additions and 43 deletions

View File

@ -2,7 +2,6 @@
result=0
echo "################ active_polymorph ################"
echo "################ Running tests against Rails 3 ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?

View File

@ -2,12 +2,9 @@
result=0
echo "################ activesupport-suspend_callbacks ################"
echo "################ Running tests against Rails 3 ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?
mv Gemfile.lock.rails2 Gemfile.lock
if [ $result -eq 0 ]; then
echo "SUCCESS"

View File

@ -2,12 +2,9 @@
result=0
echo "################ adheres_to_policy ################"
echo "################ Running tests against Rails 3 ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?
mv Gemfile.lock.rails2 Gemfile.lock
if [ $result -eq 0 ]; then
echo "SUCCESS"

View File

@ -2,12 +2,9 @@
result=0
echo "################ bookmarked_collection ################"
echo "################ Running tests against Rails 3 ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?
mv Gemfile.lock.rails2 Gemfile.lock
if [ $result -eq 0 ]; then
echo "SUCCESS"

View File

@ -40,12 +40,12 @@ module BroadcastPolicy
notification = BroadcastPolicy.notification_finder.by_name(self.dispatch)
return if notification.nil?
to_list = record.instance_eval &self.to
to_list = Array[to_list].flatten
to_list = record.instance_eval(&self.to)
to_list = Array(to_list).flatten
return if to_list.empty?
asset_context = record.instance_eval &self.context if self.context
data = record.instance_eval &self.data if self.data
asset_context = record.instance_eval(&self.context) if self.context
data = record.instance_eval(&self.data) if self.data
BroadcastPolicy.notifier.send_notification(
record,

View File

@ -30,29 +30,29 @@ describe BroadcastPolicy::NotificationPolicy do
it "should not send if conditions are not met" do
record = double('test object', skip_broadcasts: false)
subject.whenever = ->(r) { false }
subject.whenever = ->(_) { false }
subject.broadcast(record)
expect(BroadcastPolicy.notifier.messages).to be_empty
end
it "should not send if there is not a recipient list" do
record = double('test object', skip_broadcasts: false)
subject.to = ->(r) { nil }
subject.to = ->(_) { nil }
subject.broadcast(record)
expect(BroadcastPolicy.notifier.messages).to be_empty
end
it "should not send if there isn't a proper context" do
it "should send even if there isn't a context" do
record = double('test object', skip_broadcasts: false)
subject.context = ->(r) { raise Error.new }
subject.context = ->(_) { nil }
subject.broadcast(record)
expect(BroadcastPolicy.notifier.messages).to be_empty
expect(BroadcastPolicy.notifier.messages).to_not be_empty
end
it "should not send if there isn't proper data" do
it "should send even if there isn't data" do
record = double('test object', skip_broadcasts: false)
subject.data = ->(r) { raise Error.new }
subject.data = ->(_) { nil }
subject.broadcast(record)
expect(BroadcastPolicy.notifier.messages).to be_empty
expect(BroadcastPolicy.notifier.messages).to_not be_empty
end
end

15
gems/broadcast_policy/test.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
result=0
echo "################ broadcast_policy ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?
if [ $result -eq 0 ]; then
echo "SUCCESS"
else
echo "FAILURE"
fi
exit $result

View File

@ -2,7 +2,6 @@
result=0
echo "################ canvas_ext ################"
echo "################ Running tests against Rails 3 ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?

View File

@ -1,8 +1,12 @@
source 'https://rubygems.org'
gemspec
gem 'simplecov', '0.8.2', :require => false
gem 'simplecov-rcov', '0.2.3', :require => false
gem 'canvas_text_helper', :path => '../canvas_text_helper'
gem 'html_text_helper', :path => '../html_text_helper'
gemspec
platforms :ruby_20, :ruby_21 do
gem 'iconv', '1.0.4'
end

View File

@ -0,0 +1,15 @@
#!/bin/bash
result=0
echo "################ canvas_quiz_statistics ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?
if [ $result -eq 0 ]; then
echo "SUCCESS"
else
echo "FAILURE"
fi
exit $result

15
gems/canvas_sanitize/test.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
result=0
echo "################ canvas_sanitize ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?
if [ $result -eq 0 ]; then
echo "SUCCESS"
else
echo "FAILURE"
fi
exit $result

View File

@ -2,13 +2,10 @@
result=0
echo "################ canvas_stringex ################"
echo "################ Running tests against Rails 3 ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?
bundle exec rake refresh_db
mv Gemfile.lock.rails2 Gemfile.lock
if [ $result -eq 0 ]; then
echo "SUCCESS"

View File

@ -1,12 +1,10 @@
#!/bin/bash
result=0
echo "################ Running tests against Rails 3 ################"
echo "################ canvas_time ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?
mv Gemfile.lock.rails2 Gemfile.lock
if [ $result -eq 0 ]; then
echo "SUCCESS"

View File

@ -1,7 +1,7 @@
#!/bin/bash
result=0
echo "################ Running tests against Rails 3 ################"
echo "################ event_stream ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?

View File

@ -2,7 +2,6 @@
result=0
echo "################ html_text_helper ################"
echo "################ Running tests against Rails 3 ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?

View File

@ -2,12 +2,9 @@
result=0
echo "################ i18n_extraction ################"
echo "################ Running tests against Rails 3 ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?
mv Gemfile.lock.rails2 Gemfile.lock
if [ $result -eq 0 ]; then
echo "SUCCESS"

View File

@ -2,12 +2,9 @@
result=0
echo "################ i18n_tasks ################"
echo "################ Running tests against Rails 3 ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?
mv Gemfile.lock.rails2 Gemfile.lock
if [ $result -eq 0 ]; then
echo "SUCCESS"

View File

@ -2,11 +2,9 @@
result=0
echo "################ incoming_mail_processor ################"
echo "################ Running tests against Rails 3 ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?
mv Gemfile.lock.rails2 Gemfile.lock
if [ $result -eq 0 ]; then
echo "SUCCESS"

View File

@ -2,12 +2,9 @@
result=0
echo "################ paginated_collection ################"
echo "################ Running tests against Rails 3 ################"
bundle check || bundle install
bundle exec rspec spec
let result=$result+$?
mv Gemfile.lock.rails2 Gemfile.lock
if [ $result -eq 0 ]; then
echo "SUCCESS"