Sha256: f082920332dc148b19e595d993c2e03d249c22308b701e5c79ea2e3c12632c48
Contents?: true
Size: 1.56 KB
Versions: 18
Compression:
Stored size: 1.56 KB
Contents
module ActiveModelBehavior share_as :AnActiveModel do def be_a_boolean ::Rspec::Matchers::Matcher.new :be_a_boolean do match do |value| [ true, false ].include?( value ) end end end it { should respond_to(:to_model) } it { should respond_to(:to_key) } it { should respond_to(:to_param) } it { should respond_to(:valid?) } its(:valid?) { should be_a_boolean } it { should respond_to(:persisted?) } its(:persisted?) { should be_a_boolean } its(:class) { should respond_to(:model_name) } context "the model name" do subject do described_class.model_name end it { should be_kind_of(String) } its(:human) { should be_kind_of(String) } its(:partial_path) { should be_kind_of(String) } its(:singular) { should be_kind_of(String) } its(:plural) { should be_kind_of(String) } end context "when its not persisted" do subject do obj = described_class.new obj.stub!(:persisted?).and_return(false) obj end its(:to_key) { should be_nil } its(:to_param) { should be_nil } end it { should respond_to(:errors) } context "errors" do subject do described_class.new.errors end it { should respond_to(:[]) } it { should respond_to(:full_messages) } context "[:hello]" do it { subject[:hello].should be_an_instance_of(Array) } its(:full_messages) { should be_an_instance_of(Array) } end end end end
Version data entries
18 entries across 18 versions & 1 rubygems