diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 596dda8c..3e8682a3 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -9,15 +9,13 @@ end describe "GET, index" do - it "should have a list of stories" do - Story.should_receive(:paginate). - with(:page => "1", :per_page => 5) + it "gets a paginated list of stories" do + Story.should_receive(:paginate).with(:page => "1", :per_page => 5) get :index, {:page => 1} end end describe "POST, create" do - before(:each) do Story.stub(:new).and_return @story end @@ -27,25 +25,20 @@ @story.stub(:save).and_return true end - it "should create a new story" do + it "gets a new story" do Story.should_receive(:new). with("scenario" => "a new scenario").and_return @story post :create, :story => {"scenario" => "a new scenario"} end - it "should save the story" do + it "is saved" do @story.should_receive(:save).and_return true post :create, :story => @story end - it "should display a flash[:notice] message" do - post :create - flash[:notice].should contain "Story: #{@story.scenario}, was created" - end - - it "should save the story" do + it "displays a flash notice message" do post :create - response.should be_success + flash[:notice].should_not be_empty end end @@ -54,7 +47,7 @@ Story.stub(:save).and_return false end - it "should render the new template" do + it "renders the new template" do post :create response.should render_template("new") end @@ -66,12 +59,12 @@ Story.stub(:find).and_return @story end - it "should find the current story" do + it "finds the current story" do Story.should_receive(:find).and_return @story get :show, {:id => @story.id} end - it "should have a list of associated steps" do + it "gets a list of associated steps" do @story.should_receive(:steps) get :show end @@ -82,7 +75,7 @@ Story.stub(:find).and_return @story end - it "should find the current story" do + it "finds the current story" do Story.should_receive(:find).and_return @story get :show, {:id => @story.id} end @@ -96,17 +89,17 @@ end end - context "is associated with a feature" do + context "associated to a feature" do before(:each) do @feature = mock_model(Feature, :stories => mock_model(Story).as_null_object).as_null_object Feature.stub(:find).and_return @feature end - it "should find the associated feature" do + it "finds the associated feature" do get :new, {:feature_id => 1} end - it "should create a new story, associated to the feature" do + it "creates a new story" do @feature.stories.should_receive(:new) get :new, {:feature_id => 1} end @@ -118,38 +111,33 @@ Story.stub(:find).and_return @story end - context "successful" do + context "is successful" do before(:each) do @story.stub(:update_attributes).and_return true end - it "should update the story" do + it "updates the story" do @story.should_receive(:update_attributes).with(@story).and_return true post :update, {:story => @story} end - it "should display a flash[:notice] message" do + it "displays a flash notice message" do post :update, {:story => @story} - flash[:notice].should contain "Story: #{@story.scenario} was updated" - end - - it "should updat the story" do - post :update, {:story => @story} - response.should be_success + flash[:notice].should_not be_empty end end - context "unsucessful" do + context "is unsucessful" do before(:each) do @story.stub(:update_attributes).and_return false end - it "should display a flash[:error] message" do + it "displays a flash error message" do post :update, :story => @story - flash[:error].should contain "Story: #{@story.scenario} was not created" + flash[:error].should_not be_empty end - it "should render the edit template" do + it "renders the edit template" do post :update, :story => @story response.should render_template(:edit) end @@ -160,12 +148,13 @@ before(:each) do Story.stub(:find).and_return @story end - it "should delete the story" do + + it "deletes the story" do @story.should_receive :destroy delete :destroy end - it "should redirect to the stories index page" do + it "redirects to the stories page" do delete :destroy response.should redirect_to stories_path end @@ -176,30 +165,30 @@ Story.stub(:find).and_return @story end - it "should have the stories associated steps" do + it "is associated to steps" do @story.should_receive(:steps) get :steps end end describe "GET, sort" do - it "should loop through each of the stories" do + it "loops through each of the stories" do @story.should_receive(:each_with_index) get :sort, :story => @story end - it "should update all stories attributes" do + it "updates all stories" do @story.each { |story| story.should_receive(:update_all)} end end describe "GET, tag" do - it "should have a list of stories associated with the given tag" do + it "has a list of stories that have the liked to a tag" do Story.should_receive :find_tagged_with get :tag, {:tag => 'Given'} end - it "should render the index page" do + it "renders the index template" do get :tag, {:tag => 'Given'} response.should render_template :index end @@ -210,23 +199,23 @@ Step.stub(:search).and_return [1,2,3] end - it "should search for steps with the given search string" do + it "searches for steps" do Step.should_receive(:search).with('Given') get :add_step, {:search_text => 'Given'} end - context "is a new story" do - it "should redirect to the new story form" do + context "a new story" do + it "redirects to the new story form" do get :add_step, {:search_text => 'Given'} response.should redirect_to new_story_path(:step_ids => [1,2,3]) end end - context "are editing a story" do + context "editing a story" do before(:each) do Story.stub(:find).and_return @story end - it "should redirect to the edit story form" do + it "redirects to the edit story" do get :add_step, {:id => 1, :search_text => 'Given'} response.should redirect_to edit_story_path(:step_ids => [1,2,3]) end