Initial rendition of feature test upgrade to Ruby 2.x and Rspec 3.x syntax.

This commit is contained in:
Anthony Atkinson
2015-07-22 19:48:41 -04:00
parent fad9eddbc4
commit 5a35a3da01
42 changed files with 491 additions and 588 deletions

View File

@@ -1,20 +1,13 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
## Uncomment and set this to only include directories you want to watch
directories %w(app lib config spec) \
.select { |d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist") }
## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
# $ mkdir config
# $ mv Guardfile config/
# $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
guard :rspec,
cmd: 'bundle exec spring rspec --format documentation',
failed_mode: :keep
cmd: 'bundle exec rspec --format documentation',
failed_mode: :keep do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/libs/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
end

View File

@@ -2,7 +2,8 @@ require 'rails_helper'
feature "account types" do
context "admin user" do
let(:member) { FactoryGirl.create(:admin_member) }
let(:member) { create :admin_member }
let(:account_type) { create :account_type }
background do
login_as member
@@ -11,38 +12,36 @@ feature "account types" do
scenario "navigating to account type admin" do
visit root_path
click_link "Admin"
current_path.should eq admin_path
expect(current_path).to eq admin_path
click_link "Account types"
current_path.should eq account_types_path
expect(current_path).to eq account_types_path
end
scenario "adding an account type" do
visit account_types_path
click_link "New Account type"
current_path.should eq new_account_type_path
fill_in 'Name', :with => 'Guest'
expect(current_path).to eq new_account_type_path
fill_in 'Name', with: 'Guest'
click_button 'Save'
current_path.should eq account_type_path(AccountType.last)
page.should have_content 'Account type was successfully created'
expect(current_path).to eq account_type_path(AccountType.last)
expect(page).to have_content 'Account type was successfully created'
end
scenario 'editing account type' do
a = FactoryGirl.create(:account_type)
visit account_type_path(a)
visit account_type_path account_type
click_link 'Edit'
fill_in 'Name', :with => 'Something else'
fill_in 'Name', with: 'Something else'
click_button 'Save'
current_path.should eq account_type_path(a)
page.should have_content 'Account type was successfully updated'
page.should have_content 'Something else'
expect(current_path).to eq account_type_path(account_type)
expect(page).to have_content 'Account type was successfully updated'
expect(page).to have_content 'Something else'
end
scenario 'deleting account type' do
a = FactoryGirl.create(:account_type)
visit account_type_path(a)
visit account_type_path account_type
click_link 'Delete'
current_path.should eq account_types_path
page.should have_content 'Account type was successfully deleted'
expect(current_path).to eq account_types_path
expect(page).to have_content 'Account type was successfully deleted'
end
end
end

View File

@@ -1,8 +1,9 @@
require 'rails_helper'
feature "forums" do
context "admin user" do
let(:member) { FactoryGirl.create(:admin_member) }
context "as an admin user" do
let(:member) { create :admin_member }
let(:forum) { create :forum }
background do
login_as member
@@ -11,43 +12,41 @@ feature "forums" do
scenario "navigating to forum admin" do
visit root_path
click_link "Admin"
current_path.should eq admin_path
expect(current_path).to eq admin_path
within 'ul#admin_links' do
click_link "Forums"
end
current_path.should eq forums_path
page.should have_content "New forum"
expect(current_path).to eq forums_path
expect(page).to have_content "New forum"
end
scenario "adding a forum" do
visit forums_path
click_link "New forum"
current_path.should eq new_forum_path
fill_in 'Name', :with => 'Discussion'
fill_in 'Description', :with => "this is a new forum"
expect(current_path).to eq new_forum_path
fill_in 'Name', with: 'Discussion'
fill_in 'Description', with: "this is a new forum"
click_button 'Save'
current_path.should eq forum_path(Forum.last)
page.should have_content 'Forum was successfully created'
expect(current_path).to eq forum_path(Forum.last)
expect(page).to have_content 'Forum was successfully created'
end
scenario 'editing forum' do
f = FactoryGirl.create(:forum)
visit forum_path(f)
visit forum_path forum
click_link 'Edit'
fill_in 'Name', :with => 'Something else'
fill_in 'Name', with: 'Something else'
click_button 'Save'
f.reload
current_path.should eq forum_path(f)
page.should have_content 'Forum was successfully updated'
page.should have_content 'Something else'
forum.reload
expect(current_path).to eq forum_path(forum)
expect(page).to have_content 'Forum was successfully updated'
expect(page).to have_content 'Something else'
end
scenario 'deleting forum' do
f = FactoryGirl.create(:forum)
visit forum_path(f)
visit forum_path forum
click_link 'Delete'
current_path.should eq forums_path
page.should have_content 'Forum was successfully deleted'
expect(current_path).to eq forums_path
expect(page).to have_content 'Forum was successfully deleted'
end
end
end

View File

@@ -2,7 +2,8 @@ require 'rails_helper'
feature "products" do
context "admin user" do
let(:member) { FactoryGirl.create(:admin_member) }
let(:member) { create :admin_member }
let(:product) { create :product }
background do
login_as member
@@ -11,30 +12,29 @@ feature "products" do
scenario "navigating to product admin" do
visit admin_path
click_link "Products"
current_path.should eq products_path
expect(current_path).to eq products_path
end
scenario "adding a product" do
visit products_path
click_link "New Product"
current_path.should eq new_product_path
fill_in 'Name', :with => 'Special offer'
expect(current_path).to eq new_product_path
fill_in 'Name', with: 'Special offer'
# note that failing to fill in a mandatory field has a messy error. This is not a priority defect but should be raised at some point.
fill_in 'Minimum price', :with => '150'
fill_in 'Minimum price', with: '150'
click_button 'Save'
current_path.should eq product_path(Product.last)
page.should have_content 'Product was successfully created'
expect(current_path).to eq product_path(Product.last)
expect(page).to have_content 'Product was successfully created'
end
scenario 'editing product' do
p = FactoryGirl.create(:product)
visit product_path(p)
visit product_path product
click_link 'Edit'
fill_in 'Name', :with => 'Something else'
fill_in 'Name', with: 'Something else'
click_button 'Save'
current_path.should eq product_path(p)
page.should have_content 'Product was successfully updated'
page.should have_content 'Something else'
expect(current_path).to eq product_path(product)
expect(page).to have_content 'Product was successfully updated'
expect(page).to have_content 'Something else'
end
scenario 'deleting product'

View File

@@ -1,27 +1,26 @@
require 'rails_helper'
feature "cms admin" do
let(:member) { FactoryGirl.create(:member) }
let(:admin_member) { FactoryGirl.create(:admin_member) }
let(:member) { create :member }
let(:admin_member) { create :admin_member }
scenario "can't view CMS admin if not signed in" do
visit comfy_admin_cms_path
current_path.should == root_path
page.should have_content("Please sign in as an admin user")
expect(current_path).to eq root_path
expect(page).to have_content "Please sign in as an admin user"
end
scenario "can't view CMS admin if not an admin member" do
# sign in as an ordinary member
login_as member
visit comfy_admin_cms_path
current_path.should == root_path
page.should have_content("Please sign in as an admin user")
expect(current_path).to eq root_path
expect(page).to have_content "Please sign in as an admin user"
end
scenario "admin members can view CMS admin area" do
login_as admin_member
visit comfy_admin_cms_path
current_path.should match /#{comfy_admin_cms_path}/ # match any CMS admin page
expect(current_path).to match /#{comfy_admin_cms_path}/ # match any CMS admin page
end
end
end

View File

@@ -1,34 +1,33 @@
require 'rails_helper'
feature 'Commenting on a post' do
let(:member) { FactoryGirl.create(:member) }
let(:post) { FactoryGirl.create(:post, :author => member) }
let(:member) { create :member }
let(:post) { create :post, author: member }
background do
login_as(member)
visit new_comment_path(:post_id => post.id)
login_as member
visit new_comment_path post_id: post.id
end
scenario "creating a comment" do
fill_in "comment_body", :with => "This is a sample test for comment"
fill_in "comment_body", with: "This is a sample test for comment"
click_button "Post comment"
expect(page).to have_content "Comment was successfully created"
expect(page).to have_content "Posted by"
end
context "editing a comment" do
let(:existing_comment) { FactoryGirl.create(:comment, :post => post, :author => member) }
let(:existing_comment) { create :comment, post: post, author: member }
background do
visit edit_comment_path(existing_comment)
visit edit_comment_path existing_comment
end
scenario "saving edit" do
fill_in "comment_body", :with => "Testing edit for comment"
click_button "Post comment"
fill_in "comment_body", with: "Testing edit for comment"
click_button "Post comment"
expect(page).to have_content "Comment was successfully updated"
expect(page).to have_content "Edited by"
end
end
end
end

View File

@@ -1,7 +1,7 @@
require 'rails_helper'
feature "Alternate names" do
let!(:alternate_eggplant) { FactoryGirl.create(:alternate_eggplant) }
let!(:alternate_eggplant) { create :alternate_eggplant }
let(:crop) { alternate_eggplant.crop }
scenario "Display alternate names on crop page" do
@@ -16,8 +16,8 @@ feature "Alternate names" do
end
context "User is a crop wrangler" do
let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3) }
let(:member){crop_wranglers.first}
let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 }
let(:member) { crop_wranglers.first }
background do
login_as member
@@ -28,7 +28,7 @@ feature "Alternate names" do
expect(page.status_code).to equal 200
expect(page).to have_content "CROP WRANGLER"
expect(page).to have_content alternate_eggplant.name
expect(page).to have_link "Edit", :href => edit_alternate_name_path(alternate_eggplant)
expect(page).to have_link "Edit", href: edit_alternate_name_path(alternate_eggplant)
within('.alternate_names') { click_on "Edit" }
expect(page.status_code).to equal 200
expect(page).to have_css "option[value='#{crop.id}'][selected=selected]"
@@ -42,7 +42,7 @@ feature "Alternate names" do
scenario "Crop wranglers can delete alternate names" do
visit crop_path(alternate_eggplant.crop)
expect(page).to have_link "Delete",
href: alternate_name_path(alternate_eggplant)
href: alternate_name_path(alternate_eggplant)
within('.alternate_names') { click_on "Delete" }
expect(page.status_code).to equal 200
expect(page).to_not have_content alternate_eggplant.name
@@ -52,7 +52,7 @@ feature "Alternate names" do
scenario "Crop wranglers can add alternate names" do
visit crop_path(crop)
expect(page).to have_link "Add",
href: new_alternate_name_path(crop_id: crop.id)
href: new_alternate_name_path(crop_id: crop.id)
within('.alternate_names') { click_on "Add" }
expect(page.status_code).to equal 200
expect(page).to have_css "option[value='#{crop.id}'][selected=selected]"
@@ -70,17 +70,13 @@ feature "Alternate names" do
end
context "When alternate name is rejected" do
let(:rejected_crop) { FactoryGirl.create(:rejected_crop) }
let(:pending_alt_name) { FactoryGirl.create(:alternate_name, :crop => rejected_crop) }
let(:rejected_crop) { create :rejected_crop }
let(:pending_alt_name) { create :alternate_name, crop: rejected_crop }
scenario "Displays crop rejection message" do
visit alternate_name_path(pending_alt_name)
expect(page).to have_content "This crop was rejected for the following reason: Totally fake"
end
end
end
end

