mirror of
https://github.com/discourse/discourse.git
synced 2024-12-03 02:33:44 +08:00
c9dab6fd08
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors. By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
25 lines
653 B
Ruby
25 lines
653 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'wizard'
|
|
|
|
describe Wizard::Step do
|
|
|
|
let(:wizard) { Wizard.new(Fabricate.build(:user)) }
|
|
let(:step) { wizard.create_step('test-step') }
|
|
|
|
it "supports fields and options" do
|
|
expect(step.fields).to be_empty
|
|
text = step.add_field(id: 'test', type: 'text')
|
|
expect(step.fields).to eq([text])
|
|
|
|
dropdown = step.add_field(id: 'snacks', type: 'dropdown')
|
|
dropdown.add_choice('candy')
|
|
dropdown.add_choice('nachos', data: { color: 'yellow' })
|
|
dropdown.add_choice('pizza', label: 'Pizza!')
|
|
|
|
expect(step.fields).to eq([text, dropdown])
|
|
expect(dropdown.choices.size).to eq(3)
|
|
end
|
|
|
|
end
|