# shared_examples are tests written in a way that you can run them in
# multiple settings; extracting common behavior between objects.
it_behaves_like "a correct object remover" do
...
end
# shared_contexts is any setup code that you can use to prepare a test case.
# This allows you to include test helper methods or prepare for the tests to run.
include_context "has many users to begin with"
# Example
RSpec.describe TailwindDsl::Etl::ComponentStructures::Generator do
include_context :use_temp_folder
include_context :has_configured_uikit
it 'sample' do
puts temp_folder
puts uikit
end
end
# Used to read a complex data object
RSpec.shared_context :has_configured_uikit do
let(:design_systems_file) { File.join(SPEC_FOLDER, 'samples/input/uikit.json') }
let(:design_systems_data) { JSON.parse(File.read(design_systems_file), symbolize_names: true) }
let(:uikit) { ::TailwindDsl::Etl::RawComponents::UiKit.new(design_systems_data) }
end
# Used to create a temporary folder
RSpec.shared_context :use_temp_folder do
attr_reader :temp_folder
around do |example|
Dir.mktmpdir('rspec-') do |folder|
@temp_folder = folder
example.run
end
end
end
# declare the shared example
shared_examples 'foo' do
it 'passes do
expect(true).to be true
end
end
context 'using the shared example' do
include_examples 'foo'
end
Code Example |
---|
Ruby :: ruby substring remove |
Ruby :: rails form_tag |
Ruby :: button submit rails with font awesome |
Ruby :: ruby if |
Ruby :: ruby get the number of same element in array |
Ruby :: how to generate a controller in rails |
Ruby :: ruby csv parse |
Ruby :: ruby downcase |
Ruby :: new line in ruby |
Ruby :: creating model in ruby on rails |
Ruby :: ruby hash.each |
Ruby :: rails image tag data attribute |
Ruby :: timeout in rails |
Ruby :: run a rake task |
Ruby :: font awesome icon rails submit button |
Ruby :: one line each loop ruby |
Ruby :: Blocked host: c25f383bd08f.ngrok.io |
Ruby :: Ruby Regular Expressions |
Ruby :: rails localhost https |
Ruby :: ruby remove nil element in array |
Ruby :: for loop with condition in ruby |
Ruby :: Validate French phone numbers |
Ruby :: <= operator in rails |
Ruby :: rails api render show page with id |
Ruby :: difference between is_a and kind_of ruby |
Ruby :: rails print number with space |
Ruby :: ruby method |
R :: how to fill na values in r |
R :: glyph in r |
R :: r heatmap |