View File

@@ -2,10 +2,10 @@ require 'rails_helper'
feature "browse crops" do
let(:tomato) { FactoryGirl.create(:tomato) }
let(:maize) { FactoryGirl.create(:maize) }
let(:pending_crop) { FactoryGirl.create(:crop_request) }
let(:rejected_crop) { FactoryGirl.create(:rejected_crop) }
let(:tomato) { create :tomato }
let(:maize) { create :maize }
let(:pending_crop) { create :crop_request }
let(:rejected_crop) { create :rejected_crop }
scenario "has a form for sorting by" do
visit crops_path

View File

@@ -1,15 +1,15 @@
require 'rails_helper'
feature "Crop - " do
let!(:crop_wrangler) { FactoryGirl.create(:crop_wrangling_member)}
let!(:member) { FactoryGirl.create(:member)}
let!(:crop_wrangler) { create :crop_wrangling_member }
let!(:member) { create :member }
background do
login_as member
visit new_crop_path
end
scenario "creating a crop with multiple scientific and alternate name", :js => true do
scenario "creating a crop with multiple scientific and alternate name", :js do
within "form#new_crop" do
fill_in "crop_name", with: "Philippine flower"
fill_in "en_wikipedia_url", with: "https://en.wikipedia.org/wiki/Jasminum_sambac"
@@ -27,10 +27,8 @@ feature "Crop - " do
click_button "Save"
end
save_and_open_page
expect(page).to have_content "Crop was successfully requested."
expect(page).to have_content "Jasminum sambac 2"
expect(page).to have_content "Matsurika"
end
end
end

View File

@@ -1,11 +1,11 @@
require 'rails_helper'
feature "crop detail page" do
let(:crop) { FactoryGirl.create(:crop) }
let(:crop) { create :crop }
subject { visit crop_path(crop) }
context "varieties" do
scenario "The crop DOES NOT have varieties" do
visit crop_path(crop)
@@ -16,28 +16,27 @@ feature "crop detail page" do
end
scenario "The crop has one variety" do
roma1 = FactoryGirl.create(:crop, :name => 'Roma tomato 1', :parent => crop)
create :crop, name: 'Roma tomato 1', parent: crop
visit crop_path(crop)
subject
within ".varieties" do
# It lists all 2 items (note: including the top level item.)
expect(page).to have_selector('li', text: /tomato/i, count: 2)
expect(page).to have_selector('li', text: /tomato/i, count: 2)
# It DOES NOT have "Show all/less" toggle link
expect(page).to have_no_selector('button', text: /Show+/i)
end
end
context "many" do
let!(:roma1) { FactoryGirl.create(:crop, :name => 'Roma tomato 1', :parent => crop) }
let!(:roma2) { FactoryGirl.create(:crop, :name => 'Roma tomato 2', :parent => crop) }
let!(:roma3) { FactoryGirl.create(:crop, :name => 'Roma tomato 3', :parent => crop) }
let!(:roma4) { FactoryGirl.create(:crop, :name => 'Roma tomato 4', :parent => crop) }
let!(:roma1) { create :crop, name: 'Roma tomato 1', parent: crop }
let!(:roma2) { create :crop, name: 'Roma tomato 2', parent: crop }
let!(:roma3) { create :crop, name: 'Roma tomato 3', parent: crop }
let!(:roma4) { create :crop, name: 'Roma tomato 4', parent: crop }
scenario "The crop has 4 varieties" do
visit crop_path(crop)
subject
within ".varieties" do
# It lists all 5 items (note: including the top level item.)
@@ -48,9 +47,9 @@ feature "crop detail page" do
end
scenario "The crop has 5 varieties, including grandchild", :js => true do
roma_child1 = FactoryGirl.create(:crop, :name => 'Roma tomato child 1', :parent => roma4)
create :crop, name: 'Roma tomato child 1', parent: roma4
visit crop_path(crop)
subject
within ".varieties" do
@@ -64,7 +63,7 @@ feature "crop detail page" do
expect(page).to have_no_selector('button', text: /Show less+/i)
# Clik "Show all" link
page.find('button', :text => /Show all+/).click
page.find('button', text: /Show all+/).click
# It lists all 6 items (note: including the top level item.)
# It HAS have "Show less" toggle link but not "Show all" link
@@ -75,7 +74,7 @@ feature "crop detail page" do
expect(page).to have_selector('button', text: /Show less+/i)
# Clik "Show less" link
page.find('button', :text => /Show less+/).click
page.find('button', text: /Show less+/).click
# It lists 5 items (note: including the top level item.)
# It HAS have "Show all" toggle link but not "Show less" link
@@ -90,7 +89,7 @@ feature "crop detail page" do
end
context "signed in member" do
let(:member) { FactoryGirl.create(:member) }
let(:member) { create :member }
background do
login_as(member)
@@ -98,27 +97,23 @@ feature "crop detail page" do
context "action buttons" do
background do
visit crop_path(crop)
end
background { subject }
scenario "has a link to plant the crop" do
expect(page).to have_link "Plant this", :href => new_planting_path(:crop_id => crop.id)
expect(page).to have_link "Plant this", href: new_planting_path(crop_id: crop.id)
end
scenario "has a link to harvest the crop" do
expect(page).to have_link "Harvest this", :href => new_harvest_path(:crop_id => crop.id)
expect(page).to have_link "Harvest this", href: new_harvest_path(crop_id: crop.id)
end
scenario "has a link to add seeds" do
expect(page).to have_link "Add seeds to stash", :href => new_seed_path(:crop_id => crop.id)
expect(page).to have_link "Add seeds to stash", href: new_seed_path(crop_id: crop.id)
end
end
context "SEO" do
background do
visit crop_path(crop)
end
background { subject }
scenario "has seed heading with SEO" do
expect(page).to have_content "Find #{ crop.name } seeds"
@@ -145,8 +140,8 @@ feature "crop detail page" do
end
context "seed quantity for a crop" do
let(:member) { FactoryGirl.create(:member) }
let(:seed) { FactoryGirl.create(:seed, :crop => crop, :quantity => 20, :owner => member)}
let(:member) { create :member }
let(:seed) { create :seed, crop: crop, quantity: 20, owner: member }
scenario "User not signed in" do
visit crop_path(seed.crop)
@@ -166,7 +161,7 @@ feature "crop detail page" do
login_as(member)
visit crop_path(seed.crop)
click_link "View your seeds"
current_path.should == seeds_by_owner_path(:owner => member.slug)
current_path.should == seeds_by_owner_path(owner: member.slug)
end
end
end

View File

