spec/hibachi/recipe_spec.rb in hibachi-0.0.1.pre vs spec/hibachi/recipe_spec.rb in hibachi-0.0.1

- old
+ new

@@ -1,32 +1,55 @@ require 'spec_helper' require 'hibachi/recipe' module Hibachi describe Recipe do - class MockForRecipe < Hibachi::Model - recipe :name_of_recipe, :type => :singleton + context "with a singleton setting" do + subject { SingletonSetting } - attr_accessor :name - end + it "sets the recipe in the class definition" do + expect(subject.recipe_name).to eq(:singleton_settings) + end - it "sets the recipe in the class definition" do - expect(MockForRecipe.recipe_name).to eq(:name_of_recipe) - end + it "sets the type of recipe in the class definition" do + expect(subject.recipe_type).to eq('singleton') + end - it "sets the type of recipe in the class definition" do - expect(MockForRecipe.recipe_type).to eq('singleton') - end + it "is a singleton" do + expect(subject).to be_singleton + end - it "is a singleton" do - expect(MockForRecipe).to be_singleton + context "with an instantiated setting" do + let(:setting) { subject.new name: 'test' } + + it "is a singleton" do + expect(setting).to be_singleton + end + end end - context "with an instantiated singleton" do - subject { MockForRecipe.new name: 'test' } + context "with a collection setting" do + subject { MockSetting } - it "is a singleton" do - expect(subject).to be_singleton + it "sets the recipe in the class definition" do + expect(subject.recipe_name).to eq(:mock_settings) end + + it "sets the type of recipe in the class definition" do + expect(subject.recipe_type).to eq('collection') + end + + it "is a collection" do + expect(subject).to be_collection + end + + context "with an instantiated setting" do + let(:setting) { subject.new name: 'test' } + + it "is a collection" do + expect(setting).to be_collection + end + end end + end end