+ +RSpec.feature "See shop items", type: :feature do + scenario 'A user can see vairous items' do + visit '/items' + + expect(page).to have_text('包丁') + expect(page).to have_text('フライパン') + end +end ΛҰཡ͢Δ࠷ݶͷεςοϓ
1) See shop items A user can see vairous items Failure/Error: visit '/items' ActionController::RoutingError: No route matches [GET] "/items" # ./spec/features/show_items_spec.rb:5:in `block (2 levels) in < ࣦഊ͢Δ
F Failures: 1) See shop items A user can see vairous items Failure/Error: expect(page).to have_text('包丁') expected to find text "包丁" in "Listing items Name Price Image url New I # ./spec/features/manage_items_spec.rb:7:in `block (2 levels) in <top (requ Finished in 0.72653 seconds (files took 5.27 seconds to load) 1 example, 1 failure TDBGGPMEޙʹɺECNJHSBUFͯ͠ςετΛྲྀͯ͠ΈΔ
commonly want. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +require 'factory_girl' + RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest @@ -96,4 +98,5 @@ RSpec.configure do |config| # as the one that triggered the failure. Kernel.srand config.seed =end + config.include FactoryGirl::Syntax::Methods end GBDUPSZ@HJSMͷಋೖ
(files took 2.72 seconds to load) 1 example, 0 failures $ bundle exec rails s # 別ターミナルで $ open http://localhost:3000/items ࠷ॳͷςετ͕௨ͬͨ ‣ Ͳ͏ͳ͍ͬͯΔ͔ɺϒϥβͰݟͯΈ·͠ΐ͏
+ resources :items # For details on the DSL available within this file, see http://guides.rubyon routing.html end 3BJMT3&45ͱ͍͏ߟ͑ํʹͱ͍͍ͮͯΔ ‣ 3&QSFTFOUBUJPOBM4UBUF5SBOTGFS ‣ )551ϝιου Ͳ͏͍ͨ͠ ͱύε ΫΤϦ ͳʹΛ Λͱ͍͏Έ߹ΘͤΛɺ Ϧιʔεͷૢ࡞ɺͱͯ͠நԽ͠ɺΞʔΩςΫνϟͷத৺ʹஔ͘ߟ͑ํ ‣ ͦͷϦιʔεͷૢ࡞ΛͬͯɺΞϓϦέʔγϣϯͷॲཧΛ࣮ݱ͢Δɻ ‣ ࠓճɺѻ͏σʔλJUFNΛɺͦͷ··Ϧιʔεͱͨ͠ɻ
a new way of building and deploying web apps. ‣ RailsΞϓϦέʔγϣϯͷίʔυΛૹΔͱɺࣗಈతʹDBͳͲ Λ༻ҙ͠ɺαʔϏεΛىಈͯ͘͠ΕΔɻ ‣ ίϯςφԽٕज़ͷҰछ ‣ ΫοΫύουͰDocker + Amazon ECSͰඋ͍ͯ͠Δ IFSPLVʹ͍ͭͯ
- resources :items - # For details on the DSL available within this file, see http://guides.rubyo routing.html + resources :items, only: %i(index show) end ## 確認 $ bundle exec rails routes Prefix Verb URI Pattern Controller#Action items GET /items(.:format) items#index item GET /items/:id(.:format) items#show DPOpHSPVUFTSC
# GET /items # GET /items.json def index @items = Item.all end # GET /items/1 # GET /items/1.json def show end private # Use callbacks to share common setup or constraints between actions. def set_item @item = Item.find(params[:id]) end end ίϯτϩʔϥͰTIPXͱJOEFYҎ֎Λফ͢
shop items", type: :feature do expect(page).to have_text('包丁') expect(page).to have_text('フライパン') end + + scenario 'A user can see recommended items' do + create(:item, name: '包丁', recommended: true) + create(:item, name: 'フライパン') + + visit recommended_items_path + + expect(page).to have_text('包丁') + expect(page).not_to have_text('フライパン') + end end ղྫ
A user can see recommended items Failure/Error: create(:item, name: '包丁', recommended: true) NoMethodError: undefined method `recommended=' for #<Item:0x007fc928b10118> # ./spec/features/manage_items_spec.rb:15:in `block (2 levels) SFDPNNFOEFEଐੑ͕ͳͯ͘ςετʹࣦഊ͢Δ
A user can see recommended items Failure/Error: visit recommended_items_path NameError: undefined local variable or method `recommended_items_path' for #<RSpec::ExampleGroups::SeeShopItems:0x007f89d42e9db0> # ./spec/features/manage_items_spec.rb:18:in `block (2 levels) in <top (req Finished in 0.23378 seconds (files took 5.4 seconds to load) 2 examples, 1 failure ϧʔςΟϯά͕ͳͯ͘ςετࣦഊ
visit root_path NameError: undefined local variable or method `root_path' for #<RSpec::ExampleGroups::ShowCategoriesOnRoot:0x007fe4891096c0> # ./spec/features/portal_spec.rb:8:in `block (2 levels) in <top Finished in 0.26761 seconds (files took 2.8 seconds to load) 3 examples, 1 failure Failed examples: ϧʔςΟϯάఆ͕ٛͳ͍ͨΊςετ͕ࣦഊ
shop items", type: :feature do expect(page).not_to have_text('フライパン') end - scenario 'A user can see categorized items from portal', type: :feature do + xscenario 'A user can see categorized items from portal', type: :feature do kitchenware = create(:category, name: '調理器具') kitchenware.items.create!(name: '包丁') 1SPUJQςετͷϖϯσΟϯά
are expected and do not affect your su 1) See shop categories A user can see categorized items from portal # Temporarily disabled with xscenario # ./spec/features/portal_spec.rb:14 Finished in 0.21527 seconds (files took 2.25 seconds to load) 4 examples, 0 failures, 1 pending QFOEJOH