@@ -2,16 +2,14 @@ require 'rails_helper'
feature "crop wranglers" do
context "signed in wrangler" do
let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3) }
let(:wrangler){crop_wranglers.first}
let!(:crops) { FactoryGirl.create_list(:crop, 2) }
let!(:requested_crop) { FactoryGirl.create(:crop_request) }
let!(:rejected_crop) { FactoryGirl.create(:rejected_crop) }
let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 }
let(:wrangler) { crop_wranglers.first }
let!(:crops) { create_list :crop, 2 }
let!(:requested_crop) { create :crop_request }
let!(:rejected_crop) { create :rejected_crop }
background { login_as wrangler }
background do
login_as(wrangler)
end
scenario "sees crop wranglers listed on the crop wrangler page" do
visit root_path
click_link 'Crop Wrangling'
@@ -19,11 +17,11 @@ feature "crop wranglers" do
within '.crop_wranglers' do
expect(page).to have_content 'Crop Wranglers:'
crop_wranglers.each do |crop_wrangler|
page.should have_link crop_wrangler.login_name, :href => member_path(crop_wrangler)
expect(page).to have_link crop_wrangler.login_name, href: member_path(crop_wrangler)
end
end
end
scenario "can see list of crops with extra detail of who created a crop" do
visit root_path
click_link 'Crop Wrangling'
@@ -31,14 +29,14 @@ feature "crop wranglers" do
expect(page).to have_content "#{crops.first.creator.login_name}"
end
end
scenario "visiting a crop can see wrangler links" do
visit crop_path(crops.first)
expect(page).to have_content 'You are a CROP WRANGLER'
expect(page).to have_link 'Edit crop'
expect(page).to have_link 'Delete crop'
end
scenario "can create a new crop" do
visit root_path
click_link 'Crop Wrangling'
@@ -62,21 +60,18 @@ feature "crop wranglers" do
expect(page).to have_content "This crop was rejected for the following reason: Totally fake"
end
end
context "signed in non-wrangler" do
let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3) }
let(:member) { FactoryGirl.create(:member) }
background do
login_as(member)
end
end
context "signed in non-wrangler" do
let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 }
let(:member) { create :member }
background { login_as member }
scenario "can't see wrangling page" do
visit root_path
expect(page).not_to have_link "Crop Wrangling"
end
end
end

View File

@@ -1,33 +1,28 @@
require 'rails_helper'
feature "crop wrangling button" do
let(:crop_wrangler) { create :crop_wrangling_member }
let(:member) { create :member }
let(:crop_wrangler) { FactoryGirl.create(:crop_wrangling_member) }
context "crop wrangling button" do
background do
login_as(crop_wrangler)
visit crops_path
end
scenario "has a link to crop wrangling page" do
expect(page).to have_link "Wrangle Crops", :href => wrangle_crops_path
end
context "crop wrangling button" do
background do
login_as crop_wrangler
visit crops_path
end
let(:member) { FactoryGirl.create(:member) }
context "crop wrangling button" do
background do
login_as(member)
visit crops_path
end
scenario "has no link to crop wrangling page" do
expect(page).to have_no_link "Wrangle Crops", :href => wrangle_crops_path
end
scenario "has a link to crop wrangling page" do
expect(page).to have_link "Wrangle Crops", href: wrangle_crops_path
end
end
context "crop wrangling button" do
background do
login_as member
visit crops_path
end
scenario "has no link to crop wrangling page" do
expect(page).to have_no_link "Wrangle Crops", href: wrangle_crops_path
end
end
end

View File

@@ -1,7 +1,6 @@
require 'spec_helper'
feature "irregular crop inflections" do
# We're just testing a couple of representative crops to
# check that inflection works: you don't need to add
# every crop here.
@@ -9,5 +8,4 @@ feature "irregular crop inflections" do
expect("kale".pluralize).to eq "kale"
expect("broccoli".pluralize).to eq "broccoli"
end
end

View File

@@ -1,11 +1,9 @@
require 'rails_helper'
feature "Requesting a new crop" do
context "As a regular member" do
let(:member) { FactoryGirl.create(:member) }
let!(:wrangler) { FactoryGirl.create(:crop_wrangling_member) }
let(:member) { create :member }
let!(:wrangler) { create :crop_wrangling_member }
background do
login_as member
@@ -18,23 +16,18 @@ feature "Requesting a new crop" do
click_button "Save"
expect(page).to have_content "Crop was successfully requested."
end
end
context "As a crop wrangler" do
let(:wrangler) { create :crop_wrangling_member }
let!(:crop) { create :crop_request }
let!(:already_approved) { create :crop }
let(:wrangler) { FactoryGirl.create(:crop_wrangling_member) }
let!(:crop) { FactoryGirl.create(:crop_request) }
let!(:already_approved) { FactoryGirl.create(:crop) }
background do
login_as wrangler
end
background { login_as wrangler }
scenario "Approve a request" do
visit edit_crop_path(crop)
select "approved", from: "Approval status"
save_and_open_page
click_button "Save"
expect(page).to have_content "En wikipedia url is not a valid English Wikipedia URL"
fill_in "en_wikipedia_url", with: "http://en.wikipedia.org/wiki/Aung_San_Suu_Kyi"
@@ -49,7 +42,5 @@ feature "Requesting a new crop" do
click_button "Save"
expect(page).to have_content "Crop was successfully updated."
end
end
end

View File

@@ -1,9 +1,8 @@
require 'rails_helper'
feature "follows", :js => true do
feature "follows", :js do
context "when signed out" do
let(:member) { FactoryGirl.create(:member) }
let(:member) { create :member }
scenario "follow buttons on member profile page" do
visit member_path(member)
@@ -13,8 +12,8 @@ feature "follows", :js => true do
end
context "when signed in" do
let(:member) { FactoryGirl.create(:member) }
let(:other_member) { FactoryGirl.create(:member) }
let(:member) { create :member }
let(:other_member) { create :member }
background do
login_as(member)
@@ -32,13 +31,13 @@ feature "follows", :js => true do
end
scenario "has a follow button" do
expect(page).to have_link "Follow", :href => follows_path(:followed_id => other_member.id)
expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id)
end
scenario "has correct message and unfollow button" do
click_link 'Follow'
expect(page).to have_content "Followed #{other_member.login_name}"
expect(page).to have_link "Unfollow", :href => follow_path(member.get_follow(other_member))
expect(page).to have_link "Unfollow", href: follow_path(member.get_follow(other_member))
end
scenario "has a followed member listed in the following page" do
@@ -48,9 +47,7 @@ feature "follows", :js => true do
end
scenario "does not die when passed an authenticity_token" do
visit member_follows_path(
member,
:params => {:authenticity_token => "Ultima ratio regum"})
visit member_follows_path member, params: { authenticity_token: "Ultima ratio regum" }
expect(page.status_code).to equal 200
end
@@ -59,7 +56,7 @@ feature "follows", :js => true do
click_link 'Unfollow'
expect(page).to have_content "Unfollowed #{other_member.login_name}"
visit member_path(other_member) # unfollowing redirects to root
expect(page).to have_link "Follow", :href => follows_path(:followed_id => other_member.id)
expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id)
end
scenario "has member in following list" do
@@ -82,8 +79,6 @@ feature "follows", :js => true do
visit member_followers_path(other_member)
expect(page).to have_content "#{member.login_name}"
end
end
end
end

View File

@@ -1,13 +1,13 @@
require 'rails_helper'
feature "Planting a crop", :js => true do
let!(:garden) { FactoryGirl.create(:garden) }
let!(:planting) { FactoryGirl.create(:planting, garden: garden, planted_at: Date.parse("2013-3-10")) }
let!(:tomato) { FactoryGirl.create(:tomato) }
let!(:finished_planting) { FactoryGirl.create(:finished_planting, garden: garden, crop: tomato) }
let!(:garden) { create :garden }
let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") }
let!(:tomato) { create :tomato }
let!(:finished_planting) { create :finished_planting, garden: garden, crop: tomato }
background do
login_as(garden.owner)
login_as garden.owner
end
scenario "View gardens" do
@@ -30,7 +30,7 @@ feature "Planting a crop", :js => true do
scenario "Create new garden" do
visit new_garden_path
fill_in "Name", :with => "New garden"
fill_in "Name", with: "New garden"
click_button "Save"
expect(page).to have_content "Garden was successfully created"
expect(page).to have_content "New garden"
@@ -38,8 +38,8 @@ feature "Planting a crop", :js => true do
scenario "Refuse to create new garden with negative area" do
visit new_garden_path
fill_in "Name", :with => "Negative Garden"
fill_in "Area", :with => -5
fill_in "Name", with: "Negative Garden"
fill_in "Area", with: -5
click_button "Save"
expect(page).not_to have_content "Garden was successfully created"
expect(page).to have_content "Area must be greater than or equal to 0"
@@ -47,10 +47,10 @@ feature "Planting a crop", :js => true do
scenario "Edit garden" do
visit new_garden_path
fill_in "Name", :with => "New garden"
fill_in "Name", with: "New garden"
click_button "Save"
click_link "Edit garden"
fill_in "Name", :with => "Different name"
fill_in "Name", with: "Different name"
click_button "Save"
expect(page).to have_content "Garden was successfully updated"
expect(page).to have_content "Different name"
@@ -58,7 +58,7 @@ feature "Planting a crop", :js => true do
scenario "Delete garden" do
visit new_garden_path
fill_in "Name", :with => "New garden"
fill_in "Name", with: "New garden"
click_button "Save"
visit garden_path(Garden.last)
click_link "Delete garden"
@@ -67,7 +67,7 @@ feature "Planting a crop", :js => true do
end
describe "Making a planting inactive from garden show" do
let(:path) { garden_path(garden) }
let(:path) { garden_path garden }
let(:link_text) { "Mark as finished" }
it_behaves_like "append date"
end
@@ -76,5 +76,4 @@ feature "Planting a crop", :js => true do
visit gardens_path
expect(page).not_to have_content finished_planting.crop_name
end
end

