diff --git a/app/views/notes/_notes.rhtml b/app/views/notes/_notes.rhtml index f9f9dacb..2e5fef2e 100644 --- a/app/views/notes/_notes.rhtml +++ b/app/views/notes/_notes.rhtml @@ -6,17 +6,12 @@ <% note = nil -%> + diff --git a/features/notes_manage.feature b/features/notes_manage.feature index b1488831..c0e07406 100644 --- a/features/notes_manage.feature +++ b/features/notes_manage.feature @@ -37,10 +37,3 @@ Feature: View, add, remove notes When I visit the "Pass Final Exam" project And I click the icon next to the note Then I should see the note text - - @selenium - Scenario: Toggle notes - Given I have two projects with one note each - When I go to the notes page - And I click Toggle Notes - Then I should see the body of the notes diff --git a/features/step_definitions/generic_steps.rb b/features/step_definitions/generic_steps.rb index 4d1bea16..5e1b684f 100644 --- a/features/step_definitions/generic_steps.rb +++ b/features/step_definitions/generic_steps.rb @@ -1,8 +1,16 @@ Then /the badge should show (.*)/ do |number| # puts response.body.inspect badge = -1 - response.should have_xpath("//span[@id='badge_count']") do |node| - badge = node.first.content.to_i + xpath= "//span[@id='badge_count']" + + if Rails.env == 'selenium' + response.should have_xpath(xpath) + badge = response.selenium.get_text("xpath=#{xpath}").to_i + else + response.should have_xpath(xpath) do |node| + badge = node.first.content.to_i + end end + badge.should == number.to_i end diff --git a/features/step_definitions/note_steps.rb b/features/step_definitions/note_steps.rb index b9ad279d..8c5896f2 100644 --- a/features/step_definitions/note_steps.rb +++ b/features/step_definitions/note_steps.rb @@ -38,8 +38,8 @@ end Given /^I have a project "([^\"]*)" with (.*) notes?$/ do |project_name, num| project = @current_user.projects.create!(:name => project_name) - 0.upto num.to_i do |i| - project.notes.create!(:user_id => @current_user.id, :body => "A note #{i+1}") + 1.upto num.to_i do |i| + project.notes.create!(:user_id => @current_user.id, :body => "A note #{i}. This is the very long body of note #{i} where you should not see the last part of the note after 50 characters") end end @@ -49,61 +49,14 @@ When /^I delete the first note$/ do end Then /^the first note should disappear$/ do - # the first note contains "A note 1" + # the first note contains "A note 1", generated by the Given def above Then "I should not see \"A note 1\"" end -Given /^I have one project "([^\"]*)" with 1 note$/ do |arg1| - pending -end - When /^I click the icon next to the note$/ do - # need selenium for this to check on the js - pending + click_link "Show note" end Then /^I should see the note text$/ do - # need selenium for this to check on the js - pending -end - -Then /^I should see the body of the notes$/ do - pending -end - - -#------ left over from old stories. can be removed if pending stuff is done - -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 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 "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 "he should see the note text" do -should_see 'exam note 1' + Then "I should see \"after 50 characters\"" end