Permalink
Browse files

Instead of stubbing invalid thing do it for realz

This test was unnecessarily dependent on the internal implementation of the
method under test. Instead of stubbing out Active Record calls, just create the
real data conditions we want, i.e. an invalid featuring.
  • Loading branch information...
1 parent d6cc6ba commit 70167aa9872ffcc8b16b4270e0474f5e6cc05c98 @tekin tekin committed with heathd Jan 15, 2015
Showing with 3 additions and 5 deletions.
  1. +3 −5 test/unit/feature_list_test.rb
@@ -48,11 +48,9 @@ class FeatureListTest < ActiveSupport::TestCase
f1 = create(:feature)
feature_list = create(:feature_list, locale: :en, features: [f1])
f1.document = nil
- Mocha::Configuration.allow(:stubbing_non_existent_method) do
- feature_list.features.stubs(:find_by!).with(id: f1.id).returns(f1)
- refute feature_list.reorder!([f1.id])
- assert_match /Can't reorder because '.*'/, feature_list.errors.full_messages.to_sentence
- end
+ f1.save(validate: false)
+ refute feature_list.reorder!([f1.id])
+ assert_match /Can't reorder because '.*'/, feature_list.errors.full_messages.to_sentence
end
test "reordering fails if features which are not part of the feature list are referenced when re-ordering" do

0 comments on commit 70167aa

Please sign in to comment.