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
Docs #195
Docs #195
Conversation
PR is quite big. Might make more sense to review it by one commit at a time. |
Thanks for doing this @waterlink ! I'll make an account and take a look soon. |
@waterlink my username is |
I have added you to these publishers. You should be able to see them at your dashboard at https://relishapp.com/my/publishers |
BTW, @egonSchiele Can you take a look at a PR, and how it looks on staging publisher? It is important to merge that, because after that multiple small documentation changes can be done in parallel in their respective Anybody else wants to review? /cc @sfcgeorge @nixpulvis |
Don't be afraid of |
/cc @dg-ratiodata You might want to take a look as well and tell if I have utilized |
|
||
class << self | ||
Contract C::Num => String | ||
def th(number) |
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 would suggest a less complicated function, or just remove this one...two examples is enough.
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.
Ah, I guess you want the third example as the singleton example. Maybe def increment(x); x + 1; end
?
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.
Will change it now.
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.
added commit on top of master: 51cfe7c
This is really cool @waterlink, thanks for doing it. |
You can use `functype(name)` method for that: | ||
|
||
```ruby | ||
functype(:add) # => "add :: Num, Num => Num" |
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.
Is that really something "normal" end users are going to use? Otherwise I would move that to "features/developers/..." or something similar.
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.
Makes sense to move it to features/developers/functype.feature
I think.
@waterlink I think you're on a very good way. :-) What I found out while "writing" our documentation:
Something I tend to do:
Something like that - not tested. Scenario: No Instance method contract violation
Given a file named "contract.rb" with:
"""ruby
require "contracts"
C = Contracts
class Example
include Contracts::Core
Contract C::Num, C::Num => C::Num
def add(a, b)
a + b
end
end
"""
And a file named "spec/instance_method_violation_spec.rb" with:
"""
require 'contract.rb'
RSpec.describe "instance method violation" do
subject { Example.new }
let(:a) { 1 }
let(:b) { 2 }
it { expect(subject.add(a, b)).to eq 3 }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Instance method contract violation
Given a file named "contract.rb" with:
"""ruby
require "contracts"
C = Contracts
class Example
include Contracts::Core
Contract C::Num, C::Num => C::Num
def add(a, b)
a + b
end
end
"""
And a file named "spec/instance_method_violation_spec.rb" with:
"""
require 'contract.rb'
RSpec.describe "instance method violation" do
subject { Example.new }
let(:a) { 1 }
let(:b) { 'a' }
it { expect { subject.add(a, b) }.to raise_error ParamContractError }
end
"""
When I run `rspec`
Then the specs should all pass Using this approach you do not need to do something like Hope this makes sense to you. |
Oh this is pretty cool, nice! |
@dg-ratiodata For contract violation errors I wanted to demonstrate exactly how error looks like and what data it has inside. How would you do that with |
Oh, ok. But what about something like that: let(:error_message) { <<-EOS
: Contract violation for argument 2 of 2: (ParamContractError)
Expected: Num,
Actual: "foo"
Value guarded in: Example::add
With Contract: Num, Num => Num
At: instance_method_violation.rb:8
EOS
}
it { expect { subject.add(a, b) }.to raise_error ParamContractError, error_message } |
That sounds good. I will try it out. Thanks! :) Best Regards, 2015-09-08 9:27 GMT+02:00 Dennis Günnewig notifications@github.com:
|
refs #189
This PR adds proper
aruba/cucumber/relish
setup for alive documentation through BDD.@egonSchiele you probably need access to those publishers I have created on relish:
For that, can you signup (if you haven't already) on https://relishapp.com/ and send me your relish username (here or by email)?
Relish was chosen because of impression created by
rspec
's team documentation there. It really looks good and offers nice features.This PR does not add all the documentation yet, but it would be nice to get this reviewed, code-review-fixed and merged, so that we can go in small increments with this.
How it would look when released can be seen at https://relishapp.com/contracts-staging and https://relishapp.com/contracts-staging/contracts-ruby
Cheers!