mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-07 23:36:15 -04:00
write feature spec that tests crop suggest functionality in new planting form
This commit is contained in:
@@ -107,6 +107,7 @@ GEM
|
||||
csv_shaper (1.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
dalli (2.7.0)
|
||||
database_cleaner (1.3.0)
|
||||
debug_inspector (0.0.2)
|
||||
debugger (1.6.6)
|
||||
columnize (>= 0.3.1)
|
||||
@@ -327,6 +328,7 @@ DEPENDENCIES
|
||||
coveralls
|
||||
csv_shaper
|
||||
dalli
|
||||
database_cleaner (~> 1.3.0)
|
||||
debugger
|
||||
devise (~> 3.0.0)
|
||||
factory_girl_rails (~> 4.0)
|
||||
|
||||
@@ -17,6 +17,8 @@ jQuery ->
|
||||
el.val( ui.item.name )
|
||||
$( '#planting_crop_id' ).val( ui.item.id )
|
||||
false
|
||||
change: ( event, ui ) ->
|
||||
console.log( event, ui )
|
||||
.data( 'uiAutocomplete' )._renderItem = ( ul, item ) ->
|
||||
$( '<li></li>' )
|
||||
.data( 'item.autocomplete', item )
|
||||
|
||||
@@ -11,17 +11,12 @@ feature "Planting a crop", :js => true do
|
||||
|
||||
scenario "Typing in the crop name displays suggestions" do
|
||||
within "form#new_planting" do
|
||||
# fill_autocomplete 'crop', with: 'm'
|
||||
fill_in 'crop', :with => "m"
|
||||
|
||||
binding.pry
|
||||
|
||||
sleep 1000
|
||||
|
||||
page.execute_script %Q{ $('#crop').trigger('focus') }
|
||||
page.execute_script %Q{ $('#crop').trigger('keydown') }
|
||||
expect(page).to have_content("maize")
|
||||
fill_autocomplete "crop", with: "m"
|
||||
end
|
||||
|
||||
expect(page).to have_content("maize")
|
||||
select_from_autocomplete("maize")
|
||||
expect(page).to have_selector("input#planting_crop_id[value='#{maize.id}']", :visible => false)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -33,7 +33,7 @@ RSpec.configure do |config|
|
||||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||
# examples within a transaction, remove the following line or assign false
|
||||
# instead of true.
|
||||
config.use_transactional_fixtures = true
|
||||
config.use_transactional_fixtures = false
|
||||
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
# automatically. This will be the default behavior in future versions of
|
||||
|
||||
@@ -3,14 +3,13 @@ module FeatureHelpers
|
||||
def fill_autocomplete(field, options = {})
|
||||
fill_in field, :with => options[:with]
|
||||
|
||||
sleep 3
|
||||
|
||||
page.execute_script %Q{ $('##{field}').trigger('focus') }
|
||||
page.execute_script %Q{ $('##{field}').trigger('keydown') }
|
||||
# selector = %Q{ul.ui-autocomplete li.ui-menu-item a:contains("#{options[:select]}")}
|
||||
end
|
||||
|
||||
# page.should have_selector('ul.ui-autocomplete li.ui-menu-item a')
|
||||
# page.execute_script %Q{ $('#{selector}').trigger('mouseenter').click() }
|
||||
def select_from_autocomplete(selection)
|
||||
selector = %Q{ul.ui-autocomplete li.ui-menu-item a:contains("#{selection}")}
|
||||
page.execute_script %Q{ $('#{selector}').trigger('mouseenter').click() }
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user