Skip to content

Instantly share code, notes, and snippets.

@danilolic
Last active December 17, 2018 13:09
Show Gist options
  • Select an option

  • Save danilolic/b596fe40bc1a8e38652e5dff1bbead45 to your computer and use it in GitHub Desktop.

Select an option

Save danilolic/b596fe40bc1a8e38652e5dff1bbead45 to your computer and use it in GitHub Desktop.

Revisions

  1. danilolic revised this gist Dec 17, 2018. 1 changed file with 6 additions and 7 deletions.
    13 changes: 6 additions & 7 deletions rails_rspec_test_config.rb
    Original file line number Diff line number Diff line change
    @@ -31,15 +31,14 @@
    #.rspec (opcional)
    --format documentation

    # config/application
    # generates only model and requests specs
    # config/application.rb
    config.generators do |g|
    g.test_framework :rspec,
    fixtures: false,
    view_specs: false,
    helper_specs: false,
    routing_specs: false,
    controller_specs: false
    g.test_framework :rspec
    g.helper_specs false
    g.controller_specs false
    g.view_specs false
    g.routing_specs false
    end

    #spec/rails_helper.rb
  2. danilolic revised this gist Dec 17, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions rails_rspec_test_config.rb
    Original file line number Diff line number Diff line change
    @@ -32,6 +32,7 @@
    --format documentation

    # config/application
    # generates only model and requests specs
    config.generators do |g|
    g.test_framework :rspec,
    fixtures: false,
  3. danilolic renamed this gist Dec 17, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. danilolic revised this gist Dec 17, 2018. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions Rails_rspec.rb
    Original file line number Diff line number Diff line change
    @@ -13,13 +13,14 @@
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
    gem 'faker'
    gem 'factory_bot_rails'
    gem 'pry-rails'
    end

    group :test do
    gem 'rspec-rails', '~> 3.7'
    gem 'shoulda-matchers', '~> 3.1'
    gem 'capybara'
    gem 'factory_bot_rails'
    gem 'database_cleaner'
    end

    @@ -37,7 +38,7 @@
    view_specs: false,
    helper_specs: false,
    routing_specs: false,
    request_specs: false
    controller_specs: false
    end

    #spec/rails_helper.rb
  5. danilolic revised this gist Jul 31, 2018. 1 changed file with 18 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions Rails_rspec.rb
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,7 @@
    gem 'shoulda-matchers', '~> 3.1'
    gem 'capybara'
    gem 'factory_bot_rails'
    gem 'database_cleaner'
    end

    # bundle install
    @@ -39,6 +40,9 @@
    request_specs: false
    end

    #spec/rails_helper.rb
    require 'database_cleaner'

    #spec/rails_helper.rb
    config.include FactoryBot::Syntax::Methods

    @@ -50,4 +54,18 @@
    end
    end

    #spec/rails_helper.rb
    # start by truncating all the tables but then use the faster transaction strategy the rest of the time.
    config.before(:suite) do
    DatabaseCleaner.clean_with(:truncation)
    DatabaseCleaner.strategy = :transaction
    end

    # start the transaction strategy as examples are run
    config.around(:each) do |example|
    DatabaseCleaner.cleaning do
    example.run
    end
    end

    #mkdir spec/factories
  6. danilolic revised this gist Jul 31, 2018. 1 changed file with 16 additions and 4 deletions.
    20 changes: 16 additions & 4 deletions Rails_rspec.rb
    Original file line number Diff line number Diff line change
    @@ -12,20 +12,24 @@
    group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
    gem 'faker'
    end

    group :test do
    gem 'rspec-rails', '~> 3.7'
    gem 'shoulda-matchers', '~> 3.1'
    gem 'capybara'
    gem 'factory_bot_rails'
    gem 'faker'
    end

    # bundle install
    # rails g rspec:install
    # bundle exec spring binstub --all

    #.rspec
    #.rspec (opcional)
    --format documentation

    #config/application
    # config/application
    config.generators do |g|
    g.test_framework :rspec,
    fixtures: false,
    @@ -38,4 +42,12 @@
    #spec/rails_helper.rb
    config.include FactoryBot::Syntax::Methods

    # mkdir spec/factories
    #spec/rails_helper.rb
    Shoulda::Matchers.configure do |config|
    config.integrate do |with|
    with.test_framework :rspec
    with.library :rails
    end
    end

    #mkdir spec/factories
  7. danilolic revised this gist May 26, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Rails_rspec.rb
    Original file line number Diff line number Diff line change
    @@ -38,4 +38,4 @@
    #spec/rails_helper.rb
    config.include FactoryBot::Syntax::Methods

    #shell: mkdir spec/factories
    # mkdir spec/factories
  8. danilolic revised this gist May 26, 2018. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion Rails_rspec.rb
    Original file line number Diff line number Diff line change
    @@ -15,8 +15,13 @@
    gem 'rspec-rails', '~> 3.7'
    gem 'capybara'
    gem 'factory_bot_rails'
    gem 'faker'
    end

    # bundle install
    # rails g rspec:install
    # bundle exec spring binstub --all

    #.rspec
    --format documentation

    @@ -28,4 +33,9 @@
    helper_specs: false,
    routing_specs: false,
    request_specs: false
    end
    end

    #spec/rails_helper.rb
    config.include FactoryBot::Syntax::Methods

    #shell: mkdir spec/factories
  9. danilolic revised this gist May 26, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Rails_rspec.rb
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,7 @@
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
    gem 'rspec-rails', '~> 3.7'
    gem 'capybara'
    gem 'factory_bot_rails'
    end

  10. danilolic revised this gist May 26, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Rails_rspec.rb
    Original file line number Diff line number Diff line change
    @@ -25,5 +25,6 @@
    fixtures: false,
    view_specs: false,
    helper_specs: false,
    routing_specs: false
    routing_specs: false,
    request_specs: false
    end
  11. danilolic renamed this gist May 26, 2018. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions Rails boilerplate rspec → Rails_rspec.rb
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,16 @@
    gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
    gem 'rspec-rails', '~> 3.7'
    gem 'factory_bot_rails'
    end

    #.rspec
    --format documentation

    #config/application
    config.generators do |g|
    g.test_framework :rspec,
    fixtures: false,
    view_specs: false,
    helper_specs: false,
    routing_specs: false
    end
  12. danilolic created this gist May 26, 2018.
    17 changes: 17 additions & 0 deletions Rails boilerplate rspec
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #Gemfile
    group :development do
    # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
    gem 'web-console', '>= 3.3.0'
    gem 'listen', '>= 3.0.5', '< 3.2'
    # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
    gem 'spring'
    gem 'spring-watcher-listen', '~> 2.0.0'
    gem 'spring-commands-rspec'
    end

    group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
    gem 'rspec-rails', '~> 3.7'
    gem 'factory_bot_rails'
    end