bond-spy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.yardopts +1 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +27 -0
  7. data/README.rst +65 -0
  8. data/Rakefile +6 -0
  9. data/bin/bond_reconcile.py +385 -0
  10. data/bin/setup +5 -0
  11. data/bond.gemspec +36 -0
  12. data/lib/bond.rb +469 -0
  13. data/lib/bond/spec_helper.rb +32 -0
  14. data/lib/bond/targetable.rb +210 -0
  15. data/lib/bond/version.rb +3 -0
  16. data/spec/bond_spec.rb +158 -0
  17. data/spec/bond_targetable_spec.rb +202 -0
  18. data/spec/spec_helper.rb +2 -0
  19. data/spec/test_observations/.gitignore +2 -0
  20. data/spec/test_observations/bond_spec/Bond_with_agents_should_call_doers_before_returning_result.json +14 -0
  21. data/spec/test_observations/bond_spec/Bond_with_agents_should_call_the_function_passed_as_result_if_it_is_callable.json +23 -0
  22. data/spec/test_observations/bond_spec/Bond_with_agents_should_correctly_call_a_single_doer_if_filter_criteria_are_met.json +10 -0
  23. data/spec/test_observations/bond_spec/Bond_with_agents_should_correctly_call_multiple_doers.json +13 -0
  24. data/spec/test_observations/bond_spec/Bond_with_agents_should_not_call_doers_of_overriden_agents.json +8 -0
  25. data/spec/test_observations/bond_spec/Bond_with_agents_should_override_old_agents_with_newer_agents.json +0 -0
  26. data/spec/test_observations/bond_spec/Bond_with_agents_should_throw_an_exception_if_specified_by_agent.json +9 -0
  27. data/spec/test_observations/bond_spec/Bond_with_agents_should_throw_the_result_of_the_value_passed_to_exception_if_callable.json +10 -0
  28. data/spec/test_observations/bond_spec/Bond_with_agents_should_work_with_multiple_agents_for_different_spy_points.json +23 -0
  29. data/spec/test_observations/bond_spec/Bond_with_agents_with_filters_should_override_old_agents_with_newer_agents_unless_theott8glo1xn.json +22 -0
  30. data/spec/test_observations/bond_spec/Bond_with_agents_with_filters_should_respect_combinations_of_filters.json +37 -0
  31. data/spec/test_observations/bond_spec/Bond_with_agents_with_filters_should_respect_function_filters.json +16 -0
  32. data/spec/test_observations/bond_spec/Bond_with_agents_with_filters_should_respect_single_key_value_filters_of_all_types.json +121 -0
  33. data/spec/test_observations/bond_spec/Bond_without_any_agents_should_correctly_log_nested_hashes_and_arrays_with_hash_sorting.json +31 -0
  34. data/spec/test_observations/bond_spec/Bond_without_any_agents_should_correctly_log_some_normal_arguments_with_a_spy_point_name.json +12 -0
  35. data/spec/test_observations/bond_spec/Bond_without_any_agents_should_correctly_log_some_normal_arguments_without_a_spy_point_name.json +10 -0
  36. data/spec/test_observations/bond_targetable_spec/BondTargetable_correctly_continues_to_the_method_when_agent_result_continue_is_returned.json +10 -0
  37. data/spec/test_observations/bond_targetable_spec/BondTargetable_correctly_continues_to_the_method_when_agent_result_none_is_returned.json +14 -0
  38. data/spec/test_observations/bond_targetable_spec/BondTargetable_correctly_passes_through_blocks.json +10 -0
  39. data/spec/test_observations/bond_targetable_spec/BondTargetable_correctly_returns_nil__and_mocks__when_an_agent_returns_nil.json +11 -0
  40. data/spec/test_observations/bond_targetable_spec/BondTargetable_correctly_spies_private_methods.json +6 -0
  41. data/spec/test_observations/bond_targetable_spec/BondTargetable_correctly_spies_protected_methods.json +6 -0
  42. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_argument_types_correctly_spies_on_a_class_method.json +7 -0
  43. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_argument_types_correctly_spies_on_a_method_with_variabl19nhijeqoo.json +13 -0
  44. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_argument_types_correctly_spies_on_a_mix_of_positional_a6qc3d4el92.json +33 -0
  45. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_argument_types_correctly_spies_on_a_mix_of_positional_aott8glo1xn.json +20 -0
  46. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_argument_types_correctly_spies_on_a_mix_of_required_andbcgjq06had.json +17 -0
  47. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_argument_types_correctly_spies_on_a_normal_method.json +7 -0
  48. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_argument_types_correctly_spies_on_all_optional_keyword_arguments.json +10 -0
  49. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_argument_types_correctly_spies_on_variable_keyword_arguments.json +22 -0
  50. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_spy_point_parameters_correctly_changes_the_spy_point_naj4gnwvcu8n.json +5 -0
  51. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_spy_point_parameters_correctly_errors_when_mocking_is_r9j7wklng0z.json +6 -0
  52. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_spy_point_parameters_correctly_ignores_excluded_keys.json +10 -0
  53. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_spy_point_parameters_correctly_mocks_when_one_is_specified.json +10 -0
  54. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_spy_point_parameters_correctly_spies_the_return_value_w19nhijeqoo.json +10 -0
  55. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_different_spy_point_parameters_correctly_spies_the_return_value_ww8esw1qdxc.json +10 -0
  56. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_modules_correctly_spies_on_included_module_methods.json +6 -0
  57. data/spec/test_observations/bond_targetable_spec/BondTargetable_with_modules_correctly_spies_on_module_methods.json +7 -0
  58. data/tutorials/binary_search_tree/bst.rb +120 -0
  59. data/tutorials/binary_search_tree/bst_spec.rb +82 -0
  60. data/tutorials/binary_search_tree/run_tests.sh +4 -0
  61. data/tutorials/binary_search_tree/test_observations/.gitignore +2 -0
  62. data/tutorials/binary_search_tree/test_observations/bst_spec/Node_should_add_nodes_to_the_BST_correctly__testing_with_Bond.json +20 -0
  63. data/tutorials/binary_search_tree/test_observations/bst_spec/Node_should_add_nodes_to_the_BST_correctly__testing_without_Bond.json +3 -0
  64. data/tutorials/binary_search_tree/test_observations/bst_spec/Node_should_correctly_delete_nodes_from_the_BST.json +29 -0
  65. data/tutorials/heat_watcher/heat_watcher.rb +107 -0
  66. data/tutorials/heat_watcher/heat_watcher_spec.rb +116 -0
  67. data/tutorials/heat_watcher/run_tests.sh +4 -0
  68. data/tutorials/heat_watcher/test_observations/.gitignore +2 -0
  69. data/tutorials/heat_watcher/test_observations/heat_watcher_spec/HeatWatcher_should_properly_report_critical_errors.json +142 -0
  70. data/tutorials/heat_watcher/test_observations/heat_watcher_spec/HeatWatcher_should_properly_report_warnings_and_switch_back_to_OK_status.json +132 -0
  71. metadata +211 -0
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'bond/spec_helper'
@@ -0,0 +1,2 @@
1
+ *_now.json
2
+ *.diff
@@ -0,0 +1,14 @@
1
+ [
2
+ {
3
+ "__spy_point__": "internal_doer"
4
+ },
5
+ {
6
+ "__spy_point__": "internal_result"
7
+ },
8
+ {
9
+ "__spy_point__": "my_point"
10
+ },
11
+ {
12
+ "result": "mocked"
13
+ }
14
+ ]
@@ -0,0 +1,23 @@
1
+ [
2
+ {
3
+ "__spy_point__": "my_point",
4
+ "obs_name": "foo"
5
+ },
6
+ {
7
+ "result": 2
8
+ },
9
+ {
10
+ "__spy_point__": "my_point",
11
+ "obs_name": "bar"
12
+ },
13
+ {
14
+ "result": "agent_result_none"
15
+ },
16
+ {
17
+ "__spy_point__": "my_point",
18
+ "obs_name": "foo"
19
+ },
20
+ {
21
+ "result": 3
22
+ }
23
+ ]
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "__spy_point__": "internal",
4
+ "val": "value"
5
+ },
6
+ {
7
+ "__spy_point__": "my_point",
8
+ "my_key": "value"
9
+ }
10
+ ]
@@ -0,0 +1,13 @@
1
+ [
2
+ {
3
+ "__spy_point__": "internal",
4
+ "val": 10
5
+ },
6
+ {
7
+ "__spy_point__": "my_point",
8
+ "my_key": 10
9
+ },
10
+ {
11
+ "side_effect_value": 10
12
+ }
13
+ ]
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ "__spy_point__": "valid_agent"
4
+ },
5
+ {
6
+ "__spy_point__": "my_point"
7
+ }
8
+ ]
@@ -0,0 +1,9 @@
1
+ [
2
+ {
3
+ "__spy_point__": "my_point"
4
+ },
5
+ {
6
+ "__spy_point__": "rescue_point",
7
+ "except": "TypeError exception!"
8
+ }
9
+ ]
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "__spy_point__": "my_point",
4
+ "key": "Value passed to exception"
5
+ },
6
+ {
7
+ "__spy_point__": "rescue_point",
8
+ "except": "Value passed to exception"
9
+ }
10
+ ]
@@ -0,0 +1,23 @@
1
+ [
2
+ {
3
+ "__spy_point__": "my_point_1"
4
+ },
5
+ {
6
+ "__spy_point__": "point_1_return",
7
+ "return_value": "mock result"
8
+ },
9
+ {
10
+ "__spy_point__": "my_point_2"
11
+ },
12
+ {
13
+ "__spy_point__": "point_2_return",
14
+ "return_value": "mock result 2"
15
+ },
16
+ {
17
+ "__spy_point__": "my_point_1"
18
+ },
19
+ {
20
+ "__spy_point__": "point_1_return_2",
21
+ "return_value": "mock result"
22
+ }
23
+ ]
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "__spy_point__": "my_point"
4
+ },
5
+ {
6
+ "result": "second mock"
7
+ },
8
+ {
9
+ "__spy_point__": "my_point",
10
+ "obs_name": "foobar"
11
+ },
12
+ {
13
+ "result": "third mock"
14
+ },
15
+ {
16
+ "__spy_point__": "my_point",
17
+ "obs_name": "baz"
18
+ },
19
+ {
20
+ "result": "second mock"
21
+ }
22
+ ]
@@ -0,0 +1,37 @@
1
+ [
2
+ {
3
+ "__spy_point__": "my_point",
4
+ "req_key": "foo",
5
+ "req_key2": "bar",
6
+ "req_key3": "value"
7
+ },
8
+ {
9
+ "result": "agent_result_none"
10
+ },
11
+ {
12
+ "__spy_point__": "my_point",
13
+ "req_key": "foo",
14
+ "req_key2": "value",
15
+ "req_key3": "foovaluebar"
16
+ },
17
+ {
18
+ "result": "mocked"
19
+ },
20
+ {
21
+ "__spy_point__": "my_point",
22
+ "req_key": "foo",
23
+ "req_key2": "value",
24
+ "req_key3": "lacking"
25
+ },
26
+ {
27
+ "result": "agent_result_none"
28
+ },
29
+ {
30
+ "__spy_point__": "my_point",
31
+ "req_key2": "value",
32
+ "req_key3": "value"
33
+ },
34
+ {
35
+ "result": "agent_result_none"
36
+ }
37
+ ]
@@ -0,0 +1,16 @@
1
+ [
2
+ {
3
+ "__spy_point__": "my_point",
4
+ "my_key": 5
5
+ },
6
+ {
7
+ "result": "agent_result_none"
8
+ },
9
+ {
10
+ "__spy_point__": "my_point",
11
+ "my_key": 10
12
+ },
13
+ {
14
+ "result": "mocked"
15
+ }
16
+ ]
@@ -0,0 +1,121 @@
1
+ [
2
+ {
3
+ "__spy_point__": "my_point",
4
+ "obs_name": "value"
5
+ },
6
+ {
7
+ "result": "mocked"
8
+ },
9
+ {
10
+ "__spy_point__": "my_point",
11
+ "obs_name": "not value"
12
+ },
13
+ {
14
+ "result": "agent_result_none"
15
+ },
16
+ {
17
+ "__spy_point__": "my_point_eq",
18
+ "obs_name": "value"
19
+ },
20
+ {
21
+ "result": "mocked"
22
+ },
23
+ {
24
+ "__spy_point__": "my_point_eq",
25
+ "obs_name": "not value"
26
+ },
27
+ {
28
+ "result": "agent_result_none"
29
+ },
30
+ {
31
+ "__spy_point__": "my_point_exact",
32
+ "obs_name": "value"
33
+ },
34
+ {
35
+ "result": "mocked"
36
+ },
37
+ {
38
+ "__spy_point__": "my_point_exact",
39
+ "obs_name": "not value"
40
+ },
41
+ {
42
+ "result": "agent_result_none"
43
+ },
44
+ {
45
+ "__spy_point__": "my_point_startswith",
46
+ "obs_name": "value"
47
+ },
48
+ {
49
+ "result": "mocked"
50
+ },
51
+ {
52
+ "__spy_point__": "my_point_startswith",
53
+ "obs_name": "not value"
54
+ },
55
+ {
56
+ "result": "agent_result_none"
57
+ },
58
+ {
59
+ "__spy_point__": "my_point_startswith",
60
+ "obs_name": "value not"
61
+ },
62
+ {
63
+ "result": "mocked"
64
+ },
65
+ {
66
+ "__spy_point__": "my_point_endswith",
67
+ "obs_name": "value"
68
+ },
69
+ {
70
+ "result": "mocked"
71
+ },
72
+ {
73
+ "__spy_point__": "my_point_endswith",
74
+ "obs_name": "not value"
75
+ },
76
+ {
77
+ "result": "mocked"
78
+ },
79
+ {
80
+ "__spy_point__": "my_point_endswith",
81
+ "obs_name": "value not"
82
+ },
83
+ {
84
+ "result": "agent_result_none"
85
+ },
86
+ {
87
+ "__spy_point__": "my_point_contains",
88
+ "obs_name": "value"
89
+ },
90
+ {
91
+ "result": "mocked"
92
+ },
93
+ {
94
+ "__spy_point__": "my_point_contains",
95
+ "obs_name": "not value"
96
+ },
97
+ {
98
+ "result": "mocked"
99
+ },
100
+ {
101
+ "__spy_point__": "my_point_contains",
102
+ "obs_name": "value not"
103
+ },
104
+ {
105
+ "result": "mocked"
106
+ },
107
+ {
108
+ "__spy_point__": "my_point_contains",
109
+ "obs_name": "not value not"
110
+ },
111
+ {
112
+ "result": "mocked"
113
+ },
114
+ {
115
+ "__spy_point__": "my_point_contains",
116
+ "obs_name": "foobar"
117
+ },
118
+ {
119
+ "result": "agent_result_none"
120
+ }
121
+ ]
@@ -0,0 +1,31 @@
1
+ [
2
+ {
3
+ "key1": {
4
+ "h1key1": [
5
+ "hello",
6
+ "world"
7
+ ],
8
+ "h1key2": "hi"
9
+ },
10
+ "key2": [
11
+ {
12
+ "key1": "baz",
13
+ "key2": "foo",
14
+ "key3": "bar"
15
+ },
16
+ "array3",
17
+ "array2"
18
+ ]
19
+ },
20
+ {
21
+ "__spy_point__": "point_name",
22
+ "key1": "value 1",
23
+ "key3": {
24
+ "key1": "bar",
25
+ "key2": "foo",
26
+ "key3": {
27
+ "hkey": "hello world"
28
+ }
29
+ }
30
+ }
31
+ ]
@@ -0,0 +1,12 @@
1
+ [
2
+ {
3
+ "__spy_point__": "my_point_name",
4
+ "spy_key": 1,
5
+ "spy_key_2": "string value",
6
+ "spy_key_3": 1.4
7
+ },
8
+ {
9
+ "__spy_point__": "second_point",
10
+ "spy_key": "string value 2"
11
+ }
12
+ ]
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "spy_key": 1,
4
+ "spy_key_2": "string value",
5
+ "spy_key_3": 1.4
6
+ },
7
+ {
8
+ "spy_key": "string value 2"
9
+ }
10
+ ]
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "__spy_point__": "mock_required",
4
+ "arg1": "value1"
5
+ },
6
+ {
7
+ "__spy_point__": "return value",
8
+ "ret": "return"
9
+ }
10
+ ]
@@ -0,0 +1,14 @@
1
+ [
2
+ {
3
+ "__spy_point__": "spy_return",
4
+ "arg1": "value"
5
+ },
6
+ {
7
+ "__spy_point__": "spy_return.result",
8
+ "result": "return"
9
+ },
10
+ {
11
+ "__spy_point__": "return value",
12
+ "ret": "return"
13
+ }
14
+ ]
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "__spy_point__": "TestClass#annotated_method_with_block",
4
+ "arg1": "foo"
5
+ },
6
+ {
7
+ "__spy_point__": "return value",
8
+ "ret": "value"
9
+ }
10
+ ]
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "__spy_point__": "TestClass#annotated_method_with_block",
4
+ "arg1": "foo"
5
+ },
6
+ {
7
+ "__spy_point__": "return value",
8
+ "arr_val": 0,
9
+ "ret": null
10
+ }
11
+ ]