done : http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/350
Thanks for your great work.
On Mar 25, 1:00 pm, "David Chelimsky" <[EMAIL PROTECTED]> wrote:
> On Tue, Mar 25, 2008 at 6:31 AM, Bastien <[EMAIL PROTECTED]> wrote:
> > Of course, here you go :
>
> > steps_for(:work_area_execution) do
>
> > Given("a company") do
> > @account = Factory.create_valid_account()
> > end
>
> > Given("$amount questions?") do |amount|
> > Question.delete_all
> > category = Factory.create_valid_category
> > work_area = Factory.create_valid_work_area(category)
> > amount.to_i.times do
> > Factory.create_valid_questions(work_area)
> > end
> > end
>
> > Given("a department") do
> > @department = Factory.create_valid_department(:account_id =>
> > @account.id)
> > end
>
> > Given("a number of replies") do
> > @replies = Reply.find(:all).size
> > end
>
> > Given("the logged in user $email") do |email|
> > @user = Factory.create_valid_user(:email=>email, :department_id =>
> > @department.id, :account_id => @account.id)
> > @user_profiles = Profile.find(:all, :conditions => ['user_id
> > = ?',@user.id]).size
> > host! "company.example.com"
> > post "sessions",
> > {:login => email,
> > :password => "bacon"}
> > follow_redirect! if redirect?
> > end
>
> > When("the user starts a new profile") do
> > post person_profiles_path(@user)
> > follow_redirect! if redirect?
> > end
>
> > When("the user answers a question") do
> > q = Question.find(session[:current_question]) # doesn't work with
> > GivenScenario
> > w = q.work_area
> > c = w.category
>
> > post profile_question_answers_path(@user.profiles.first, q.id),
> > { 'reply[current]' => 4,
> > 'reply[work_area_id]' => w.id,
> > 'reply[question_id]' =>q.id,
> > 'reply[category_id]'=> c.id,
> > 'reply[base]' => nil, }
> > follow_redirect! if redirect?
> > end
>
> > Then("there should be a new profile for this user") do
> > @user.profiles.size.should == @user_profiles + 1
> > end
>
> > Then("there should be a list of remaining questions") do
> > session[:current_question].should_not == nil
> > session[:pending_questions].should_not == nil
> > @remaining_questions = session[:pending_questions].size
> > end
>
> > Then("there should be one question less to answer") do
> > session[:pending_questions].size.should == @remaining_questions -
> > 1
> > @remaining_questions = session[:pending_questions].size
> > end
>
> > Then("there should be one more answer") do
> > Reply.find(:all).size.should == @replies + 1
> > @replies = Reply.find(:all).size
> > end
>
> > Then("there should be no more question to answer") do
> > session[:pending_questions].size.should == 0
> > session[:current_question].should == nil
> > end
>
> > Then("the profile should be set as terminated") do
> > @user.profiles.first.finished_at.should_not == nil
> > end
>
> > end
>
> Looks like GivenScenario gets run in a separate instance of RailsStory
> (which is derived from ActionController::IntegrationSession) from the
> rest of the scenario. This would explain why the session gets cleared
> out. I can tell you that the DB state does NOT get cleared out, but
> the mechanism is different.
>
> I'm not going to have cycles to investigate a solution right away, so
> would you please submit a ticket athttp://rspec.lighthouseapp.com?
>
> Thanks,
> David
>
>
>
>
>
> > Thanks for your time and help.
>
> > On Mar 25, 12:07 pm, "David Chelimsky" <[EMAIL PROTECTED]> wrote:
>
> > > On Tue, Mar 25, 2008 at 5:13 AM, Bastien <[EMAIL PROTECTED]> wrote:
> > > > I have some problems with GivenScenario, my scenario keeps on failing
> > > > when I use GivenScenario, like if the database or the session was not
> > > > in the same state at the beginning of the new scenario as it was at
> > > > the end of the given one. If I try to group my two scenari in only one
> > > > big scenario then it passes... Any clue of what I might do wrong
> > > > there ?
>
> > > Hard to tell from plain text. Can you post the steps definitions?
>
> > > > you can see here my story :
>
> > > > Story: Filling a profile
>
> > > > As a user
> > > > I want to fill a profile
> > > > So that I can see my score
>
> > > > Scenario: Starting a new profile
>
> > > > Given a company
> > > > And a department
> > > > And 2 questions
> > > > And a number of replies
> > > > And the logged in user [EMAIL PROTECTED]
>
> > > > When the user starts a new profile
>
> > > > Then there should be a new profile for this user
> > > > And there should be a list of remaining questions (
> > ids stored in
> > > > the session )
>
> > > > When the user answers a question
>
> > > > Then there should be one more answer
> > > > Then there should be one question less to answer
>
> > > > Scenario: Ending a profile
> > > > GivenScenario: Starting a new profile # if i remove
> > these 2 lines it
> > > > passes
>
> > > > When the user answers a question # fails here because
> > the question
> > > > which id's is stored in the session can't be found
>
> > > > Then there should be one more answer
> > > > Then there should be no more question to answer
> > > > Then the profile should be set as terminated
> > > > _______________________________________________
> > > > rspec-users mailing list
> > > > [EMAIL PROTECTED]
>
> > > > http://rubyforge.org/mailman/listinfo/rspec-users
>
> > > _______________________________________________
> > > rspec-users mailing list
> > > [EMAIL PROTECTED]://rubyforge.org/mailman/listinfo/rspec-users
>
> > _______________________________________________
> > rspec-users mailing list
> > [EMAIL PROTECTED]
> > http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> [EMAIL PROTECTED]://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users