View File

@@ -1,25 +1,25 @@
require 'rails_helper'
feature "Harvesting a crop", :js => true do
let(:member) { FactoryGirl.create(:member) }
let!(:maize) { FactoryGirl.create(:maize) }
feature "Harvesting a crop", :js do
let(:member) { create :member }
let!(:maize) { create :maize }
background do
login_as member
visit new_harvest_path
sync_elasticsearch([maize])
sync_elasticsearch [maize]
end
it_behaves_like "crop suggest", "harvest", "crop"
scenario "Creating a new harvest", :js => true do
fill_autocomplete "crop", :with => "mai"
scenario "Creating a new harvest" do
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_harvest" do
fill_in "When?", :with => "2014-06-15"
fill_in "How many?", :with => 42
fill_in "Weighing (in total):", :with => 42
fill_in "Notes", :with => "It's killer."
fill_in "When?", with: "2014-06-15"
fill_in "How many?", with: 42
fill_in "Weighing (in total):", with: 42
fill_in "Notes", with: "It's killer."
click_button "Save"
end
@@ -29,7 +29,7 @@ feature "Harvesting a crop", :js => true do
scenario "Clicking link to owner's profile" do
visit harvests_by_owner_path(member)
click_link "View #{member}'s profile >>"
current_path.should eq member_path(member)
expect(current_path).to eq member_path member
end
scenario "Harvesting from crop page" do
@@ -45,7 +45,7 @@ feature "Harvesting a crop", :js => true do
end
context "Editing a harvest" do
let(:existing_harvest) { FactoryGirl.create(:harvest, :crop => maize, :owner => member) }
let(:existing_harvest) { create :harvest, crop: maize, owner: member }
background do
visit harvest_path(existing_harvest)
@@ -59,8 +59,6 @@ feature "Harvesting a crop", :js => true do
expect(page).to have_content "Harvest was successfully updated"
expect(page).to have_content "maize"
end
end
end

View File

@@ -2,15 +2,12 @@ require 'rails_helper'
feature "Changing locales" do
after do
I18n.locale = :en
end
after { I18n.locale = :en }
scenario "Locale can be set with a query param" do
visit root_path
expect(page).to have_content("a community of food gardeners.")
visit root_path(:locale => 'ja')
visit root_path(locale: 'ja')
expect(page).to have_content("はガーデナーのコミュニティです。")
end
end

View File

@@ -1,18 +1,17 @@
require 'rails_helper'
feature "member profile" do
context "signed out member" do
let(:member) { FactoryGirl.create(:member) }
let(:member) { create :member }
scenario "basic details on member profile page" do
visit member_path(member)
expect(page).to have_css("h1", :text => member.login_name)
expect(page).to have_css("h1", text: member.login_name)
expect(page).to have_content member.bio
expect(page).to have_content "Member since: #{member.created_at.to_s(:date)}"
expect(page).to have_content "Account type: Free account"
expect(page).to have_content "#{member.login_name}'s gardens"
expect(page).to have_link "More about this garden...", :href => garden_path(member.gardens.first)
expect(page).to have_link "More about this garden...", href: garden_path(member.gardens.first)
end
scenario "no bio" do
@@ -29,9 +28,9 @@ feature "member profile" do
context "location" do
scenario "member has set location" do
london_member = FactoryGirl.create(:london_member)
london_member = create :london_member
visit member_path(london_member)
expect(page).to have_css("h1>small", :text => london_member.location)
expect(page).to have_css("h1>small", text: london_member.location)
expect(page).to have_css("#membermap")
expect(page).to have_content "See other members near #{london_member.location}"
end
@@ -47,7 +46,7 @@ feature "member profile" do
context "email privacy" do
scenario "public email address" do
public_member = FactoryGirl.create(:public_member)
public_member = create :public_member
visit member_path(public_member)
expect(page).to have_content public_member.email
end
@@ -59,7 +58,7 @@ feature "member profile" do
context "email privacy" do
scenario "public email address" do
public_member = FactoryGirl.create(:public_member)
public_member = create :public_member
visit member_path(public_member)
expect(page).to have_content public_member.email
end
@@ -81,36 +80,35 @@ feature "member profile" do
end
scenario "with some activity" do
FactoryGirl.create_list(:planting, 2, :owner => member)
FactoryGirl.create_list(:harvest, 3, :owner => member)
FactoryGirl.create_list(:seed, 4, :owner => member)
FactoryGirl.create_list(:post, 5, :author => member)
create_list :planting, 2, owner: member
create_list :harvest, 3, owner: member
create_list :seed, 4, owner: member
create_list :post, 5, author: member
visit member_path(member)
expect(page).to have_link "2 plantings", :href => plantings_by_owner_path(:owner => member)
expect(page).to have_link "3 harvests", :href => harvests_by_owner_path(:owner => member)
expect(page).to have_link "4 seeds", :href => seeds_by_owner_path(:owner => member)
expect(page).to have_link "5 posts", :href => posts_by_author_path(:author => member)
expect(page).to have_link "2 plantings", href: plantings_by_owner_path(owner: member)
expect(page).to have_link "3 harvests", href: harvests_by_owner_path(owner: member)
expect(page).to have_link "4 seeds", href: seeds_by_owner_path(owner: member)
expect(page).to have_link "5 posts", href: posts_by_author_path(author: member)
end
end
scenario "twitter link" do
twitter_auth = FactoryGirl.create(:authentication, :member => member)
twitter_auth = create :authentication, member: member
visit member_path(member)
expect(page).to have_link twitter_auth.name, :href => "http://twitter.com/#{twitter_auth.name}"
expect(page).to have_link twitter_auth.name, href: "http://twitter.com/#{twitter_auth.name}"
end
scenario "flickr link" do
flickr_auth = FactoryGirl.create(:flickr_authentication, :member => member)
flickr_auth = create :flickr_authentication, member: member
visit member_path(member)
expect(page).to have_link flickr_auth.name, :href => "http://flickr.com/photos/#{flickr_auth.uid}"
expect(page).to have_link flickr_auth.name, href: "http://flickr.com/photos/#{flickr_auth.uid}"
end
end
context "signed in member" do
let(:member) { FactoryGirl.create(:member) }
let(:other_member) { FactoryGirl.create(:member) }
let(:member) { create :member }
let(:other_member) { create :member }
background do
login_as(member)
@@ -122,17 +120,16 @@ feature "member profile" do
end
scenario "has a link to create new garden" do
expect(page).to have_link "New Garden", :href => new_garden_path
expect(page).to have_link "New Garden", href: new_garden_path
end
scenario "has a button to edit profile" do
expect(page).to have_link "Edit profile", :href => edit_member_registration_path
expect(page).to have_link "Edit profile", href: edit_member_registration_path
end
scenario "has a button to upgrade account" do
expect(page).to have_link "Upgrade account", :href => shop_path
expect(page).to have_link "Upgrade account", href: shop_path
end
end
context "someone else's profile page" do
@@ -141,9 +138,8 @@ feature "member profile" do
end
scenario "has a private message button" do
expect(page).to have_link "Send message", :href => new_notification_path(:recipient_id => other_member.id)
expect(page).to have_link "Send message", href: new_notification_path(:recipient_id => other_member.id)
end
end
context "home page" do
@@ -152,9 +148,8 @@ feature "member profile" do
end
scenario "does not have a button to edit profile" do
expect(page).to_not have_link "Edit profile", :href => edit_member_registration_path
expect(page).to_not have_link "Edit profile", href: edit_member_registration_path
end
end
end
end

View File

@@ -1,11 +1,10 @@
require 'rails_helper'
feature "members list" do
context "list all members" do
let! (:member1) { FactoryGirl.create(:member, :login_name => "Archaeopteryx", :confirmed_at => Time.zone.parse('2013-02-10')) }
let! (:member2) { FactoryGirl.create(:member, :login_name => "Zephyrosaurus", :confirmed_at => Time.zone.parse('2014-01-11')) }
let! (:member3) { FactoryGirl.create(:member, :login_name => "Testingname", :confirmed_at => Time.zone.parse('2014-05-09')) }
let!(:member1) { create :member, login_name: "Archaeopteryx", confirmed_at: Time.zone.parse('2013-02-10') }
let!(:member2) { create :member, login_name: "Zephyrosaurus", confirmed_at: Time.zone.parse('2014-01-11') }
let!(:member3) { create :member, login_name: "Testingname", confirmed_at: Time.zone.parse('2014-05-09') }
scenario "default alphabetical sort" do
visit members_path
@@ -26,10 +25,6 @@ feature "members list" do
all_links = page.all("#maincontainer p")
expect(all_links.first).to have_text member3.login_name
expect(all_links.last).to have_text member1.login_name
end
end
end
end

View File

