tpope / vim-rails

rails.vim: Ruby on Rails power tools
http://www.vim.org/scripts/script.php?script_id=1567
4.1k stars 383 forks source link

Command to run rspec system specs #583

Open chrislawrence opened 2 years ago

chrislawrence commented 2 years ago

Rspec system specs have largely replaced feature specs for high end testing. It would be nice to have an :Esystem command to edit these specs.

tpope commented 2 years ago

I'm out of the loop on this. What's the naming scheme? What should the template look like?

Based on precedent, we probably want to further overload this onto :Eintegrationtest.

chrislawrence commented 2 years ago

naming scheme is spec/system/widget_system_spec.rb

template is:

require "rails_helper"

RSpec.describe "Widget management", :type => :system do
  before do
    driven_by(:rack_test)
  end

  it "enables me to create widgets" do
    visit "/widgets/new"

    fill_in "Name", :with => "My Widget"
    click_button "Create Widget"

    expect(page).to have_text("Widget was successfully created.")
  end
end

From https://relishapp.com/rspec/rspec-rails/docs/system-specs/system-spec

tpope commented 2 years ago

Probably adding another section like this will be sufficient:

https://github.com/tpope/vim-rails/blob/de73f6d1b0bf1b2af2d576f3420fc861af14769f/autoload/rails.vim#L4430-L4438

For templates we strive for the smallest possible, no example tests or anything like that. One can use the generator to get those.