remove the last rspec story and migrate it to cucumber. Also remove equivalent selenium script

This commit is contained in:
Reinier Balt 2010-02-09 10:27:59 +01:00
parent 8d10deac30
commit d945d974a7
12 changed files with 52 additions and 202 deletions

View file

@ -0,0 +1,21 @@
Feature: Manage contexts
In order to manage my contexts
As a Tracks user
I want to view, edit, add, or remove contexts
Background:
Given the following user record
| login | password | is_admin |
| testuser | secret | false |
And I have logged in as "testuser" with password "secret"
@selenium
Scenario: In place edit of context name
Given I have a context called "Errands"
When I visits the context page for "Errands"
And I edit the context name in place to be "OutAndAbout"
Then I should see the context name is "OutAndAbout"
When I go to the contexts page
Then he should see that a context named "Errands" is not present
And he should see that a context named "OutAndAbout" is present

View file

@ -0,0 +1,27 @@
Given /^I have a context called "([^\"]*)"$/ do |context_name|
@current_user.contexts.create!(:name => context_name)
end
When /^I visits the context page for "([^\"]*)"$/ do |context_name|
context = @current_user.contexts.find_by_name(context_name)
context.should_not be_nil
visit "/contexts/#{context.id}"
end
When /^I edit the context name in place to be "([^\"]*)"$/ do |new_context_name|
selenium.click "context_name"
fill_in "value", :with => "OutAndAbout"
click_button "OK"
end
Then /^I should see the context name is "([^\"]*)"$/ do |context_name|
Then "I should see \"#{context_name}\""
end
Then /^he should see that a context named "([^\"]*)" is present$/ do |context_name|
Then "I should see \"#{context_name}\""
end
Then /^he should see that a context named "([^\"]*)" is not present$/ do |context_name|
Then "I should not see \"#{context_name}\""
end

View file

@ -14,6 +14,8 @@ module NavigationHelpers
login_path
when /the notes page/
notes_path
when /the contexts page/
contexts_path
# Add more page name => path mappings here

View file

@ -1,6 +1,7 @@
Webrat.configure do |config|
config.mode = :selenium
config.application_environment = :selenium
config.selenium_browser_startup_timeout = 30
end
Cucumber::Rails::World.use_transactional_fixtures = false

View file

@ -394,7 +394,7 @@ $(document).ready(function() {
};
$.post('/contexts/update/'+context_id, {'context[name]': value}, highlight);
return(value);
}, {style: 'padding:0px', submit: "OK"});
}, {style: 'padding:0px', submit: "OK", cancel: "CANCEL"});
/* Projects behavior */

View file

@ -1,4 +0,0 @@
dir = File.dirname(__FILE__)
Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file|
require file
end

View file

@ -1,15 +0,0 @@
Story: Change context name
As a Tracks user
I want to change the name of a context
So that it can best reflect my daily life
Scenario: In place edit of context name
Given a logged in user Luis
And Luis has a context Errands
When Luis visits the Errands context page
And he edits the Errands context name in place to be OutAndAbout
Then he should see the context name is OutAndAbout
When Luis visits the context listing page
Then he should see that a context named Errands is not present
And he should see that a context named OutAndAbout is present

View file

@ -1,3 +0,0 @@
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec/rails/story_adapter'

View file

@ -1,41 +0,0 @@
Story: View, add, remove notes
As a Tracks user
I want to view, add, and remove notes
So that I can keep important information easily accessible
Scenario: View and toggle notes
Given a logged in user Luis
And Luis has two projects with one note each
When Luis visits the notes page
Then two notes should be visible
And the badge should show 2
When Luis clicks Toggle Notes
Then the body of the notes should be shown
Scenario: Add a new note
Given a logged in user Luis
And Luis has one project Pass Final Exam with no notes
When Luis adds a note from the Pass Final Exam project page
Then Luis should see the note on the Pass Final Exam project page
And Luis should see the note on the notes page
And the badge on the notes page should show 1
Scenario: Delete note from notes page
Given a logged in user Luis
And Luis has one project Pass Final Exam with 2 notes
When Luis visits the notes page
And Luis deletes the first note
Then the first note should disappear
Then the badge should show 1
Scenario: Link to note
Given a logged in user Luis
And Luis has one project Pass Final Exam with 1 note
When Luis visits the Pass Final Exam project page
And clicks the icon next to the note
Then he should see the note text

View file

@ -1,34 +0,0 @@
steps_for :context_detail do
include_steps_for :users
Given "Luis has a context Errands" do
@errands = @luis.contexts.create!(:name => 'Errands')
end
When "Luis visits the Errands context page" do
visits "/contexts/#{@errands.to_param}"
end
When "he edits the Errands context name in place to be OutAndAbout" do
selenium.click 'context_name_in_place_editor'
wait_for_ajax_and_effects
selenium.type "css=#context_name_in_place_editor-inplaceeditor input.editor_field", "OutAndAbout"
clicks_button "ok", :wait => :ajax
end
When "Luis visits the context listing page" do
visits "/contexts"
end
Then "he should see the context name is OutAndAbout" do
should_see 'OutAndAbout'
end
Then "he should see that a context named Errands is not present" do
should_not_see 'Errands'
end
Then "he should see that a context named OutAndAbout is present" do
should_see 'OutAndAbout'
end
end

View file

@ -1,94 +0,0 @@
steps_for :notes do
include_steps_for :users
Given "Luis has two projects with one note each" do
project_a = @luis.projects.create!(:name => 'project A')
project_a.notes.create!(:user_id => @luis.id, :body => 'note for project A')
project_b = @luis.projects.create!(:name => 'project B')
project_b.notes.create!(:user_id => @luis.id, :body => 'note for project B')
end
Given "Luis has one project Pass Final Exam with no notes" do
@exam_project = @luis.projects.create!(:name => 'Pass Final Exam')
end
Given "Luis has one project Pass Final Exam with 1 note" do
Given "Luis has one project Pass Final Exam with no notes"
@exam_project.notes.create!(:user_id => @luis.id, :body => 'exam note 1')
end
Given "Luis has one project Pass Final Exam with 2 notes" do
Given "Luis has one project Pass Final Exam with 1 note"
@exam_project.notes.create!(:user_id => @luis.id, :body => 'exam note 2')
end
When "Luis visits the notes page" do
visits '/notes'
end
When "Luis adds a note from the Pass Final Exam project page" do
When "Luis visits the Pass Final Exam project page"
clicks_link 'Add a note', :wait => :ajax
fills_in 'new_note_body', :with => 'new exam note'
clicks_button 'Add note', :wait => :ajax
end
When "Luis visits the Pass Final Exam project page" do
visits "/projects/#{@exam_project.to_param}"
end
When "Luis deletes the first note" do
selenium.click "css=a.delete_note"
selenium.get_confirmation.should =~ /delete/
end
When "clicks the icon next to the note" do
selenium.click "css=a.link_to_notes"
wait_for_page_to_load
end
When "Luis clicks Toggle Notes" do
clicks_link 'Toggle notes', :wait => :effects
end
Then "the body of the notes should be shown" do
wait_for_effects
selenium.is_visible("css=body.notes").should be_true
end
Then "Luis should see the note on the Pass Final Exam project page" do
should_see "new exam note"
end
Then "Luis should see the note on the notes page" do
visits '/notes'
should_see "new exam note"
end
Then "the badge on the notes page should show 1" do
badge_count_should_show(1)
end
Then "the first note should disappear" do
wait_for_ajax_and_effects
should_not_see 'exam note 1'
end
Then "the badge should show 1" do
wait_for_ajax_and_effects
badge_count_should_show(1)
end
Then "the badge should show 2" do
badge_count_should_show(2)
end
Then "two notes should be visible" do
should_see 'note for project A'
should_see 'note for project B'
end
Then "he should see the note text" do
should_see 'exam note 1'
end
end

View file

@ -1,10 +0,0 @@
setup :fixtures => :all
login :as => 'admin'
open "/contexts/1"
click "context_name"
wait_for_element_present "css=#context_name form input"
type "css=#context_name form input", "Test Foo"
click "css=#context_name form button"
wait_for_text "context_name", "Test Foo"
open "/contexts/1"
wait_for_text "context_name", "Test Foo"