@@ -1,14 +1,20 @@
require 'rails_helper'
feature "Notifications", :js => true do
let(:sender) { FactoryGirl.create(:member) }
let(:recipient) { FactoryGirl.create(:member) }
feature "Notifications", :js do
let(:sender) { create :member }
let(:recipient) { create :member }
context "On existing notification" do
let!(:notification) { FactoryGirl.create(:notification, sender: sender, recipient: recipient, body: "Notification body", :post_id => nil) }
let!(:notification) {
create :notification,
sender: sender,
recipient: recipient,
body: "Notification body",
post_id: nil
}
background do
login_as(recipient)
login_as recipient
visit notification_path(notification)
end

View File

@@ -1,48 +1,42 @@
require 'rails_helper'
feature "show photo page" do
let (:photo) { FactoryGirl.create(:photo) }
let(:photo) { create :photo }
context "signed in member" do
let (:member) { FactoryGirl.create(:member) }
let(:member) { create :member }
background do
login_as member
end
background { login_as member }
context "linked to planting" do
let (:planting) { FactoryGirl.create(:planting) }
let(:planting) { create :planting }
scenario "shows linkback to planting" do
planting.photos << photo
visit photo_path(photo)
expect(page).to have_link planting, :href => planting_path(planting)
expect(page).to have_link planting, href: planting_path(planting)
end
end
context "linked to harvest" do
let (:harvest) { FactoryGirl.create(:harvest) }
let(:harvest) { create :harvest }
scenario "shows linkback to harvest" do
harvest.photos << photo
visit photo_path(photo)
expect(page).to have_link harvest, :href => harvest_path(harvest)
expect(page).to have_link harvest, href: harvest_path(harvest)
end
end
context "linked to garden" do
let (:garden) { FactoryGirl.create(:garden) }
let(:garden) { create :garden }
scenario "shows linkback to garden" do
garden.photos << photo
visit photo_path(photo)
expect(page).to have_link garden, :href => garden_path(garden)
expect(page).to have_link garden, href: garden_path(garden)
end
end
end
end

View File

