Created
September 27, 2016 13:27
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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