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

shoulda_create

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shoulda_create

  • 0.0.9
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

== shoulda_create

Restores should_create functionality to shoulda.

I like using should_create and friends to make assertions about records coming and going in the database.

Shoulda did, but doesn't any more. With this, it can again.

Some ideological dispute, I guess. I complained to one of the thoughtbot guys, and he said "that's the joy of open source, you can build your own". Well, here it is.

== Examples

context 'POST to :create' do setup { post :create, :email => 'bob@example.com', :name => 'Bob Dobbs' } # simple usage should_create :user

# asserting records are neither created nor destroyed
should_not_change_record_count_of :blog_posts

# asserting a change in some state other than simple row count
should_change("number of Bobs", :by => 1){ User.where("name ILIKE '%bob%'").count }

# the subject can be a class rather than a symbol:
should_create Audited::Adapters::ActiveRecord::Audit

# ... or it can be a table name: (remember to pluralize)
should_create 'audits'

# the to can be a proc: (when using factories and ids are not known at context setup time)
should_change('the user group', :to => lambda{ @group.id }){ @user.reload.group_id }

end

== License

shoulda_create is released under the MIT license:

FAQs

Package last updated on 24 Jan 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