siringa 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -10
- data/app/controllers/siringa/siringa_controller.rb +1 -1
- data/config/routes.rb +1 -1
- data/lib/siringa/version.rb +1 -1
- data/lib/tasks/siringa_tasks.rake +1 -1
- data/test/controllers/siringa_controller_test.rb +8 -8
- data/test/dummy/log/test.log +41 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e86e6f8766845bd59ef91b71811575e9b0d5bf55
|
4
|
+
data.tar.gz: 3fd47988e335331bd12311fd114029393f4eaaed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b47372970c5d75e368c2b6552d0be4eaea148105f1578cbd1ebc2202d33ca3bc07a7ff826644971aeaa2fa56bc460837fc345c0d515270aa430927215c34f288
|
7
|
+
data.tar.gz: bf308063eeb9ce9078aaa1e27f05b0e7d525c531952d467e232e1ddac5aa68be86e24c837f5eb2a0f71badbdd72193c089004a6f405ec4e33aa71ad9573f243c
|
data/README.md
CHANGED
@@ -72,24 +72,24 @@ Now that we've created our definitions we could use them in our two cases:
|
|
72
72
|
### As seed data
|
73
73
|
You could just load the `initial` definition running the following rake recipe after your deploy:
|
74
74
|
```console
|
75
|
-
rake siringa:
|
75
|
+
rake siringa:load_definition
|
76
76
|
```
|
77
77
|
`initial` is the default definition this Rake task recipe will try to load, if you want to load another definition instead you could pass its name as argument:
|
78
78
|
```console
|
79
|
-
rake 'siringa:
|
79
|
+
rake 'siringa:load_definition[another_definition]'
|
80
80
|
```
|
81
81
|
This will load a definition named `:another_definition`. Please note that if you use Zsh shell you'll need to use quotes, more info [here](http://robots.thoughtbot.com/post/18129303042/how-to-use-arguments-in-a-rake-task).
|
82
82
|
|
83
83
|
If you want to force a Rails environment you could just run the Sriringa recipe specifing the `RAILS_ENV` environmental variable:
|
84
84
|
```console
|
85
|
-
RAILS_ENV=development rake siringa:
|
85
|
+
RAILS_ENV=development rake siringa:load_definition
|
86
86
|
```
|
87
87
|
|
88
88
|
### During an acceptance test
|
89
89
|
As you can see running `rake routes`, Siringa added 3 new routes to your API:
|
90
90
|
```console
|
91
91
|
Routes for Siringa::Engine:
|
92
|
-
POST /
|
92
|
+
POST /load_definition/:definition(.:format) siringa/siringa#load_definition
|
93
93
|
dump POST /dump(.:format) siringa/siringa#dump
|
94
94
|
restore POST /restore(.:format) siringa/siringa#restore
|
95
95
|
```
|
@@ -100,7 +100,7 @@ The workflow I propose here is:
|
|
100
100
|
|
101
101
|
This will create a `.dump` file in the `tmp/dumps` directory created during the install process. You could create as many dump files as you want but Siringa will keep only the latest 5 dumps created.
|
102
102
|
|
103
|
-
2. Load a Siringa definition performing a `POST` request to `YOURHOST/siringa/
|
103
|
+
2. Load a Siringa definition performing a `POST` request to `YOURHOST/siringa/load_definition/specific`
|
104
104
|
|
105
105
|
This will run the code defined in a definition named `specific` on the server.
|
106
106
|
|
@@ -126,7 +126,7 @@ end
|
|
126
126
|
## Acceptance test example
|
127
127
|
Just to get the idea, the following script will show you how to use Siringa in a acceptance test using Selenium, [rest-client](https://github.com/rest-client/rest-client) and RSpec:
|
128
128
|
```ruby
|
129
|
-
require 'selenium-webdriver'
|
129
|
+
require 'selenium-webdriver'
|
130
130
|
require 'rspec'
|
131
131
|
require 'rest_client'
|
132
132
|
|
@@ -144,9 +144,9 @@ describe "Acceptance test using Siringa" do
|
|
144
144
|
@driver.quit
|
145
145
|
end
|
146
146
|
|
147
|
-
it "
|
148
|
-
#
|
149
|
-
RestClient.post 'YOURHOST/siringa/
|
147
|
+
it "Loads a definition and test something" do
|
148
|
+
# Loads a definition named 'specific'
|
149
|
+
RestClient.post 'YOURHOST/siringa/load_definition', { definition: :specific }
|
150
150
|
|
151
151
|
# Here goes your test
|
152
152
|
|
@@ -163,5 +163,5 @@ end
|
|
163
163
|
## How to collaborate
|
164
164
|
* Fork the repo and send a pull request, thanks!
|
165
165
|
|
166
|
-
#
|
166
|
+
# License
|
167
167
|
MIT-LICENSE 2013 Enrico Stano
|
data/config/routes.rb
CHANGED
data/lib/siringa/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
namespace :siringa do
|
2
2
|
desc "Load a definition and populate the DB with seed data"
|
3
|
-
task :
|
3
|
+
task :load_definition, [:definition] do |t, args|
|
4
4
|
args.with_defaults :definition => :initial
|
5
5
|
Rake::Task["environment"].invoke
|
6
6
|
puts <<-EOS
|
@@ -10,18 +10,18 @@ class SiringaControllerTest < ActionController::TestCase
|
|
10
10
|
def teardown
|
11
11
|
end
|
12
12
|
|
13
|
-
test "
|
14
|
-
get :
|
13
|
+
test "load_definition action passing existing factory" do
|
14
|
+
get :load_definition, { definition: "initial", use_route: "siringa" }
|
15
15
|
assert_response :success
|
16
16
|
end
|
17
17
|
|
18
|
-
test "
|
19
|
-
get :
|
18
|
+
test "load_definition action passing a factory that doesn't exist" do
|
19
|
+
get :load_definition, { definition: "papapa", use_route: "siringa" }
|
20
20
|
assert_response :method_not_allowed
|
21
21
|
end
|
22
22
|
|
23
|
-
test "
|
24
|
-
get :
|
23
|
+
test "load_definition action passing arguments" do
|
24
|
+
get :load_definition, {
|
25
25
|
definition: "definition_with_arguments",
|
26
26
|
siringa_args: { name: 'Robb Stark' },
|
27
27
|
use_route: "siringa"
|
@@ -29,8 +29,8 @@ class SiringaControllerTest < ActionController::TestCase
|
|
29
29
|
assert_response :success
|
30
30
|
end
|
31
31
|
|
32
|
-
test "
|
33
|
-
get :
|
32
|
+
test "load_definition action returning JSON response" do
|
33
|
+
get :load_definition, {
|
34
34
|
definition: "definition_with_return",
|
35
35
|
siringa_args: { name: 'Ned' },
|
36
36
|
use_route: "siringa"
|
data/test/dummy/log/test.log
CHANGED
@@ -749,3 +749,44 @@ Processing by Siringa::SiringaController#load as HTML
|
|
749
749
|
[1m[35m (0.1ms)[0m RELEASE SAVEPOINT active_record_1
|
750
750
|
Completed 201 Created in 8ms (Views: 0.3ms | ActiveRecord: 0.7ms)
|
751
751
|
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
752
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
753
|
+
---------------------------------------------------------------------------------------
|
754
|
+
SiringaControllerTest: test_load_definition_action_passing_a_factory_that_doesn't_exist
|
755
|
+
---------------------------------------------------------------------------------------
|
756
|
+
Processing by Siringa::SiringaController#load_definition as HTML
|
757
|
+
Parameters: {"definition"=>"papapa"}
|
758
|
+
Completed 405 Method Not Allowed in 0ms (Views: 0.2ms | ActiveRecord: 0.0ms)
|
759
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
760
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
761
|
+
--------------------------------------------------------------------
|
762
|
+
SiringaControllerTest: test_load_definition_action_passing_arguments
|
763
|
+
--------------------------------------------------------------------
|
764
|
+
Processing by Siringa::SiringaController#load_definition as HTML
|
765
|
+
Parameters: {"definition"=>"definition_with_arguments", "siringa_args"=>{"name"=>"Robb Stark"}}
|
766
|
+
[1m[35m (0.0ms)[0m SAVEPOINT active_record_1
|
767
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "users" DEFAULT VALUES[0m
|
768
|
+
[1m[35m (0.1ms)[0m RELEASE SAVEPOINT active_record_1
|
769
|
+
Completed 201 Created in 7ms (Views: 0.2ms | ActiveRecord: 0.6ms)
|
770
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
771
|
+
[1m[35m (0.0ms)[0m begin transaction
|
772
|
+
---------------------------------------------------------------------------
|
773
|
+
SiringaControllerTest: test_load_definition_action_passing_existing_factory
|
774
|
+
---------------------------------------------------------------------------
|
775
|
+
Processing by Siringa::SiringaController#load_definition as HTML
|
776
|
+
Parameters: {"definition"=>"initial"}
|
777
|
+
[1m[36m (0.1ms)[0m [1mSAVEPOINT active_record_1[0m
|
778
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO "users" DEFAULT VALUES
|
779
|
+
[1m[36m (0.0ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
780
|
+
Completed 201 Created in 2ms (Views: 0.2ms | ActiveRecord: 0.2ms)
|
781
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
782
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
783
|
+
--------------------------------------------------------------------------
|
784
|
+
SiringaControllerTest: test_load_definition_action_returning_JSON_response
|
785
|
+
--------------------------------------------------------------------------
|
786
|
+
Processing by Siringa::SiringaController#load_definition as HTML
|
787
|
+
Parameters: {"definition"=>"definition_with_return", "siringa_args"=>{"name"=>"Ned"}}
|
788
|
+
[1m[35m (0.1ms)[0m SAVEPOINT active_record_1
|
789
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "users" DEFAULT VALUES[0m
|
790
|
+
[1m[35m (0.0ms)[0m RELEASE SAVEPOINT active_record_1
|
791
|
+
Completed 201 Created in 2ms (Views: 0.2ms | ActiveRecord: 0.3ms)
|
792
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|