@@ -1,64 +1,61 @@
require "rails_helper"
RSpec.feature "User searches", :type => :feature do
let(:member) { FactoryGirl.create(:member, location: "Philippines") }
let!(:maize) { FactoryGirl.create(:maize) }
let(:garden) { FactoryGirl.create(:garden, owner: member) }
let!(:seed1) { FactoryGirl.create(:seed, owner: member) }
let!(:planting){ FactoryGirl.create(:planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10")) }
feature "User searches" do
let(:member) { create :member, location: "Philippines" }
let!(:maize) { create :maize }
let(:garden) { create :garden, owner: member }
let!(:seed1) { create :seed, owner: member }
let!(:planting) { create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") }
scenario "with a valid place" do
visit places_path
search_with("Philippines")
expect(page).to have_content "members near Philippines"
expect(page).to have_button "search_button"
page.has_content?('placesmap')
expect(page).to have_content "Nearby members"
expect(page).to_not have_content "No results found"
end
scenario "with a valid place" do
visit places_path
search_with "Philippines"
expect(page).to have_content "members near Philippines"
expect(page).to have_button "search_button"
expect(page).to have_content "Nearby members"
expect(page).to_not have_content "No results found"
end
scenario "with a blank search string" do
visit places_path
search_with("")
expect(page).to have_content "Please enter a valid location"
expect(page).to have_button "search_button"
page.has_content?('placesmap')
end
scenario "with a blank search string" do
visit places_path
search_with ""
expect(page).to have_content "Please enter a valid location"
expect(page).to have_button "search_button"
end
describe "Nearby plantings, seed, and members" do
before(:each) do
login_as(member)
visit places_path
search_with("Philippines")
end
describe "Nearby plantings, seed, and members" do
before do
login_as member
visit places_path
search_with "Philippines"
end
it "should show that there are nearby seeds, plantings, and members" do
expect(page).to have_content "Nearby members"
expect(page).to have_content "Seeds available for trade near Philippines"
expect(page).to have_content "Recent plantings near Philippines"
find_link("View all members").visible?
find_link("View all seeds").visible?
find_link("View all plantings").visible?
end
it "should show that there are nearby seeds, plantings, and members" do
expect(page).to have_content "Nearby members"
expect(page).to have_content "Seeds available for trade near Philippines"
expect(page).to have_content "Recent plantings near Philippines"
end
it "should go to members' index page" do
click_link('View all members >>')
current_path.should == members_path
end
it "should go to members' index page" do
click_link 'View all members >>'
expect(current_path).to eq members_path
end
it "should go to plantings' index page" do
click_link('View all plantings >>')
current_path.should == plantings_path
end
it "should go to plantings' index page" do
click_link 'View all plantings >>'
expect(current_path).to eq plantings_path
end
it "should go to seeds' index page" do
click_link('View all seeds >>')
current_path.should == seeds_path
end
end
it "should go to seeds' index page" do
click_link 'View all seeds >>'
expect(current_path).to eq seeds_path
end
end
def search_with(search_string)
fill_in "new_place", :with => search_string
click_button "search_button"
end
private
def search_with(search_string)
fill_in "new_place", with: search_string
click_button "search_button"
end
end

View File

@@ -1,8 +1,8 @@
require 'rails_helper'
require 'capybara/email/rspec'
feature "Planting reminder email", :js => true do
let(:member) { FactoryGirl.create(:member) }
feature "Planting reminder email", :js do
let(:member) { create :member }
let(:mail) { Notifier.planting_reminder(member) }
# Unfortunately, we can't use the default url options for ActionMailer as configured in
@@ -23,25 +23,16 @@ feature "Planting reminder email", :js => true do
scenario "doesn't list plantings" do
expect(mail).not_to have_content "most recent plantings you've told us about"
end
end
context "when member has some plantings" do
before :each do
@p1 = FactoryGirl.create(:planting,
:garden => member.gardens.first,
:owner => member
)
@p2 = FactoryGirl.create(:planting,
:garden => member.gardens.first,
:owner => member
)
end
let(:p1) { create :planting, garden: member.gardens.first, owner: member }
let(:p2) { create :planting, garden: member.gardens.first, owner: member }
scenario "lists plantings" do
expect(mail).to have_content "most recent plantings you've told us about"
expect(mail).to have_link @p1.to_s, planting_url(@p1)
expect(mail).to have_link @p2.to_s, planting_url(@p2)
expect(mail).to have_link p1.to_s, planting_url(p1)
expect(mail).to have_link p2.to_s, planting_url(p2)
expect(mail).to have_content "keep your garden records up to date"
end
end
@@ -54,26 +45,17 @@ feature "Planting reminder email", :js => true do
scenario "doesn't list plantings" do
expect(mail).not_to have_content "the last few things you harvested were"
end
end
context "when member has some harvests" do
before :each do
@h1 = FactoryGirl.create(:harvest,
:owner => member
)
@h2 = FactoryGirl.create(:harvest,
:owner => member
)
end
let(:h1) { create :harvest, owner: member }
let(:h2) { create :harvest, owner: member }
scenario "lists harvests" do
expect(mail).to have_content "the last few things you harvested were"
expect(mail).to have_link @h1.to_s, harvest_url(@h1)
expect(mail).to have_link @h2.to_s, harvest_url(@h2)
expect(mail).to have_link h1.to_s, harvest_url(h1)
expect(mail).to have_link h2.to_s, harvest_url(h2)
expect(mail).to have_content "Harvested anything else lately?"
end
end
end

View File

@@ -1,28 +1,28 @@
require "rails_helper"
feature "Planting a crop", :js => true do
let(:member) { FactoryGirl.create(:member) }
let!(:maize) { FactoryGirl.create(:maize) }
let(:garden) { FactoryGirl.create(:garden, owner: member) }
let!(:planting) { FactoryGirl.create(:planting, garden: garden, planted_at: Date.parse("2013-3-10")) }
feature "Planting a crop", :js do
let(:member) { create :member }
let!(:maize) { create :maize }
let(:garden) { create :garden, owner: member }
let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") }
background do
login_as member
visit new_planting_path
sync_elasticsearch([maize])
sync_elasticsearch [maize]
end
it_behaves_like "crop suggest", "planting"
scenario "Creating a new planting" do
fill_autocomplete "crop", :with => "mai"
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
fill_in "When", :with => "2014-06-15"
fill_in "How many?", :with => 42
select "cutting", :from => "Planted from:"
select "semi-shade", :from => "Sun or shade?"
fill_in "Tell us more about it", :with => "It's rad."
fill_in "When", with: "2014-06-15"
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
select "semi-shade", from: "Sun or shade?"
fill_in "Tell us more about it", with: "It's rad."
click_button "Save"
end
@@ -33,26 +33,25 @@ feature "Planting a crop", :js => true do
scenario "Clicking link to owner's profile" do
visit plantings_by_owner_path(member)
click_link "View #{member}'s profile >>"
current_path.should eq member_path(member)
expect(current_path).to eq member_path(member)
end
describe "Progress bar status on planting creation" do
before(:each) do
DateTime.stub(:now){DateTime.new(2015, 10, 20, 10, 34)}
login_as(member)
before do
DateTime.stub(:now) { DateTime.new(2015, 10, 20, 10, 34) }
login_as member
visit new_planting_path
sync_elasticsearch([maize])
end
it "should show that it is not planted yet" do
fill_autocomplete "crop", :with => "mai"
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
fill_in "When", :with => "2015-12-15"
fill_in "How many?", :with => 42
select "cutting", :from => "Planted from:"
select "semi-shade", :from => "Sun or shade?"
fill_in "Tell us more about it", :with => "It's rad."
fill_in "When", with: "2015-12-15"
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
select "semi-shade", from: "Sun or shade?"
fill_in "Tell us more about it", with: "It's rad."
click_button "Save"
end
@@ -61,14 +60,14 @@ feature "Planting a crop", :js => true do
end
it "should show that days before maturity is unknown" do
fill_autocomplete "crop", :with => "mai"
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
fill_in "When", :with => "2015-9-15"
fill_in "How many?", :with => 42
select "cutting", :from => "Planted from:"
select "semi-shade", :from => "Sun or shade?"
fill_in "Tell us more about it", :with => "It's rad."
fill_in "When", with: "2015-9-15"
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
select "semi-shade", from: "Sun or shade?"
fill_in "Tell us more about it", with: "It's rad."
click_button "Save"
end
@@ -78,15 +77,15 @@ feature "Planting a crop", :js => true do
end
it "should show that planting is in progress" do
fill_autocomplete "crop", :with => "mai"
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
fill_in "When", :with => "2015-10-15"
fill_in "How many?", :with => 42
select "cutting", :from => "Planted from:"
select "semi-shade", :from => "Sun or shade?"
fill_in "Tell us more about it", :with => "It's rad."
fill_in "Finished date", :with => "2015-10-30"
fill_in "When", with: "2015-10-15"
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
select "semi-shade", from: "Sun or shade?"
fill_in "Tell us more about it", with: "It's rad."
fill_in "Finished date", with: "2015-10-30"
click_button "Save"
end
@@ -96,14 +95,14 @@ feature "Planting a crop", :js => true do
end
it "should show that planting is 100% complete (no date specified)" do
fill_autocomplete "crop", :with => "mai"
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
fill_in "When", :with => "2015-10-15"
fill_in "How many?", :with => 42
select "cutting", :from => "Planted from:"
select "semi-shade", :from => "Sun or shade?"
fill_in "Tell us more about it", :with => "It's rad."
fill_in "When", with: "2015-10-15"
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
select "semi-shade", from: "Sun or shade?"
fill_in "Tell us more about it", with: "It's rad."
check "Mark as finished"
click_button "Save"
end
@@ -115,15 +114,15 @@ feature "Planting a crop", :js => true do
end
it "should show that planting is 100% complete (date specified)" do
fill_autocomplete "crop", :with => "mai"
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
fill_in "When", :with => "2015-10-15"
fill_in "How many?", :with => 42
select "cutting", :from => "Planted from:"
select "semi-shade", :from => "Sun or shade?"
fill_in "Tell us more about it", :with => "It's rad."
fill_in "Finished date", :with => "2015-10-19"
fill_in "When", with: "2015-10-15"
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
select "semi-shade", from: "Sun or shade?"
fill_in "Tell us more about it", with: "It's rad."
fill_in "Finished date", with: "2015-10-19"
click_button "Save"
end
@@ -144,11 +143,11 @@ feature "Planting a crop", :js => true do
expect(page).to have_content "Planting was successfully created"
expect(page).to have_content "maize"
end
scenario "Editing a planting to add details" do
visit planting_path(planting)
click_link "Edit"
fill_in "Tell us more about it", :with => "Some extra notes"
fill_in "Tell us more about it", with: "Some extra notes"
click_button "Save"
expect(page).to have_content "Planting was successfully updated"
end
@@ -158,37 +157,37 @@ feature "Planting a crop", :js => true do
expect(page).to have_content "Progress: 0% - Days before maturity unknown"
click_link "Edit"
check "finished"
fill_in "Finished date", :with => "2015-06-25"
fill_in "Finished date", with: "2015-06-25"
click_button "Save"
expect(page).to have_content "Planting was successfully updated"
expect(page).to_not have_content "Progress: 0% - Days before maturity unknown"
end
scenario "Marking a planting as finished" do
fill_autocomplete "crop", :with => "mai"
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
fill_in "When?", :with => "2014-07-01"
fill_in "When?", with: "2014-07-01"
check "Mark as finished"
fill_in "Finished date", :with => "2014-08-30"
fill_in "Finished date", with: "2014-08-30"
# Trigger click instead of using Capybara"s uncheck
# because a date selection widget is overlapping
# the checkbox preventing interaction.
page.find("#planting_finished").trigger("click")
find("#planting_finished").trigger 'click'
end
# Javascript removes the finished at date when the
# planting is marked unfinished.
expect(page.find("#planting_finished_at").value).to eq("")
expect(find("#planting_finished_at").value).to eq("")
within "form#new_planting" do
page.find("#planting_finished").trigger("click")
find("#planting_finished").trigger 'click'
end
# The finished at date was cached in Javascript in
# case the user clicks unfinished accidentally.
expect(page.find("#planting_finished_at").value).to eq("2014-08-30")
expect(find("#planting_finished_at").value).to eq("2014-08-30")
within "form#new_planting" do
click_button "Save"
@@ -201,7 +200,7 @@ feature "Planting a crop", :js => true do
end
scenario "Marking a planting as finished without a date" do
fill_autocomplete "crop", :with => "mai"
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
check "Mark as finished"
@@ -214,50 +213,50 @@ feature "Planting a crop", :js => true do
describe "Planting sunniness" do
it "should show the image sunniness_sun.png" do
fill_autocomplete "crop", :with => "mai"
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
fill_in "When", :with => "2015-10-15"
fill_in "How many?", :with => 42
select "cutting", :from => "Planted from:"
select "sun", :from => "Sun or shade?"
fill_in "Tell us more about it", :with => "It's rad."
fill_in "When", with: "2015-10-15"
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
select "sun", from: "Sun or shade?"
fill_in "Tell us more about it", with: "It's rad."
check "Mark as finished"
click_button "Save"
end
expect(page).to have_css("img[src*='sunniness_sun.png']")
page.should have_css("img[alt=sun]")
expect(page).to have_css("img[alt=sun]")
end
it "should show the image 'not specified.png'" do
fill_autocomplete "crop", :with => "mai"
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
fill_in "When", :with => "2015-10-15"
fill_in "How many?", :with => 42
select "cutting", :from => "Planted from:"
fill_in "Tell us more about it", :with => "It's rad."
fill_in "When", with: "2015-10-15"
fill_in "How many?", with: 42
select "cutting", from: "Planted from:"
fill_in "Tell us more about it", with: "It's rad."
check "Mark as finished"
click_button "Save"
end
expect(page).to have_css("img[src*='sunniness_not specified.png']")
page.should have_css("img[alt='not specified']")
expect(page).to have_css("img[alt='not specified']")
end
end
describe "Marking a planting as finished from the show page" do
let(:path) { planting_path(planting) }
let(:path) { planting_path(planting) }
let(:link_text) { "Mark as finished" }
it_behaves_like "append date"
end
describe "Marking a planting as finished from the list page" do
let(:path) { plantings_path }
let(:path) { plantings_path }
let(:link_text) { "Mark as finished" }
it_behaves_like "append date"
end
end

View File

@@ -1,34 +1,33 @@
require 'rails_helper'
feature 'Post a post' do
let(:member) { FactoryGirl.create(:member) }
let(:member) { create :member }
background do
login_as(member)
login_as member
visit new_post_path
end
scenario "creating a post" do
fill_in "post_subject", :with => "Testing"
fill_in "post_body", :with => "This is a sample test"
fill_in "post_subject", with: "Testing"
fill_in "post_body", with: "This is a sample test"
click_button "Post"
expect(page).to have_content "Post was successfully created"
expect(page).to have_content "Posted by"
end
context "editing a post" do
let(:existing_post) { FactoryGirl.create(:post, :author => member)}
let(:existing_post) { create :post, author: member }
background do
visit edit_post_path(existing_post)
end
scenario "saving edit" do
fill_in "post_subject", :with => "Testing Edit"
click_button "Post"
fill_in "post_subject", with: "Testing Edit"
click_button "Post"
expect(page).to have_content "Post was successfully updated"
expect(page).to have_content "Edited by"
end
end
end

View File

@@ -1,13 +1,13 @@
require 'spec_helper'
require 'rails_helper'
feature 'Comments RSS feed' do
scenario 'The index feed exists' do
visit comments_path(:format => 'rss')
visit comments_path(format: 'rss')
expect(page.status_code).to equal 200
end
scenario 'The index title is what we expect' do
visit comments_path(:format => 'rss')
visit comments_path(format: 'rss')
expect(page).to have_content "Recent comments on all posts (#{ENV['GROWSTUFF_SITE_NAME']})"
end
end

View File

@@ -1,13 +1,13 @@
require 'spec_helper'
require 'rails_helper'
feature 'Crops RSS feed' do
scenario 'The index feed exists' do
visit crops_path(:format => 'rss')
visit crops_path(format: 'rss')
expect(page.status_code).to equal 200
end
scenario 'The index title is what we expect' do
visit crops_path(:format => 'rss')
visit crops_path(format: 'rss')
expect(page).to have_content "Recently added crops (#{ENV['GROWSTUFF_SITE_NAME']})"
end
end

View File

@@ -1,15 +1,15 @@
require 'spec_helper'
require 'rails_helper'
feature 'Members RSS feed' do
let(:member) { FactoryGirl.create(:member) }
let(:member) { create :member }
scenario 'The show action exists' do
visit member_path(member, :format => 'rss')
visit member_path(member, format: 'rss')
expect(page.status_code).to equal 200
end
scenario 'The show action title is what we expect' do
visit member_path(member, :format => 'rss')
visit member_path(member, format: 'rss')
expect(page).to have_content "#{member.login_name}'s recent posts (#{ENV['GROWSTUFF_SITE_NAME']})"
end
end

View File

@@ -1,13 +1,13 @@
require 'spec_helper'
require 'rails_helper'
feature 'Plantings RSS feed' do
scenario 'The index feed exists' do
visit plantings_path(:format => 'rss')
visit plantings_path(format: 'rss')
expect(page.status_code).to equal 200
end
scenario 'The index title is what we expect' do
visit plantings_path(:format => 'rss')
visit plantings_path(format: 'rss')
expect(page).to have_content "Recent plantings from #{ @owner ? @owner : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
end
end

View File

@@ -1,13 +1,13 @@
require 'spec_helper'
require 'rails_helper'
feature 'Posts RSS feed' do
scenario 'The index feed exists' do
visit posts_path(:format => 'rss')
visit posts_path(format: 'rss')
expect(page.status_code).to equal 200
end
scenario 'The index title is what we expect' do
visit posts_path(:format => 'rss')
visit posts_path(format: 'rss')
expect(page).to have_content "Recent posts from #{ @author ? @author : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
end
end

View File

@@ -1,13 +1,13 @@
require 'spec_helper'
require 'rails_helper'
feature 'Seeds RSS feed' do
scenario 'The index feed exists' do
visit seeds_path(:format => 'rss')
visit seeds_path(format: 'rss')
expect(page.status_code).to equal 200
end
scenario 'The index title is what we expect' do
visit seeds_path(:format => 'rss')
visit seeds_path(format: 'rss')
expect(page).to have_content "Recent seeds from #{ @owner ? @owner : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
end
end

View File

@@ -1,7 +1,7 @@
require 'rails_helper'
feature "Scientific names" do
let!(:zea_mays) { FactoryGirl.create(:zea_mays) }
let!(:zea_mays) { create :zea_mays }
let(:crop) { zea_mays.crop }
scenario "Display scientific names on crop page" do
@@ -17,8 +17,8 @@ feature "Scientific names" do
end
context "User is a crop wrangler" do
let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3) }
let(:member){crop_wranglers.first}
let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 }
let(:member) { crop_wranglers.first }
background do
login_as(member)
@@ -29,7 +29,7 @@ feature "Scientific names" do
expect(page.status_code).to equal 200
expect(page).to have_content "CROP WRANGLER"
expect(page).to have_content zea_mays.scientific_name
expect(page).to have_link "Edit", :href => edit_scientific_name_path(zea_mays)
expect(page).to have_link "Edit", href: edit_scientific_name_path(zea_mays)
within('.scientific_names') { click_on "Edit" }
expect(page.status_code).to equal 200
expect(page).to have_css "option[value='#{crop.id}'][selected=selected]"
@@ -42,7 +42,7 @@ feature "Scientific names" do
scenario "Crop wranglers can delete scientific names" do
visit crop_path(zea_mays.crop)
expect(page).to have_link "Delete",
href: scientific_name_path(zea_mays)
href: scientific_name_path(zea_mays)
within('.scientific_names') { click_on "Delete" }
expect(page.status_code).to equal 200
expect(page).to_not have_content zea_mays.scientific_name
@@ -52,7 +52,7 @@ feature "Scientific names" do
scenario "Crop wranglers can add scientific names" do
visit crop_path(crop)
expect(page).to have_link "Add",
href: new_scientific_name_path(crop_id: crop.id)
href: new_scientific_name_path(crop_id: crop.id)
within('.scientific_names') { click_on "Add" }
expect(page.status_code).to equal 200
expect(page).to have_css "option[value='#{crop.id}'][selected=selected]"
@@ -67,12 +67,12 @@ feature "Scientific names" do
visit scientific_name_path(zea_mays)
expect(page.status_code).to equal 200
expect(page).to have_link zea_mays.crop.name,
href: crop_path(zea_mays.crop)
href: crop_path(zea_mays.crop)
end
context "When scientific name is pending" do
let(:pending_crop) { FactoryGirl.create(:crop_request) }
let(:pending_sci_name) { FactoryGirl.create(:scientific_name, :crop => pending_crop) }
let(:pending_crop) { create :crop_request }
let(:pending_sci_name) { create :scientific_name, crop: pending_crop }
scenario "Displays crop pending message" do
visit scientific_name_path(pending_sci_name)

