This file contains hidden or 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
http://stackoverflow.com/questions/13774022/testing-as-a-logged-in-user-in-rails |
This file contains hidden or 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
==== Gem file | |
group :test, :development do | |
gem "rspec-rails", "~> 2.0" | |
gem 'database_cleaner' | |
gem 'capybara' | |
gem "factory_girl_rails", ">= 4.1.0" | |
gem 'cucumber-rails', :require => false | |
gem 'mocha' | |
gem "shoulda-matchers" |
This file contains hidden or 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
module (ROR validation callbacks) | |
== acceptance | |
class Person < ActiveRecord::Base | |
validates :terms_of_service, :acceptance => true | |
end | |
== validates_associated (* should not used on both ends) |
This file contains hidden or 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
(ActiveRecord::Migration) | |
=== migration options | |
add_column | |
add_index | |
change_column | |
change_table | |
create_table | |
drop_table |
This file contains hidden or 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_shoulda: | | |
Shoulda Rspec Matchers | |
For more information on rspec, rspec-rails, shoulda | |
$ cheat rspec | |
$ cheat rspec_on_rails_matchers | |
$ cheat shoulda | |
Models Matchers | |
Data |
This file contains hidden or 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
=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') |
This file contains hidden or 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
sameeras-mbp:pretty_search sameera$ rspec | |
pretty search routes | |
. should route /pretty_search/query/company to pretty_search#search with model_name 'company' | |
PrettySearch::Query | |
constants | |
. check defaults | |
instance methods | |
.initialize |
This file contains hidden or 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
# encoding: utf-8 | |
require 'logstash/codecs/base' | |
class LogStash::Codecs::JsonFileGz < LogStash::Codecs::Base | |
config_name 'json_file_gz' | |
milestone 1 | |
public | |
def register | |
require 'zlib' |
This file contains hidden or 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
count = 0 | |
a = Dir.glob("/<rails app path>/app/models/**/*.rb") | |
a.each do |f| | |
file = File.new(f) |
This file contains hidden or 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
#Following is the problem with your solution. You have 2 if's , in ruby we need only 1 if | |
# notice that it has only one IF :) | |
if matched_games.length > 0 && matched_games.include?(search) | |
puts "Game #{search} found." | |
end | |
#clarrifications | |
Regexp.new(search) #is creating a new regular expression object in ruby. | |
#<Any Object>.new is the way of initializing an object in ruby. In this case 'Regexp' class. | |
#Regular expression can me used to match words in different options. Like |