0
考慮以下代碼片段:如何重構這個rails規範?
context 'votes' do
it { should_not be_able_to :vote_yes, create(:question, user: user), user: user }
it { should be_able_to :vote_yes, create(:question, user: other_user), user: user }
it { should_not be_able_to :vote_no, create(:question, user: user), user: user }
it { should be_able_to :vote_no, create(:question, user: other_user), user: user }
it { should_not be_able_to :reject_vote, create(:question, user: user), user: user }
it { should be_able_to :reject_vote, create(:question, user: other_user), user: user }
it { should_not be_able_to :vote_yes, create(:answer, user: user), user: user }
it { should be_able_to :vote_yes, create(:answer, user: other_user), user: user }
it { should_not be_able_to :vote_no, create(:answer, user: user), user: user }
it { should be_able_to :vote_no, create(:answer, user: other_user), user: user }
it { should_not be_able_to :reject_vote, create(:answer, user: user), user: user }
it { should be_able_to :reject_vote, create(:answer, user: other_user), user: user }
end
如何重構到的東西用更少的線條和重複?
另外爲了將來的參考,這樣的問題更適合[代碼評論](http://codereview.stackexchange.com/)StackExchange網站。 –