View File

@@ -1,29 +1,29 @@
require 'rails_helper'
feature "Seeds", :js => true do
let(:member) { FactoryGirl.create(:member) }
let!(:maize) { FactoryGirl.create(:maize) }
feature "Seeds", :js do
let(:member) { create :member }
let!(:maize) { create :maize }
background do
login_as member
visit new_seed_path
sync_elasticsearch([maize])
sync_elasticsearch [maize]
end
it_behaves_like "crop suggest", "seed", "crop"
scenario "Adding a new seed", :js => true do
fill_autocomplete "crop", :with => "mai"
scenario "Adding a new seed" do
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_seed" do
fill_in "Quantity:", :with => 42
fill_in "Plant before:", :with => "2014-06-15"
fill_in "Days until maturity:", :with => 999
fill_in "to", :with => 1999
fill_in "Quantity:", with: 42
fill_in "Plant before:", with: "2014-06-15"
fill_in "Days until maturity:", with: 999
fill_in "to", with: 1999
select "certified organic", :from => "Organic?"
select "non-certified GMO-free", :from => "GMO?"
select "heirloom", :from => "Heirloom?"
fill_in "Description", :with => "It's killer."
fill_in "Description", with: "It's killer."
select "internationally", :from => "Will trade:"
click_button "Save"
end
@@ -48,5 +48,4 @@ feature "Seeds", :js => true do
expect(page).to have_content "Successfully added maize seed to your stash"
expect(page).to have_content "maize"
end
end
end

View File

@@ -2,77 +2,75 @@ require 'rails_helper'
feature "seeds" do
context "signed in user" do
let(:member) { @member = FactoryGirl.create(:member) }
let(:crop) { FactoryGirl.create(:crop) }
let(:member) { create :member }
let(:crop) { create :crop }
background do
login_as member
end
scenario "button on index to edit seed" do
seed = FactoryGirl.create(:seed, :owner => @member)
seed = create :seed, owner: member
visit seeds_path
click_link "Edit"
current_path.should eq edit_seed_path(seed)
page.should have_content 'Editing seeds'
expect(current_path).to eq edit_seed_path(seed)
expect(page).to have_content 'Editing seeds'
end
scenario "button on front page to add seeds" do
visit root_path
click_link "Add seeds"
current_path.should eq new_seed_path
page.should have_content 'Add seeds'
expect(current_path).to eq new_seed_path
expect(page).to have_content 'Add seeds'
end
scenario "Clicking link to owner's profile" do
visit seeds_by_owner_path(member)
click_link "View #{member}'s profile >>"
current_path.should eq member_path(member)
expect(current_path).to eq member_path(member)
end
# actually adding seeds is in spec/features/seeds_new_spec.rb
scenario "edit seeds" do
seed = FactoryGirl.create(:seed, :owner => @member)
seed = create :seed, owner: member
visit seed_path(seed)
click_link 'Edit'
current_path.should eq edit_seed_path(seed)
fill_in 'Quantity:', :with => seed.quantity * 2
expect(current_path).to eq edit_seed_path(seed)
fill_in 'Quantity:', with: seed.quantity * 2
click_button 'Save'
current_path.should eq seed_path(seed)
expect(current_path).to eq seed_path(seed)
end
scenario "delete seeds" do
seed = FactoryGirl.create(:seed, :owner => @member)
seed = create :seed, owner: member
visit seed_path(seed)
click_link 'Delete'
current_path.should eq seeds_path
expect(current_path).to eq seeds_path
end
scenario "view seeds with max and min days until maturity" do
seed = FactoryGirl.create(:seed, :days_until_maturity_min => 5, :days_until_maturity_max => 7)
seed = create :seed, days_until_maturity_min: 5, days_until_maturity_max: 7
visit seed_path(seed)
expect(page).to have_content "Days until maturity: 57"
end
scenario "view seeds with only max days until maturity" do
seed = FactoryGirl.create(:seed, :days_until_maturity_max => 7)
seed = create :seed, days_until_maturity_max: 7
visit seed_path(seed)
expect(page).to have_content "Days until maturity: 7"
end
scenario "view seeds with only min days until maturity" do
seed = FactoryGirl.create(:seed, :days_until_maturity_min => 5)
seed = create :seed, days_until_maturity_min: 5
visit seed_path(seed)
expect(page).to have_content "Days until maturity: 5"
end
scenario "view seeds with neither max nor min days until maturity" do
seed = FactoryGirl.create(:seed)
seed = create :seed
visit seed_path(seed)
expect(page).to have_content "Days until maturity: unknown"
end
end
end

View File

@@ -1,22 +1,21 @@
shared_examples "append date" do
let(:this_month) { Date.today.strftime("%B") }
let(:this_year) { Date.today.strftime("%Y") }
background { visit path }
scenario "Selecting a date with datepicker" do
this_month = Date.today.strftime("%B")
this_year = Date.today.strftime("%Y")
visit path
click_link link_text
within "div.datepicker" do
expect(page).to have_content "#{this_month}"
page.find(".datepicker-days td.day", text: "21").click
find(".datepicker-days td.day", text: "21").click
end
expect(page).to have_content "Finished: #{this_month} 21, #{this_year}"
end
scenario "Confirming without selecting date" do
visit path
click_link link_text
click_link "Confirm without date"
expect(page).to have_content("Finished: Yes (no date specified) ")
end
end

View File

@@ -1,14 +1,12 @@
require 'rails_helper'
shared_examples "crop suggest" do |resource|
let!(:pea) { FactoryGirl.create(:crop, :name => 'pea') }
let!(:pear) { FactoryGirl.create(:pear) }
let!(:tomato) { FactoryGirl.create(:tomato) }
let!(:roma) { FactoryGirl.create(:roma) }
let!(:pea) { create :crop, name: 'pea' }
let!(:pear) { create :pear }
let!(:tomato) { create :tomato }
let!(:roma) { create :roma }
background do
sync_elasticsearch([pea, pear, maize, tomato])
end
background { sync_elasticsearch [pea, pear, maize, tomato] }
scenario "placeholder text in crop auto suggest field" do
expect(page).to have_selector("input[placeholder='e.g. lettuce']")
@@ -16,21 +14,21 @@ shared_examples "crop suggest" do |resource|
scenario "typing in the crop name displays suggestions" do
within "form#new_#{resource}" do
fill_autocomplete "crop", :with => "pe"
fill_autocomplete "crop", with: "pe"
end
expect(page).to_not have_content("pear")
expect(page).to_not have_content("pea")
within "form#new_#{resource}" do
fill_autocomplete "crop", :with => "pea"
fill_autocomplete "crop", with: "pea"
end
expect(page).to have_content("pear")
expect(page).to have_content("pea")
within "form#new_#{resource}" do
fill_autocomplete "crop", :with => "pear"
fill_autocomplete "crop", with: "pear"
end
expect(page).to have_content("pear")
@@ -38,7 +36,7 @@ shared_examples "crop suggest" do |resource|
scenario "selecting crop from dropdown" do
within "form#new_#{resource}" do
fill_autocomplete "crop", :with => "pear"
fill_autocomplete "crop", with: "pear"
end
select_from_autocomplete("pear")
@@ -48,7 +46,7 @@ shared_examples "crop suggest" do |resource|
scenario "Typing and pausing does not affect input" do
within "form#new_#{resource}" do
fill_autocomplete "crop", :with => "pea"
fill_autocomplete "crop", with: "pea"
end
expect(page).to have_content("pear")
@@ -57,7 +55,7 @@ shared_examples "crop suggest" do |resource|
scenario "Searching for a crop casts a wide net on results" do
within "form#new_#{resource}" do
fill_autocomplete "crop", :with => "tom"
fill_autocomplete "crop", with: "tom"
end
expect(page).to have_content("tomato")
@@ -66,11 +64,10 @@ shared_examples "crop suggest" do |resource|
scenario "Submitting a crop that doesn't exist in the database produces a meaningful error" do
within "form#new_#{resource}" do
fill_autocomplete "crop", :with => "Ryan Gosling"
fill_autocomplete "crop", with: "Ryan Gosling"
click_button "Save"
end
expect(page).to have_content("Crop must be present and exist in our database")
end
end

View File

@@ -1,9 +1,9 @@
require 'rails_helper'
feature "signin" do
let(:member){FactoryGirl.create(:member)}
let(:recipient){FactoryGirl.create(:member)}
let(:notification){FactoryGirl.create(:notification)}
let(:member) { create :member }
let(:recipient) { create :member }
let(:notification) { create :notification }
scenario "redirect to previous page after signin" do
visit crops_path # some random page
@@ -11,7 +11,7 @@ feature "signin" do
fill_in 'Login', with: member.login_name
fill_in 'Password', with: member.password
click_button 'Sign in'
current_path.should eq crops_path
expect(current_path).to eq crops_path
end
scenario "don't redirect to devise pages after signin" do
@@ -20,34 +20,33 @@ feature "signin" do
fill_in 'Login', with: member.login_name
fill_in 'Password', with: member.password
click_button 'Sign in'
current_path.should eq root_path
expect(current_path).to eq root_path
end
scenario "redirect to signin page for if not authenticated to view notification" do
visit notification_path(notification)
current_path.should eq new_member_session_path
expect(current_path).to eq new_member_session_path
end
scenario "after signin, redirect to what you were trying to do" do
models = %w[plantings harvests posts photos gardens seeds]
models.each do |model|
visit "/#{model}/new"
current_path.should eq new_member_session_path
expect(current_path).to eq new_member_session_path
fill_in 'Login', with: member.login_name
fill_in 'Password', with: member.password
click_button 'Sign in'
current_path.should eq "/#{model}/new"
expect(current_path).to eq "/#{model}/new"
click_link 'Sign out'
end
end
scenario "after signin, redirect to new notifications page" do
visit new_notification_path(recipient: recipient)
current_path.should eq new_member_session_path
expect(current_path).to eq new_member_session_path
fill_in 'Login', with: member.login_name
fill_in 'Password', with: member.password
click_button 'Sign in'
current_path.should eq new_notification_path
expect(current_path).to eq new_notification_path
end
end

View File

@@ -1,8 +1,8 @@
require 'rails_helper'
feature "signout" do
let(:member){FactoryGirl.create(:member)}
let(:member) { create :member }
scenario "redirect to previous page after signout" do
visit crops_path # some random page
click_link 'Sign in'
@@ -10,20 +10,20 @@ feature "signout" do
fill_in 'Password', with: member.password
click_button 'Sign in'
click_link 'Sign out'
current_path.should eq crops_path
expect(current_path).to eq crops_path
end
scenario "after signout, redirect to signin page if page needs authentication" do
models = %w[plantings harvests posts photos gardens seeds]
models.each do |model|
visit "/#{model}/new"
current_path.should eq new_member_session_path
expect(current_path).to eq new_member_session_path
fill_in 'Login', with: member.login_name
fill_in 'Password', with: member.password
click_button 'Sign in'
current_path.should eq "/#{model}/new"
expect(current_path).to eq "/#{model}/new"
click_link 'Sign out'
current_path.should eq new_member_session_path
expect(current_path).to eq new_member_session_path
end
end

View File

@@ -1,7 +1,6 @@
require 'rails_helper'
feature "signup" do
scenario "sign up for new account from top menubar" do
visit crops_path # something other than front page, which has multiple signup links
click_link 'Sign up'
@@ -11,7 +10,7 @@ feature "signup" do
fill_in 'Password confirmation', with: 'abc123'
check 'member_tos_agreement'
click_button 'Sign up'
current_path.should eq root_path
expect(current_path).to eq root_path
end
scenario "sign up for new account with existing username" do
@@ -23,8 +22,7 @@ feature "signup" do
fill_in 'Password confirmation', with: 'abc123'
check 'member_tos_agreement'
click_button 'Sign up'
page.has_content? 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
current_path.should eq root_path
expect(current_path).to eq root_path
first('.signup a').click # click the 'Sign up' button in the middle of the page
fill_in 'Login name', with: 'person123'
fill_in 'Email', with: 'gardener@example.com'
@@ -32,7 +30,6 @@ feature "signup" do
fill_in 'Password confirmation', with: 'abc123'
check 'member_tos_agreement'
click_button 'Sign up'
page.has_content? 'Login name has already been taken'
end
scenario "sign up for new account without accepting TOS" do
@@ -44,8 +41,6 @@ feature "signup" do
fill_in 'Password confirmation', with: 'abc123'
# do not check 'member_tos_agreement'
click_button 'Sign up'
page.has_content? 'Tos agreement must be accepted'
current_path.should eq members_path
expect(current_path).to eq members_path
end
end

View File

@@ -2,8 +2,8 @@ require 'rails_helper'
require 'capybara/email/rspec'
feature "unsubscribe" do
let(:member) { FactoryGirl.create(:member) }
let(:notification) { FactoryGirl.create(:notification) }
let(:member) { create :member }
let(:notification) { create :notification }
background do
clear_emails

View File

@@ -82,4 +82,7 @@ RSpec.configure do |config|
# see https://github.com/plataformatec/devise/wiki/How-To%3a-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29
config.include Devise::TestHelpers, :type => :controller
config.extend ControllerMacros, :type => :controller
# Allow just create(:factory) instead of needing to specify FactoryGirl.create(:factory)
config.include FactoryGirl::Syntax::Methods
end