end it("should have a default author") do Post.new.author.should eql "remi" end end class Post < OpenStruct def published? self.published == true end def author self.author || "remi" end end
be_published? } its(:author) { should eql "remi" } end class Post < OpenStruct def published? self.published == true end def author self.author || "remi" end end
should_not be_published? } its(:author) { should eql "jack" } end class Post < OpenStruct def published? self.published == true end def author self.author end end
User.new(first_name: "Rémi") } its(:author_name) { should eql user.first_name } end class Post < OpenStruct def author_name self.author.first_name end end
Post..." end before :each do ActionMailer::Base.deliveries.clear DatabaseCleaner.clear end it { should_not be_published } its(:author) { should be_nil } end
context "with empty parameters" do let(:parameters) { {} } it { should_not be_valid? } end context "with valid parameters" do let(:parameters) { { title: "Hello world." } } it { should be_valid? } end end end
:author do before do a = OpenStruct.new(full_name: "Rémi Prévost") Author.stubs(:find).and_return(a) end its(:author) { should eql "Rémi Prévost" } end end class Post < OpenStruct def author Author.find(self.author_id).full_name end end
:author do before do a = OpenStruct.new(full_name: "Rémi Prévost") Author.should_receive(:find).with(4).and_return(a) end its(:author) { should eql "Rémi Prévost" } end end class Post < OpenStruct def author Author.find(self.author_id).full_name end end