-
-
Notifications
You must be signed in to change notification settings - Fork 525
Add an initial setup for RSpec examples. #381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.bundle | ||
bin/configlet | ||
bin/configlet.exe | ||
Gemfile.lock | ||
/Gemfile.lock | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
CWD=`pwd` | ||
cd $1 && bundle install && bundle exec rspec -r $CWD/lib/disable_rspec_skip.rb |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--color | ||
--order=random | ||
--pattern *_spec.rb |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
# A sample Gemfile | ||
source "https://rubygems.org" | ||
|
||
# gem "rails" | ||
gem "rspec", "~> 3.4.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
diff-lcs (1.2.5) | ||
rspec (3.4.0) | ||
rspec-core (~> 3.4.0) | ||
rspec-expectations (~> 3.4.0) | ||
rspec-mocks (~> 3.4.0) | ||
rspec-core (3.4.4) | ||
rspec-support (~> 3.4.0) | ||
rspec-expectations (3.4.0) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.4.0) | ||
rspec-mocks (3.4.1) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.4.0) | ||
rspec-support (3.4.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
rspec (~> 3.4.0) | ||
|
||
BUNDLED WITH | ||
1.12.5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
require_relative "./wordy" | ||
|
||
RSpec.describe WordProblem do | ||
it "can add one to one" do | ||
problem = WordProblem.new("What is 1 plus 1?") | ||
|
||
expect(problem.answer).to eq(2) | ||
end | ||
|
||
it "can add two to fifty three" do | ||
skip "fix this test second - delete the `skip` lines to enable individual tests" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
https://relishapp.com/rspec/rspec-core/v/3-4/docs/pending-and-skipped-examples/skip-examples https://relishapp.com/rspec/rspec-core/v/3-0/docs/pending-and-skipped-examples/pending-examples There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough, it has been a long time since I have used RSpec. When you say "Here" do you mean "Here as in at RSpec" or "Here as in on exercism"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here as in "for the exorcism examples" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Glad I asked. If it is idiomatic for RSpec to use pending, then we should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think Is there a way to not have the verbose output about it being skipped? I'm trying to avoid noisy output. In this context (exercism) it's not intended as team-wide communication. |
||
|
||
problem = WordProblem.new('What is 53 plus 2?') | ||
|
||
expect(problem.answer).to eq(55) | ||
end | ||
|
||
it "can add negative numbers together" do | ||
skip "fix this test third" | ||
|
||
problem = WordProblem.new('What is -1 plus -10?') | ||
|
||
expect(problem.answer).to eq(-11) | ||
end | ||
|
||
it "can add larger numbers together" do | ||
skip "fix this test fourth" | ||
|
||
problem = WordProblem.new('What is 123 plus 45678?') | ||
|
||
expect(problem.answer).to eq(45_801) | ||
end | ||
|
||
it "can subtract numbers from each other" do | ||
skip "fix this test fifth" | ||
|
||
problem = WordProblem.new('What is 4 minus -12?') | ||
|
||
expect(problem.answer).to eq(16) | ||
end | ||
|
||
it "can multiply numbers together" do | ||
skip "fix this test sixth" | ||
|
||
problem = WordProblem.new('What is -3 multiplied by 25?') | ||
|
||
expect(problem.answer).to eq(-75) | ||
end | ||
|
||
it "can divide two numbers" do | ||
skip "fix this test seventh" | ||
|
||
problem = WordProblem.new('What is 33 divided by -3?') | ||
|
||
expect(problem.answer).to eq(-11) | ||
end | ||
|
||
it "can add numbers together multiple times" do | ||
skip "fix this test eight" | ||
|
||
question = 'What is 1 plus 1 plus 1?' | ||
problem = WordProblem.new(question) | ||
|
||
expect(problem.answer).to eq(3) | ||
end | ||
|
||
it "can add and then subtract a number" do | ||
skip "fix this test ninth" | ||
|
||
question = 'What is 1 plus 5 minus -2?' | ||
problem = WordProblem.new(question) | ||
|
||
expect(problem.answer).to eq(8) | ||
end | ||
|
||
it "can subtract numbers twice" do | ||
skip "fix this test tenth" | ||
|
||
question = 'What is 20 minus 4 minus 13?' | ||
problem = WordProblem.new(question) | ||
|
||
expect(problem.answer).to eq(3) | ||
end | ||
|
||
it "can subtract then add a number" do | ||
skip "fix this test eleventh" | ||
|
||
question = 'What is 17 minus 6 plus 3?' | ||
problem = WordProblem.new(question) | ||
|
||
expect(problem.answer).to eq(14) | ||
end | ||
|
||
it "can multiply numbers twice" do | ||
skip "fix this test twelth" | ||
|
||
question = 'What is 2 multiplied by -2 multiplied by 3?' | ||
problem = WordProblem.new(question) | ||
|
||
expect(problem.answer).to eq(-12) | ||
end | ||
|
||
it "can add then multiply numbers" do | ||
skip "fix this test thirtheenth" | ||
|
||
question = 'What is -3 plus 7 multiplied by -2?' | ||
problem = WordProblem.new(question) | ||
|
||
expect(problem.answer).to eq(-8) | ||
end | ||
|
||
it "can divide numbers twice" do | ||
skip "fix this test fourteenth" | ||
|
||
question = 'What is -12 divided by 2 divided by -3?' | ||
problem = WordProblem.new(question) | ||
|
||
expect(problem.answer).to eq(2) | ||
end | ||
|
||
it "can't do advanced math" do | ||
skip "fix this test fifteenth" | ||
|
||
problem = WordProblem.new('What is 53 cubed?') | ||
|
||
expect { problem.answer }.to raise_error(ArgumentError) | ||
end | ||
|
||
it "can't answer irrelevant questions" do | ||
skip "fix this test sixteenth" | ||
|
||
problem = WordProblem.new('Who is the president of the United States?') | ||
|
||
expect { problem.answer }.to raise_error(ArgumentError) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
RSpec::Core::Pending.class_eval do | ||
def skip(*args) | ||
end | ||
end |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know about this but I wonder if this should be:
This way, any other ones are still ignored, or must be explicitly added to the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tells git to ignore the
Gemfile.lock
at the repo root, so it will work (in fact is preferred).Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which "This"? The one that I propose does the same, but specifically also says to NOT ignore the
Gemfile.lock
in each of the exercise subfolders (but only the subfolder.), while also ignoring Gemfile.lock anywhere else.