Tags » Rspec 2

RSpect : need to be taken care of while writing UnitTesting

Ok let me show an example

let(:role) { create :role, name: 'parent' }
let(:user) { create(:user1, roles: ) }
let(:pact) { create :pact, parent_id: user.id, renews_at: 1.hour.ago }
let(:execution){ AutoRenewalPactAsync.new.perform}

it 'should renew pact and also schedule the drug test whose renews_at date is today' do
  expect{execution}.to change{pact.pact_years.count}.by(1)
  expect(pact.renews_at).to eq(pact.renews_at + Pact::RenewalYear)
Failure/Error: expect(pact.renews_at).to eq(1.year.from_now)
 expected: 2017-02-28 09:20:41.204897017 +0000
 got: 2016-02-28 08:20:40.980794147 +0000

… 170 more words
Rubu On Rails

How to mock Stripe::Charge.retrieve using Stripe Mock gem

I created customer, made a subscription on the behalf of the customer. Along with that I generated invoices and expected in the RSpec example like… 76 more words

Ruby On Rails

RSpec : Conditionals in before/after callbacks


When you add a conditions hash to before(:example) or before(:context), RSpec will only apply that hook to groups or examples that match the conditions. 134 more words

Ruby On Rails

Rails : Capybara : When Checkboxes and Radio buttons are not found

There may come situation when you try to check(tick) the checkboxes via RSpec. using codes like


Problem was:

We have hidden the original checkbox and the fancy checkbox was being shown. 65 more words

Ruby On Rails

Rails : Capybara Webkit : Issue : Multiple JS events in single example

I recently moved from Selenium Web Driver to Thoughtbot’s Capybara Webkit as JS Driver for Capybara. The main reason is, webkit is super fast in running the test suite and its headless (no browser pops up ) . 131 more words

Ruby On Rails