Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lowfive

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lowfive

  • 0.1.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Low Five

Low Five allows you to easily login a resource using devise in your rspec specs.

You can use these methods inside your specs for:

  • controllers
  • requests
  • features

Make sure that your specs have the correct type: defined.

RSpec.describe UserManagement, type: :request do
end

Installation

Add this line to your application's Gemfile:

gem 'lowfive'

And then execute:

$ bundle

Or install it yourself as:

$ gem install lowfive

Setup

Add this require to your rails_helper.rb file.

require 'lowfive/devise/rspec'

Usage

Low Five provides helper methods that allow you to sign in a particular resource.

First you must create a resource, in our example we use FactoryGirl to create a user instance.

# spec/factories/users.rb

FactoryGirl.define do
  factory :user do
    email 'user@testuser.com'
    name 'Bob Marley'
    password 'Whatever999'
    password_confirmation 'Whatever999'
  end
end

then you pass the user to the helper methods provided. There are two methods available

log_in(resource)
log_out(resource)

Note that you NEED to have a before block to put the helper method into, if you use it outside of an it block.

require 'rails_helper'

RSpec.describe UserManagement, type: :request do
  let(:user) { FactoryGirl.create(:user) }

  before do
    log_in(user)
  end

  describe '#index' do
    context 'logged in' do
      it 'renders index home page' do
        get root_path
        expect(response.body).to include('Home Page')
      end
    end

    context 'logged out' do
      it 'redirects to login page' do
        log_out(user)
        get root_path
        follow_redirect!
        expect(response.body).to include('Log in')
      end
    end
  end
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jwipeout/lowfive. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 07 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc