Skip to content

Commit

Permalink
Version bump to 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lecid committed May 3, 2024
1 parent 0e1c274 commit 082d4a6
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 8 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Ruby

on: [push,pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.3
- name: Getting dependencies (Bundle)
run: |
gem install bundler -v 2.2.3
bundle install
- name: Running test Rspec
run: |
bundle exec rake
- name: Running CVE security audit
run: |
bundle exec rake audit
59 changes: 52 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,64 @@ You could, for debug your tests and during dev, dump your data with
describe 'Test REST API' do
before :all do
$service = RestService::new :service => Application
$data = {name: "Sample App", version: "0.0.1", status: 'OK'}
$collection = [{one: 1}, {two: 2}, {three: 3}]
end

subject { $service }
context "GET /status : test for status" do
context "GET /data" do
it { expect(subject.get('/data')).to be_correctly_sent }
it { subject.returned_data }

end

end

end
```

It display the returned data of API.

### Fixtures getter

If you want to compare or inject data you could create fixture YAML files with :


```ruby

describe 'Test REST API' do
before :all do
$service = RestService::new :service => Application
$mydata = get_file 'spec/fixtures/mydata.yml'
end

subject { $service }
context "POST /data : test" do
it { expect(subject.post('/data',$mydata.to_json)).to be_correctly_sent }
end


end
```

### Statefullies helpers

To be able to record ids of record, rack-rest-spec offer two helpers, to transit data from tests to tests.

```ruby

describe 'Test REST API' do
before :all do
$service = RestService::new :service => Application
$mydata = get_file 'spec/fixtures/mydata.yml'
end

subject { $service }
context "POST /data : test" do
it { expect(subject.post('/data',$mydata.to_json)).to be_correctly_sent }
it { memorize id: subject.returned_data[:id] }
end

context "GET /data/<id> : test" do
it { expect(subject.get("/data#{retrieve(:id)}")).to be_correctly_sent }
end
end

end
```


2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.5
1.0.0

0 comments on commit 082d4a6

Please sign in to comment.