Sha256: f198cbad5456d373da9d8d12b9591a74fdc0c136c37f1fb531aeb2ca508a57e0
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
require 'spec_helper' describe SeemsRateable::Helpers::ActionViewExtension, type: :feature do let(:user) { FactoryGirl.create(:user) } let(:rateable) { DummyModel.create } let(:view) { DummyView.new } describe "#rating_for" do context "valid rateable object" do before do DummyModel.seems_rateable end it "builds a new voting" do SeemsRateable::Builder.should_receive(:build).with(rateable, an_instance_of(Hash)) view.rating_for rateable end describe "disabled rating" do shared_examples "passing disabled true" do |options={}| it "passes disabled: true as an option" do SeemsRateable::Builder.should_receive(:build).with(rateable, hash_including(disabled: true)) view.rating_for rateable, options end end context "when no current rater" do it_behaves_like "passing disabled true" end context "when user has already rated" do let(:rate) { FactoryGirl.create(:rate, rateable: rateable) } before do DummyView.stub(:current_rater).and_return(rate.rater) end it_behaves_like "passing disabled true" end context "when it is given explicitly" do before do DummyView.stub(:current_rater).and_return(user) end it_behaves_like "passing disabled true", disabled: true end end end context "invalid rateable object" do it "raises an InvalidRateableError" do expect { view.rating_for "wtf?" }.to raise_error(SeemsRateable::Errors::InvalidRateableError) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
seems_rateable-2.0.0 | spec/helpers/action_view_extension_spec.rb |