]> git.openstreetmap.org Git - rails.git/blobdiff - vendor/gems/rspec-1.1.2/spec/spec/story/step_mother_spec.rb
added RSpec and RSpec on Rails
[rails.git] / vendor / gems / rspec-1.1.2 / spec / spec / story / step_mother_spec.rb
diff --git a/vendor/gems/rspec-1.1.2/spec/spec/story/step_mother_spec.rb b/vendor/gems/rspec-1.1.2/spec/spec/story/step_mother_spec.rb
new file mode 100644 (file)
index 0000000..64efd7a
--- /dev/null
@@ -0,0 +1,72 @@
+require File.dirname(__FILE__) + '/story_helper'
+
+module Spec
+  module Story
+    describe StepMother do
+      it 'should store a step by name and type' do
+        # given
+        step_mother = StepMother.new
+        step = Step.new("a given", &lambda {})
+        step_mother.store(:given, step)
+        
+        # when
+        found = step_mother.find(:given, "a given")
+        
+        # then
+        found.should == step
+      end
+      
+      it 'should NOT raise an error if a step is missing' do
+        # given
+        step_mother = StepMother.new
+        
+        # then
+        lambda do
+          # when
+          step_mother.find(:given, "doesn't exist")
+        end.should_not raise_error
+      end
+      
+      it "should create a default step which raises a pending error" do
+        # given
+        step_mother = StepMother.new
+        
+        # when
+        step = step_mother.find(:given, "doesn't exist")
+        
+        # then
+        step.should be_an_instance_of(Step)
+        
+        lambda do
+          step.perform(Object.new, "doesn't exist")
+        end.should raise_error(Spec::Example::ExamplePendingError, /Unimplemented/)
+      end
+      
+      it 'should clear itself' do
+        # given
+        step_mother = StepMother.new
+        step = Step.new("a given") do end
+        step_mother.store(:given, step)
+
+        # when
+        step_mother.clear
+        
+        # then
+        step_mother.should be_empty
+      end
+      
+      it "should use assigned steps" do
+        step_mother = StepMother.new
+        
+        step = Step.new('step') {}
+        step_group = StepGroup.new
+        step_group.add(:given, step)
+        
+        step_mother.use(step_group)
+                
+        step_mother.find(:given, "step").should equal(step)
+      end
+
+    end
+  end
+end