aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--spec/models/info_request_spec.rb4
-rw-r--r--spec/models/user_spec.rb8
-rw-r--r--spec/spec_helper.rb8
3 files changed, 14 insertions, 6 deletions
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index d50d6dace..543c07699 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -380,8 +380,8 @@ describe InfoRequest do
before do
Time.stub!(:now).and_return(Time.utc(2007, 11, 9, 23, 59))
- @mock_comment_event = mock_model(InfoRequestEvent, :created_at => Time.now - 23.days, :event_type => 'comment')
- @mock_response_event = mock_model(InfoRequestEvent, :created_at => Time.now - 22.days, :event_type => 'response')
+ @mock_comment_event = safe_mock_model(InfoRequestEvent, :created_at => Time.now - 23.days, :event_type => 'comment')
+ @mock_response_event = safe_mock_model(InfoRequestEvent, :created_at => Time.now - 22.days, :event_type => 'response')
@info_request = InfoRequest.new(:prominence => 'normal',
:awaiting_description => true,
:info_request_events => [@mock_response_event, @mock_comment_event])
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 751a61060..7d68c978b 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -152,10 +152,10 @@ end
describe User, "when reindexing referencing models" do
before do
- @request_event = mock_model(InfoRequestEvent, :xapian_mark_needs_index => true)
- @request = mock_model(InfoRequest, :info_request_events => [@request_event])
- @comment_event = mock_model(InfoRequestEvent, :xapian_mark_needs_index => true)
- @comment = mock_model(Comment, :info_request_events => [@comment_event])
+ @request_event = safe_mock_model(InfoRequestEvent, :xapian_mark_needs_index => true)
+ @request = safe_mock_model(InfoRequest, :info_request_events => [@request_event])
+ @comment_event = safe_mock_model(InfoRequestEvent, :xapian_mark_needs_index => true)
+ @comment = safe_mock_model(Comment, :info_request_events => [@comment_event])
@user = User.new(:comments => [@comment], :info_requests => [@request])
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index ffe48c731..36bf50002 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -147,6 +147,14 @@ if $tempfilecount.nil?
end
end
+# to_ary differs in Ruby 1.8 and 1.9
+# @see http://yehudakatz.com/2010/01/02/the-craziest-fing-bug-ive-ever-seen/
+def safe_mock_model(model, args = {})
+ mock = mock_model(model, args)
+ mock.should_receive(:to_ary).any_number_of_times
+ mock
+end
+
def load_raw_emails_data(raw_emails)
raw_email = raw_emails(:useless_raw_email)
begin