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::Core::FilterManager | |
#include | |
merges inclusions | |
overrides previous inclusions with (via merge) | |
deletes matching opposites | |
with :locations | |
clears previous inclusions | |
does nothing when :locations previously set | |
with :line_numbers | |
clears previous inclusions |
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
# Note the differences between this and https://gist.github.com/2938822 are that | |
# we're making 10k groups with 1 example each vs 1 group w/ 10k examples, and the | |
# rspec example uses "should eq" instead of "should ==" | |
if $0 =~ /rspec$/ | |
10_000.times do |i| | |
describe "loltest #{i}" do | |
it "does #{i}" do | |
i.should eq i | |
end |
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
describe Article do | |
def article; Article.new :title => "Lorem ipsum"; end | |
it "has a title" do | |
article.title.should eq("Lorem ipsum") | |
end | |
end |
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
describe Article do | |
it { should validate_presence_of(:title) } | |
end |
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
class Article < ActiveRecord::Base | |
validates_presence_of :title | |
has_many :comments | |
end |
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
desc "A user's comment" do | |
let(:user) { User.create! name: "John" } | |
let(:comment) { user.comments.create! } | |
it "delegates to user's name" do | |
comment.name.should eq(user.name) | |
end | |
end |
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
[david: compare]$ # at this point we have a stock rails app with no minitest tests and one pending rspec example | |
[david: compare]$ | |
[david: compare]$ time rake test | |
Run options: | |
# Running tests: | |
Finished tests in 0.030419s, 0.0000 tests/s, 0.0000 assertions/s. |
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 example_spec.rb | |
F | |
Failures: | |
1) Pessimist never thinks its equal, even to itself | |
Failure/Error: pessimist.should eq(pessimist) | |
expected: #<Pessimist:0x007fb82a9bae80> | |
got: #<Pessimist:0x007fb82a9bae80> |
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
describe Something do | |
before(:each) do | |
do_something_before | |
end | |
it "does one thing" do | |
# before will run for this example because rspec doesn't know it is pending | |
# until the example is eval'd | |
pending | |
end |
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
describe "GET /agents.json" do | |
it_behaves_like "API controller", :params => { ... }, :environment => { ... } | |
end |