Skip to content

Instantly share code, notes, and snippets.

@walidvb
Last active August 29, 2015 14:03
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 walidvb/5c7c5f6e674c17e195a5 to your computer and use it in GitHub Desktop.
Save walidvb/5c7c5f6e674c17e195a5 to your computer and use it in GitHub Desktop.
/Users/Gaston/dev/pigeonhole/pigeonhole/spec/support/controller_macros.rb
/Users/Gaston/dev/pigeonhole/pigeonhole/spec/support/count_queries.rb
/Users/Gaston/dev/pigeonhole/pigeonhole/spec/support/delayed_jobs.rb
/Users/Gaston/dev/pigeonhole/pigeonhole/spec/support/rspec_extensions.rb
/Users/Gaston/dev/pigeonhole/pigeonhole/spec/support/stub_paperclip_attachment.rb
Run options: include {:locations=>{"./spec/controllers/send_to_kindle_controller_spec.rb"=>[41]}}
F
Failures:
1) SendToKindleController when the book has 2 published staves and 1 unpublished and the user is subscribed sends the book to a user
Failure/Error: expect_jobs(1)
NoMethodError:
undefined method `expect_jobs' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_2:0x007fa41bec78d8>
# ./spec/controllers/send_to_kindle_controller_spec.rb:43:in `block (4 levels) in <top (required)>'
require 'spec_helper'
describe SendToKindleController do
before do
@user = Fabricate(:user, kindle_wanted: true, kindle_email: "you@kindle.com")
@chapter = Fabricate(:chapter)
@chapter.file?.should == true
@book = Fabricate(:book, chapters: [@chapter])
sign_in @user
SubscribeMailer.deliveries = []
end
it "should work" do
get book
expect_jobs(2)
end
end
module DelayedJobs
def expect_jobs n
# expect(Delayed::Job.count).to eq(n)
# Timecop.travel(time) unless time.nil?
# successes, failures = Delayed::Worker.new.work_off
# expect(successes).to eq(n)
# expect(failures).to eq(0)
# expect(Delayed::Job.count).to eq(0)
# Timecop.return unless time.nil?
puts "test"
"test"
end
end
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'email_spec'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f|
puts f
require f}
RSpec.configure do |config|
config.include(EmailSpec::Helpers)
config.include(EmailSpec::Matchers)
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment