Below is the test code that currently fails. The three lines of issue.expects
expect that the three methods :project_id=
, :tracker_id=
, and :subject=
are called in this order. However, it is :subject=
that is called first because issue.attributes = {:subject => 'Test'}
is executed first. It is curious that this code worked with Mocha 2.1.
def test_assigning_attributes_should_assign_project_and_tracker_first
seq = sequence('seq')
issue = Issue.new
issue.expects(:project_id=).in_sequence(seq)
issue.expects(:tracker_id=).in_sequence(seq)
issue.expects(:subject=).in_sequence(seq)
assert_raise Exception do
issue.attributes = {:subject => 'Test'}
end
assert_nothing_raised do
issue.attributes = {:tracker_id => 2, :project_id => 1, :subject => 'Test'}
end
end
The error can be fixed simply removing issue.attributes = {:subject => 'Test'}
.
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 599c0046d..21a295aa1 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -707,9 +707,6 @@ class IssueTest < ActiveSupport::TestCase
issue.expects(:project_id=).in_sequence(seq)
issue.expects(:tracker_id=).in_sequence(seq)
issue.expects(:subject=).in_sequence(seq)
- assert_raise Exception do
- issue.attributes = {:subject => 'Test'}
- end
assert_nothing_raised do
issue.attributes = {:tracker_id => 2, :project_id => 1, :subject => 'Test'}
end