Skip to content

Instantly share code, notes, and snippets.

@sparrow
Created September 27, 2016 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sparrow/3cdedbeadfe2ab37315bc5840f958149 to your computer and use it in GitHub Desktop.
Save sparrow/3cdedbeadfe2ab37315bc5840f958149 to your computer and use it in GitHub Desktop.
This is an Rspec code snippet that we used for our blog post https://rubygarage.org/blog/ruby-on-rails-and-symfony-comparison at RubyGarage. It demonstrates how to test subscription with Rspec. This code snippet was fully written by web developer at RubyGarage.
Rspec.describe Subscription do
describe ".create_and_request_confirmation(params)" do
it "creates an unconfirmed subscription with the given params" do
params = { email: "subscriber@somedomain.tld", start_on: "2015-01-31" }
Subscription.create_and_request_confirmation(params)
subscription = Subscription.first
expect(subscription.confirmed?).to eq(false)
expect(subscription.email).to eq(params[:email])
expect(subscription.start_on).to eq(Date.new(2015, 1, 31))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment