changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/spec/spec/story/step_mother_spec.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1require File.dirname(__FILE__) + '/story_helper'
2
3module Spec
4 module Story
5 describe StepMother do
6 it 'should store a step by name and type' do
7 # given
8 step_mother = StepMother.new
9 step = Step.new("a given", &lambda {})
10 step_mother.store(:given, step)
11
12 # when
13 found = step_mother.find(:given, "a given")
14
15 # then
16 found.should == step
17 end
18
19 it 'should NOT raise an error if a step is missing' do
20 # given
21 step_mother = StepMother.new
22
23 # then
24 lambda do
25 # when
26 step_mother.find(:given, "doesn't exist")
27 end.should_not raise_error
28 end
29
30 it "should create a default step which raises a pending error" do
31 # given
32 step_mother = StepMother.new
33
34 # when
35 step = step_mother.find(:given, "doesn't exist")
36
37 # then
38 step.should be_an_instance_of(Step)
39
40 lambda do
41 step.perform(Object.new, "doesn't exist")
42 end.should raise_error(Spec::Example::ExamplePendingError, /Unimplemented/)
43 end
44
45 it 'should clear itself' do
46 # given
47 step_mother = StepMother.new
48 step = Step.new("a given") do end
49 step_mother.store(:given, step)
50
51 # when
52 step_mother.clear
53
54 # then
55 step_mother.should be_empty
56 end
57
58 it "should use assigned steps" do
59 step_mother = StepMother.new
60
61 step = Step.new('step') {}
62 step_group = StepGroup.new
63 step_group.add(:given, step)
64
65 step_mother.use(step_group)
66
67 step_mother.find(:given, "step").should equal(step)
68 end
69
70 end
71 end
72end