shared_examples "State Machine updateable event (concerns)" do unless described_class.method_defined? :blah described_class.class_eval do state_machine :state, initial: :pending do state :pending, :blahhed event :blah do transition any => :blahhed end end end end subject { described_class.new } it { should respond_to :event= } describe "#event=" do it "should not trigger non-existing state machine event" do subject.should_receive(:blah!) subject.event = :blah subject.blahhed? end it "should trigger state machine event" do subject.should_not_receive(:noblah!) subject.event = :noblah end end end