Skip to content

Instantly share code, notes, and snippets.

@arturictus
arturictus / rails_helper.rb
Created March 19, 2015 09:01
Rspec-capybara login with warden
# spec/rails_helper.rb
# add to your rails_helper inside the
RSpec.configure do |config|
config.around(:each, type: :request) do |example|
Warden.test_mode!
example.run
Warden.test_reset!
end
end
@arturictus
arturictus / env_helpers.rb
Last active August 29, 2015 14:13
Set ENV variables for specific tests
# spec/support/env_helpers.rb
module EnvHelpers
def with_env_vars(vars)
original = ENV.to_hash
vars.each { |k, v| ENV[k] = v }
begin
yield
ensure
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
# First the end result of what we want:
class Foo
before_hook :whoa
before_hook :amazing
def test
puts "This is kinda cool!"
end
@arturictus
arturictus / Gemfile
Last active August 29, 2015 13:56
carrierwave S3 config
# ...
gem 'carrierwave'
gem 'fog', '~> 1.0.0' # Need to specify version, as carrierwave references older (0.9.0) which doesn't allow configuration of Rackspace UK Auth URL
@arturictus
arturictus / links
Last active August 29, 2015 13:56
Usefull repos