commit
472a294bb8
62 changed files with 26 additions and 263 deletions
|
|
@ -1,11 +0,0 @@
|
|||
@javascript
|
||||
Feature: Navigate mobile site
|
||||
|
||||
In order to navigate Diaspora*
|
||||
As a mobile user
|
||||
I want to show mobile site of Diaspora*
|
||||
|
||||
Scenario: Show mobile site
|
||||
And I visit the mobile aspects page
|
||||
Then I should see "LOG IN"
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
When /^I click on "([^"]*)" aspect edit icon$/ do |aspect_name|
|
||||
within(".all_aspects") do
|
||||
li = find('li', text: aspect_name)
|
||||
page.execute_script("$('#aspects_list li:contains(\\'#{aspect_name}\\') .modify_aspect').css('display', 'block');") # TODO HACK please replace me by li.hover when capybara will be fixed
|
||||
li.hover
|
||||
li.find('.modify_aspect').click
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ end
|
|||
|
||||
Then /^the first comment field should be closed$/ do
|
||||
page.should have_css(".stream_element")
|
||||
find("#main_stream .stream_element .new_comment", match: :first, visible: false).should_not be_visible
|
||||
page.should_not have_selector("#main_stream .stream_element .new_comment", match: :first)
|
||||
end
|
||||
|
||||
When /^I comment "([^"]*)" on "([^"]*)"$/ do |comment_text, post_text|
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ Then /^I should see "([^"]*)" as part of the participants popover$/ do |name|
|
|||
end
|
||||
|
||||
Then /^I close the participants popover$/ do
|
||||
find('.popover-title .close', visible: false).click
|
||||
find('.popover').hover
|
||||
find('.popover-title .close').click
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -75,10 +75,6 @@ And /^I expand the publisher$/ do
|
|||
click_publisher
|
||||
end
|
||||
|
||||
When 'I click the aspects title' do
|
||||
find('.home_selector').click
|
||||
end
|
||||
|
||||
When /^I press the aspect dropdown$/ do
|
||||
find('.dropdown .button').click
|
||||
end
|
||||
|
|
@ -88,10 +84,6 @@ And /^I toggle the aspect "([^"]*)"$/ do |aspect_name|
|
|||
find(".dropdown li[data-aspect_id='#{aspect.id}']").click
|
||||
end
|
||||
|
||||
Then /^the publisher should be collapsed$/ do
|
||||
find("#publisher")["class"].should include("closed")
|
||||
end
|
||||
|
||||
Then /^the publisher should be expanded$/ do
|
||||
find("#publisher")["class"].should_not include("closed")
|
||||
end
|
||||
|
|
@ -103,8 +95,6 @@ end
|
|||
When /^I append "([^"]*)" to the publisher$/ do |stuff|
|
||||
elem = find('#status_message_fake_text')
|
||||
elem.native.send_keys(' ' + stuff)
|
||||
|
||||
find('#status_message_text', visible: false).value.should include(stuff)
|
||||
end
|
||||
|
||||
When /^I append "([^"]*)" to the publisher mobile$/ do |stuff|
|
||||
|
|
@ -122,12 +112,13 @@ And /^I want to mention (?:him|her) from the profile$/ do
|
|||
end
|
||||
|
||||
And /^I hover over the "([^"]+)"$/ do |element|
|
||||
page.execute_script("$(\"#{element}\").first().addClass('hover')")
|
||||
find("#{element}", match: :first).hover
|
||||
end
|
||||
|
||||
When /^I prepare the deletion of the first post$/ do
|
||||
within('.stream_element', match: :first) do
|
||||
find('.remove_post', visible: false).click
|
||||
find('.controls').hover
|
||||
find('.remove_post').click
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -138,7 +129,8 @@ end
|
|||
|
||||
When /^I click to delete the first comment$/ do
|
||||
within("div.comment", match: :first) do
|
||||
find(".comment_delete", visible: false).click
|
||||
find(".controls").hover
|
||||
find(".comment_delete").click
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -147,10 +139,6 @@ When /^I click to delete the first uploaded photo$/ do
|
|||
find("#photodropzone .x", match: :first).click
|
||||
end
|
||||
|
||||
And /^I click "([^"]*)" button$/ do |arg1|
|
||||
page.execute_script('$(".button:contains('+arg1+')").click()')
|
||||
end
|
||||
|
||||
And /^I click on selector "([^"]*)"$/ do |selector|
|
||||
find(selector).click
|
||||
end
|
||||
|
|
@ -216,18 +204,10 @@ Then /^the "([^"]*)" field(?: within "([^"]*)")? should be filled with "([^"]*)"
|
|||
field = find_field(field)
|
||||
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
||||
field_value = field_value.first if field_value.is_a? Array
|
||||
if field_value.respond_to? :should
|
||||
field_value.should == value
|
||||
else
|
||||
assert_equal(value, field_value)
|
||||
end
|
||||
field_value.should == value
|
||||
end
|
||||
end
|
||||
|
||||
Then /^I should see (\d+) posts$/ do |n_posts|
|
||||
has_css?("#main_stream .stream_element", :count => n_posts.to_i).should be_true
|
||||
end
|
||||
|
||||
Then /^I should see (\d+) contacts$/ do |n_posts|
|
||||
has_css?("#people_stream .stream_element", :count => n_posts.to_i).should be_true
|
||||
end
|
||||
|
|
@ -246,12 +226,6 @@ When /^I resize my window to 800x600$/ do
|
|||
JS
|
||||
end
|
||||
|
||||
Then /^I follow Edit Profile in the same window$/ do
|
||||
page.execute_script("$('a[href=\"#{edit_profile_path}\"]').removeAttr('target')")
|
||||
|
||||
step %(I follow "Edit Profile")
|
||||
end
|
||||
|
||||
Then 'I should see an image attached to the post' do
|
||||
step %{I should see a "img" within ".stream_element div.photo_attachments"}
|
||||
end
|
||||
|
|
@ -269,22 +243,10 @@ And /^I click close on all the popovers$/ do
|
|||
page.should_not have_selector(".popover .close")
|
||||
end
|
||||
|
||||
Then /^I should see first post deletion link$/ do
|
||||
page.should have_selector '.stream_element .delete', match: :first
|
||||
end
|
||||
|
||||
Then /^I should not see ajax loader on deletion link place$/ do
|
||||
page.should_not have_selector '.hide_loader'
|
||||
end
|
||||
|
||||
Then /^I should see a flash message indicating success$/ do
|
||||
flash_message_success?.should be_true
|
||||
end
|
||||
|
||||
Then /^I should see a flash message indicating failure$/ do
|
||||
flash_message_failure?.should be_true
|
||||
end
|
||||
|
||||
Then /^I should see a flash message containing "(.+)"$/ do |text|
|
||||
flash_message_containing? text
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
module FactoryMethods
|
||||
def create_from_table(model_name, table, extra = {})
|
||||
factory_name = model_name.gsub(/\W+/, '_').downcase.singularize.to_sym
|
||||
is_singular = model_name.to_s.singularize == model_name.to_s
|
||||
hashes = if is_singular
|
||||
if table.kind_of?(Hash)
|
||||
[table]
|
||||
else
|
||||
[table.rows_hash]
|
||||
end
|
||||
else
|
||||
table.hashes
|
||||
end
|
||||
klass = FactoryGirl.factories[factory_name].class_name.to_s.classify.constantize
|
||||
@they = hashes.map do |hash|
|
||||
hash = hash.merge(extra).inject({}) do |h,(k,v)|
|
||||
k = k.gsub(/\W+/,'_')
|
||||
v = v.split(/\s*,\s*/) if klass.serialized_attributes[k] == Array
|
||||
h.update(k.to_sym => v)
|
||||
end
|
||||
object = FactoryGirl.build(factory_name, hash)
|
||||
yield object if block_given?
|
||||
object.save!
|
||||
object
|
||||
end
|
||||
if is_singular
|
||||
@it = @they.last
|
||||
instance_variable_set("@#{factory_name}", @it)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
World(FactoryMethods)
|
||||
|
||||
Given %r{^I have a (.+)$} do |model_name|
|
||||
create_from_table(model_name, {}, 'user' => @me)
|
||||
end
|
||||
|
||||
Given %r{^I have the following (.+):$} do |child, table|
|
||||
step "that me has the following #{child}:", table
|
||||
end
|
||||
|
||||
Given %r{^the following (.+):$} do |model_name, table|
|
||||
create_from_table(model_name, table)
|
||||
end
|
||||
|
||||
Given %r{^that (.+) has the following (.+):$} do |parent, child, table|
|
||||
child= child.gsub(/\W+/,'_')
|
||||
parent = parent.gsub(/\W+/,'_').downcase.sub(/^_/, '')
|
||||
parent_instance = instance_variable_get("@#{parent}")
|
||||
parent_class = parent_instance.class
|
||||
if assoc = parent_class.reflect_on_association(child.to_sym) || parent_class.reflect_on_association(child.pluralize.to_sym)
|
||||
parent = (assoc.options[:as] || parent).to_s
|
||||
child = (assoc.options[:class_name] || child).to_s
|
||||
end
|
||||
if child.classify.constantize.method_defined?(parent.pluralize)
|
||||
create_from_table(child, table, parent.pluralize => [parent_instance])
|
||||
elsif child.classify.constantize.method_defined?(parent)
|
||||
create_from_table(child, table, parent => parent_instance)
|
||||
else
|
||||
create_from_table(child, table)
|
||||
if assoc.macro == :has_many
|
||||
parent_instance.send("#{assoc.name}=", @they)
|
||||
else
|
||||
parent_instance.send("#{assoc.name}=", @they.first)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -5,7 +5,7 @@ When /^I press the "([^\"]*)" key somewhere$/ do |key|
|
|||
end
|
||||
|
||||
When /^I press the "([^\"]*)" key in the publisher$/ do |key|
|
||||
find("#status_message_fake_text", visible: false).native.send_keys(key)
|
||||
find("#status_message_fake_text").native.send_keys(key)
|
||||
end
|
||||
|
||||
Then /^post (\d+) should be highlighted$/ do |position|
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
Then /^the post "([^"]*)" should be marked nsfw$/ do |text|
|
||||
assert_nsfw(text)
|
||||
end
|
||||
|
||||
Then /^the post should be collapsed$/ do
|
||||
first_post_collapsed?
|
||||
end
|
||||
|
|
@ -11,7 +7,7 @@ Then /^the post should be expanded$/ do
|
|||
end
|
||||
|
||||
Then /^I should see an uploaded image within the photo drop zone$/ do
|
||||
find("#photodropzone img", visible: false)["src"].should include("uploads/images")
|
||||
find("#photodropzone img")["src"].should include("uploads/images")
|
||||
end
|
||||
|
||||
Then /^I should not see an uploaded image within the photo drop zone$/ do
|
||||
|
|
@ -38,12 +34,9 @@ And /^the post with text "([^"]*)" is reshared by "([^"]*)"$/ do |text, email|
|
|||
user.post(:reshare, :root_guid => root.guid, :public => true, :to => user.aspects)
|
||||
end
|
||||
|
||||
When /^The user deletes their first post$/ do
|
||||
@me.posts.first.destroy
|
||||
end
|
||||
|
||||
When /^I click on the first block button/ do
|
||||
find(".block_user", visible: false).click
|
||||
find(".stream_element", match: :first).hover
|
||||
find(".block_user").click
|
||||
end
|
||||
|
||||
When /^I expand the post$/ do
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
module SectionLocator
|
||||
def within_parent(content, elements = ['*'], &block)
|
||||
expr = %(//*[(#{elements.join('|')})/descendant-or-self::*[contains(., "#{content}")]])
|
||||
within(expr, &block)
|
||||
end
|
||||
end
|
||||
|
||||
World(SectionLocator)
|
||||
|
||||
sections = %w(h1 h2 h3 h4 h5 h6 legend caption dt strong header)
|
||||
|
||||
When /^(.*) in the "([^\"]*)" section$/ do |action, title|
|
||||
within_parent(title, sections) do
|
||||
step action
|
||||
end
|
||||
end
|
||||
|
||||
When /^(.*) in the "([^\"]*)" section:$/ do |action, title, table|
|
||||
within_parent(title, sections) do
|
||||
step "#{action}:", table
|
||||
end
|
||||
end
|
||||
|
||||
When /^(.*) in the "([^\"]*)" row$/ do |action, title|
|
||||
within_parent(title, %w(th td)) do
|
||||
step action
|
||||
end
|
||||
end
|
||||
|
|
@ -1,13 +1,8 @@
|
|||
|
||||
Given /^(?:I am signed in|I sign in)$/ do
|
||||
Given /^(?:I am signed in)$/ do
|
||||
automatic_login
|
||||
confirm_login
|
||||
end
|
||||
|
||||
When /^I try to sign in$/ do
|
||||
automatic_login
|
||||
end
|
||||
|
||||
When /^I try to sign in manually$/ do
|
||||
manual_login
|
||||
end
|
||||
|
|
@ -62,4 +57,4 @@ end
|
|||
|
||||
When /^I (?:log|sign) out manually$/ do
|
||||
manual_logout
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
Then /^I should see an image in the publisher$/ do
|
||||
photo_in_publisher.should be_present
|
||||
end
|
||||
|
||||
Then /^I like the post "([^"]*)"$/ do |post_text|
|
||||
like_post(post_text)
|
||||
end
|
||||
|
|
@ -17,9 +13,3 @@ end
|
|||
Then /^I should have (\d+) nsfw posts$/ do |num_posts|
|
||||
page.should have_css(".nsfw-shield", count: num_posts.to_i)
|
||||
end
|
||||
|
||||
When /^I click the show page link for "([^"]*)"$/ do |post_text|
|
||||
within(find_post_by_text(post_text)) do
|
||||
find("time").click
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
Given /^I have posts for each type of template$/ do
|
||||
generate_post_of_each_template(@me)
|
||||
end
|
||||
|
||||
Then /^I visit all of my posts$/ do
|
||||
lambda{ @templates_seen = visit_posts_and_collect_template_names(@me)}.should_not raise_error
|
||||
end
|
||||
|
||||
When /^I should have seen all of my posts displayed with the correct template$/ do
|
||||
pending
|
||||
@templates_seen.should =~ TemplatePicker.jsonified_templates
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
When /^I visit url ([^ ]+)$/ do |url|
|
||||
visit( url)
|
||||
end
|
||||
|
||||
Then /^I should find '([^']*)' in ([^ ]+)$/ do |pattern,file|
|
||||
found = %x!fgrep -o #{pattern} #{file}!
|
||||
assert_equal pattern, found.chomp, "Can't find pattern in #{file}"
|
||||
end
|
||||
|
||||
Then /^I should match '([^']*)' in ([^ ]+)$/ do |pattern,file|
|
||||
found = `egrep -o '#{pattern}' #{file}`
|
||||
assert_match /#{pattern}/, found.chomp, "Can't find #{pattern} in #{file}"
|
||||
end
|
||||
|
||||
When /^I retrieve ([^ ]+) into ([^ ]+)$/ do |url,file|
|
||||
system( "wget -q -O #{file} #{url}")
|
||||
end
|
||||
|
||||
Then /^a page\-asset should be ([^ ]+)$/ do |asset_path|
|
||||
page.has_content?(asset_path)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -119,22 +119,14 @@ end
|
|||
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
||||
regexp = Regexp.new(regexp)
|
||||
with_scope(selector) do
|
||||
if page.respond_to? :should
|
||||
page.should have_xpath('//*', :text => regexp)
|
||||
else
|
||||
assert page.has_xpath?('//*', :text => regexp)
|
||||
end
|
||||
page.should have_xpath('//*', :text => regexp)
|
||||
end
|
||||
end
|
||||
|
||||
Then /^(?:|I )should not see (\".+?\"[\s]*)(?:[\s]+within[\s]* "([^"]*)")?$/ do |vars,selector|
|
||||
vars.scan(/"([^"]+?)"/).flatten.each do |text|
|
||||
with_scope(selector) do
|
||||
if page.respond_to? :should
|
||||
page.should have_no_content(text)
|
||||
else
|
||||
assert page.has_no_content?(text)
|
||||
end
|
||||
page.should have_no_content(text)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -142,11 +134,7 @@ end
|
|||
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
||||
regexp = Regexp.new(regexp)
|
||||
with_scope(selector) do
|
||||
if page.respond_to? :should
|
||||
page.should have_no_xpath('//*', :text => regexp)
|
||||
else
|
||||
assert page.has_no_xpath?('//*', :text => regexp)
|
||||
end
|
||||
page.should have_no_xpath('//*', :text => regexp)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -154,11 +142,7 @@ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |
|
|||
with_scope(selector) do
|
||||
field = find_field(field)
|
||||
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
||||
if field_value.respond_to? :should
|
||||
field_value.should =~ /#{value}/
|
||||
else
|
||||
assert_match(/#{value}/, field_value)
|
||||
end
|
||||
field_value.should =~ /#{value}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -166,33 +150,21 @@ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/
|
|||
with_scope(selector) do
|
||||
field = find_field(field)
|
||||
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
||||
if field_value.respond_to? :should_not
|
||||
field_value.should_not =~ /#{value}/
|
||||
else
|
||||
assert_no_match(/#{value}/, field_value)
|
||||
end
|
||||
field_value.should_not =~ /#{value}/
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
|
||||
with_scope(selector) do
|
||||
field_checked = find_field(label)['checked']
|
||||
if field_checked.respond_to? :should
|
||||
field_checked.should be_true
|
||||
else
|
||||
assert field_checked
|
||||
end
|
||||
field_checked.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
|
||||
with_scope(selector) do
|
||||
field_checked = find_field(label)['checked']
|
||||
if field_checked.respond_to? :should
|
||||
field_checked.should be_false
|
||||
else
|
||||
assert !field_checked
|
||||
end
|
||||
field_checked.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -206,12 +178,7 @@ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
|||
actual_params = query ? CGI.parse(query) : {}
|
||||
expected_params = {}
|
||||
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
||||
|
||||
if actual_params.respond_to? :should
|
||||
actual_params.should == expected_params
|
||||
else
|
||||
assert_equal expected_params, actual_params
|
||||
end
|
||||
actual_params.should == expected_params
|
||||
end
|
||||
|
||||
Then /^show me the page$/ do
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ module PublishingCukeHelpers
|
|||
def expand_first_post
|
||||
within(".stream_element", match: :first) do
|
||||
find(".expander").click
|
||||
find(".expander", visible: false).should_not be_visible
|
||||
has_css?(".expander").should be_false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ module PublishingCukeHelpers
|
|||
end
|
||||
|
||||
def first_post_expanded?
|
||||
find(".stream_element .expander", match: :first, visible: false).should_not be_visible
|
||||
has_no_css?(".stream_element .expander", match: :first).should be_true
|
||||
find(".stream_element .collapsible", match: :first).has_no_selector?(".collapsed")
|
||||
find(".stream_element .collapsible", match: :first).has_selector?(".opened")
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue