Giter VIP home page Giter VIP logo

utensils's Introduction

Utensils

Rspec stuff we use over and over again

Installation

Add this line to your application's Gemfile:

gem 'utensils', :group => :test

Usage

  1. Create spec/support/utensils.rb
  2. Add whichever bits you need:
require 'utensils/capybara_extensions'
require 'utensils/capybara_javascript'
require 'utensils/database_cleaner'
require 'utensils/email'
require 'utensils/factory_bot'
require 'utensils/omniauth'
require 'utensils/upload_macros'
require 'utensils/json'

capybara_extensions

Allows you to use active record objects with capybara finders

page.within(post) { click_link('Edit') }
page.find(book_2).drag_to(page.find(book_1))

capybara_javascript

Switches javascript driver to poltergeist, and blacklists slow external JS

To use Poltegeist with remote debugging, run test with POLTERGEIST_DEBUG set.

POLTERGEIST_DEBUG=1 rspec spec/features/broken_feature_spec.rb

database_cleaner

Sets up rspec to use database_cleaner instead of transactional fixtures

email

Clears ActionMailer::Base.deliveries before each spec and includes https://github.com/bmabey/email-spec helpers.

factory_bot

Use shorthand for FactoryBot, ie:

# instead of:
FactoryBot.create(:post)

# use:
create(:post)

omniauth

Puts ominauth in test mode and provides the following macros:

stub_oauth(:facebook, info: { name: 'Bob' })
stub_oauth_error(:facebook)
login(user)

timecop

Resets timecop after each spec

upload_macros

Provides fixture_file and fixture_file_path helper pointing to spec/fixtures directory

fixture_file_path('dummy.jpg') # 'spec/fixtures/dummy.jpg'
Photo.create(:file => fixture_file('dummy.jpg')) # attaches File spec/fixtures/dummy.jpg

utensils's People

Contributors

balvig avatar chrisbr avatar davidstosik avatar kinopyo avatar l15n avatar lewispb avatar sikachu avatar tapster avatar tejanium avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

utensils's Issues

uninitialized constant JsonHelpers::Launchy

Requiring require 'utensils/json' and trying to use save_and_open_json errors:

uninitialized constant JsonHelpers::Launchy

I guess there's a requirement on using Launchy, but I don't see that in the gemspec.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.