Added cucumber step for searching, and feature for searching for tags.

This commit is contained in:
Sarah Mei 2011-03-19 18:52:35 -07:00
parent a8737ab318
commit 1bd693eb14
4 changed files with 24 additions and 1 deletions

View file

@ -132,3 +132,12 @@ end
Then /^I should get download alert$/ do
page.evaluate_script("window.alert = function() { return true; }")
end
When /^I search for "([^\"]*)"$/ do |search_term|
When "I fill in \"q\" with \"#{search_term}\""
page.execute_script <<-JS
var e = jQuery.Event("keypress");
e.keyCode = 13;
$("#q").trigger(e);
JS
end

View file

@ -1,7 +1,7 @@
module NavigationHelpers
def path_to(page_name)
case page_name
when /^the home page$/
when /^the home(?: )?page$/
root_path
when /^step (\d)$/
if $1.to_i == 1
@ -9,6 +9,8 @@ module NavigationHelpers
else
getting_started_path(:step => $1)
end
when /^the tag page for "([^\"]*)"$/
tag_path($1)
when /^its ([\w ]+) page$/
send("#{$1.gsub(/\W+/, '_')}_path", @it)
when /^the ([\w ]+) page$/

8
features/tags.feature Normal file
View file

@ -0,0 +1,8 @@
@javascript
Feature: Interacting with tags
Scenario: Searching for a tag
Given I am signed in
And I am on the homepage
And I search for "#rockstar"
Then I should be on the tag page for "rockstar"

View file

@ -12,6 +12,10 @@ FixtureBuilder.configure do |fbuilder|
bob = Factory(:user_with_aspect, :username => "bob")
Factory(:aspect, :name => "empty", :user => bob)
alice.profile.tag_string = '#rockstar'
alice.profile.build_tags
alice.profile.save!
connect_users(bob, bob.aspects.first, alice, alice.aspects.first)
connect_users(bob, bob.aspects.first, eve, eve.aspects.first)
end