Last active
December 23, 2015 21:39
-
-
Save erez-rabih/6697511 to your computer and use it in GitHub Desktop.
Rspec refactoring - initial test suite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe FindReaction do | |
#Spec 1 | |
it "should return no reaction template when there are no reaction templates" do | |
post = create :post, locale: "en", type: "basic" | |
reaction = FindReaction.for(@post).reaction | |
reaction.blank?.should == true | |
end | |
#Spec 2 | |
it "should return no reaction template if reaction templates exist, but non fitting" do | |
post = create :post, locale: "en", type: "basic" | |
reaction1 = ReactionTemplate.create locale: "de", subtypes: ["basic", "top_x"] | |
reaction2 = ReactionTemplate.create locale: "en", subtypes: ["slideshow", "top_x"] | |
reaction = FindReaction.for(@post).reaction | |
reaction.blank?.should == true | |
end | |
#Spec 3 | |
it "should return the right reaction if it exists" do | |
post = create :post, locale: "en", type: "basic" | |
reaction1 = ReactionTemplate.create locale: "en", subtypes: ["basic", "top_x"] | |
reaction2 = ReactionTemplate.create locale: "en", subtypes: ["basic", "top_x"] | |
reaction3 = ReactionTemplate.create locale: "en" , subtypes: ["slideshow", "top_x"] | |
reaction = FindReaction.for(@post).reaction | |
reaction.blank?.should == false | |
reaction.should eq reaction2 | |
end | |
#Spec 4 | |
it "should change posts reaction_template when attaching it" do | |
post = create :post, locale: "en", type: "basic" | |
post.reaction_template.nil?.should == true | |
reaction = ReactionTemplate.create locale: "en", subtypes: ["basic", "top_x"] | |
FindReaction.for(post).attach | |
post.reaction_template.nil?.should == false | |
post.reaction_template.should eq reaction | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment