elabs_matchers 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/.gitignore +2 -1
  2. data/Gemfile.lock +37 -26
  3. data/README.md +57 -47
  4. data/development.txt +26 -0
  5. data/doc/ElabsMatchers/Helpers/Fixtures.html +33 -23
  6. data/doc/ElabsMatchers/Helpers/NormalizeKeys.html +222 -0
  7. data/doc/ElabsMatchers/Helpers/ReloadRecord.html +302 -0
  8. data/doc/ElabsMatchers/Helpers/SelectYearAndMonth.html +251 -0
  9. data/doc/ElabsMatchers/Helpers.html +29 -22
  10. data/doc/ElabsMatchers/Matchers/Allow/AllowMatcher.html +707 -0
  11. data/doc/ElabsMatchers/Matchers/Allow.html +229 -0
  12. data/doc/ElabsMatchers/Matchers/ContainHash/ContainHashMatcher.html +506 -0
  13. data/doc/ElabsMatchers/Matchers/ContainHash.html +222 -0
  14. data/doc/ElabsMatchers/Matchers/HaveAttribute/HaveAttributeMatcher.html +656 -0
  15. data/doc/ElabsMatchers/Matchers/HaveAttribute.html +239 -0
  16. data/doc/ElabsMatchers/Matchers/HaveFields/HaveFieldsMatcher.html +572 -0
  17. data/doc/ElabsMatchers/Matchers/HaveFields.html +220 -0
  18. data/doc/ElabsMatchers/Matchers/HaveFlash/HaveFlashMatcher.html +654 -0
  19. data/doc/ElabsMatchers/Matchers/HaveFlash.html +306 -0
  20. data/doc/ElabsMatchers/Matchers/HaveFormErrorsOn/HaveFormErrorsOnMatcher.html +678 -0
  21. data/doc/ElabsMatchers/Matchers/HaveFormErrorsOn.html +236 -0
  22. data/doc/ElabsMatchers/Matchers/HaveHeader/HaveHeaderMatcher.html +568 -0
  23. data/doc/ElabsMatchers/Matchers/HaveHeader.html +219 -0
  24. data/doc/ElabsMatchers/Matchers/HaveImage/HaveImageMatcher.html +592 -0
  25. data/doc/ElabsMatchers/Matchers/HaveImage.html +219 -0
  26. data/doc/ElabsMatchers/Matchers/HaveTableRow/HaveTableRowMatcher.html +654 -0
  27. data/doc/ElabsMatchers/Matchers/HaveTableRow.html +236 -0
  28. data/doc/ElabsMatchers/Matchers/OnlyInclude/OnlyIncludeMatcher.html +494 -0
  29. data/doc/ElabsMatchers/Matchers/OnlyInclude.html +221 -0
  30. data/doc/ElabsMatchers/Matchers/Persist/PersistMatcher.html +586 -0
  31. data/doc/ElabsMatchers/Matchers/Persist.html +235 -0
  32. data/doc/ElabsMatchers/Matchers.html +29 -22
  33. data/doc/ElabsMatchers.html +1144 -21
  34. data/doc/_index.html +161 -79
  35. data/doc/class_list.html +12 -6
  36. data/doc/css/full_list.css +4 -2
  37. data/doc/css/style.css +50 -44
  38. data/doc/file.README.html +71 -73
  39. data/doc/file_list.html +12 -6
  40. data/doc/frames.html +20 -5
  41. data/doc/index.html +71 -73
  42. data/doc/js/app.js +52 -43
  43. data/doc/js/full_list.js +9 -9
  44. data/doc/js/jquery.js +4 -16
  45. data/doc/method_list.html +603 -77
  46. data/doc/top-level-namespace.html +24 -103
  47. data/elabs_matchers.gemspec +4 -3
  48. data/history.txt +15 -0
  49. data/lib/elabs_matchers/extensions/module.rb +24 -0
  50. data/lib/elabs_matchers/helpers/fixtures.rb +2 -2
  51. data/lib/elabs_matchers/helpers/{common.rb → normalize_keys.rb} +3 -4
  52. data/lib/elabs_matchers/helpers/{orm.rb → reload_record.rb} +9 -6
  53. data/lib/elabs_matchers/helpers/{capybara.rb → select_year_and_month.rb} +5 -3
  54. data/lib/elabs_matchers/matchers/allow.rb +130 -0
  55. data/lib/elabs_matchers/matchers/contain_hash.rb +58 -0
  56. data/lib/elabs_matchers/matchers/have_attribute.rb +62 -0
  57. data/lib/elabs_matchers/matchers/have_fields.rb +45 -0
  58. data/lib/elabs_matchers/matchers/have_flash.rb +65 -0
  59. data/lib/elabs_matchers/matchers/have_form_errors_on.rb +79 -0
  60. data/lib/elabs_matchers/matchers/have_header.rb +53 -0
  61. data/lib/elabs_matchers/matchers/have_image.rb +69 -0
  62. data/lib/elabs_matchers/matchers/have_table_row.rb +113 -0
  63. data/lib/elabs_matchers/matchers/only_include.rb +41 -0
  64. data/lib/elabs_matchers/matchers/persist.rb +42 -0
  65. data/lib/elabs_matchers/version.rb +1 -1
  66. data/lib/elabs_matchers.rb +90 -10
  67. data/spec/elabs_matchers/helpers/fixtures_spec.rb +1 -1
  68. data/spec/elabs_matchers/helpers/{common_spec.rb → normalize_keys_spec.rb} +2 -2
  69. data/spec/elabs_matchers/helpers/{orm_spec.rb → reload_record_spec.rb} +3 -2
  70. data/spec/elabs_matchers/helpers/select_year_and_month_spec.rb +32 -0
  71. data/spec/elabs_matchers/matchers/{rspec/allow_spec.rb → allow_spec.rb} +5 -4
  72. data/spec/elabs_matchers/matchers/contain_hash_spec.rb +86 -0
  73. data/spec/elabs_matchers/matchers/have_attribute_spec.rb +65 -0
  74. data/spec/elabs_matchers/matchers/have_fields_spec.rb +46 -0
  75. data/spec/elabs_matchers/matchers/have_flash_spec.rb +97 -0
  76. data/spec/elabs_matchers/matchers/have_form_errors_on_spec.rb +93 -0
  77. data/spec/elabs_matchers/matchers/have_header_spec.rb +54 -0
  78. data/spec/elabs_matchers/matchers/have_image_spec.rb +49 -0
  79. data/spec/elabs_matchers/matchers/have_table_row_spec.rb +119 -0
  80. data/spec/elabs_matchers/matchers/only_include_spec.rb +32 -0
  81. data/spec/elabs_matchers/matchers/persist_spec.rb +21 -0
  82. data/{lib/elabs_matchers/orm → spec/fixtures}/post.rb +0 -0
  83. data/spec/spec_helper.rb +19 -8
  84. data/todo.txt +6 -0
  85. metadata +104 -48
  86. data/lib/elabs_matchers/cucumber/common.rb +0 -57
  87. data/lib/elabs_matchers/helpers/session.rb +0 -81
  88. data/lib/elabs_matchers/matchers/capybara/common.rb +0 -245
  89. data/lib/elabs_matchers/matchers/rspec/allow.rb +0 -112
  90. data/lib/elabs_matchers/matchers/rspec/common.rb +0 -59
  91. data/lib/elabs_matchers/matchers/rspec/orm.rb +0 -29
  92. data/spec/elabs_matchers/cucumber/common_spec.rb +0 -49
  93. data/spec/elabs_matchers/helpers/capybara_spec.rb +0 -32
  94. data/spec/elabs_matchers/helpers/session_spec.rb +0 -35
  95. data/spec/elabs_matchers/matchers/capybara/common_spec.rb +0 -202
  96. data/spec/elabs_matchers/matchers/rspec/common_spec.rb +0 -74
  97. data/spec/elabs_matchers/matchers/rspec/orm_spec.rb +0 -16
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ElabsMatchers::Cucumber::Common do
4
- describe "LIST_SEPARATOR" do
5
- it "matches ," do
6
- ", ".should =~ Cucumber::LIST_SEPARATOR
7
- end
8
-
9
- it "matches and" do
10
- " and ".should =~ Cucumber::LIST_SEPARATOR
11
- end
12
-
13
- it "doesn't matches other things" do
14
- "foo".should_not =~ Cucumber::LIST_SEPARATOR
15
- end
16
- end
17
-
18
- describe "LIST_REGEXP" do
19
- it "matches just one item" do
20
- %Q{"Bart"}.should =~ Cucumber::LIST_REGEXP
21
- end
22
-
23
- it "matches a comma seperated list" do
24
- %Q{"Bart", "Lisa"}.should =~ Cucumber::LIST_REGEXP
25
- end
26
-
27
- it "matches a 'and' seperated list" do
28
- %Q{"Bart" and "Lisa"}.should =~ Cucumber::LIST_REGEXP
29
- end
30
-
31
- it "matches a comma and 'and' seperated list" do
32
- %Q{"Bart", "Lisa" and "Homer"}.should =~ Cucumber::LIST_REGEXP
33
- end
34
-
35
- it "matches a comma and 'and' seperated list with several words" do
36
- %Q{"Bart Simpsons", "Lisa Simpsons" and "Homer Simpsons"}.should =~ Cucumber::LIST_REGEXP
37
- end
38
-
39
- it "doesn't matches other things" do
40
- %Q{foo}.should_not =~ Cucumber::LIST_REGEXP
41
- end
42
- end
43
-
44
- describe "#human_list_to_array" do
45
- it "converts a LIST_REGEXP-list to an array" do
46
- human_list_to_array(%Q{"Bart", "Lisa" and "Homer"}).should == %w[Bart Lisa Homer]
47
- end
48
- end
49
- end
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ElabsMatchers::Helpers::Capybara do
4
- let(:page) { Capybara::Session.new(:rack_test, proc { |env| [200, {}, [html]]}) }
5
- let(:html) do
6
- %Q{
7
- <label for="post_date_1i">Date</label>
8
- <select id="post_date_1i" name="post[date(1i)]">
9
- <option value='2009' selected='selected'>2009</option>
10
- <option value='2010'>2010</option>
11
- </select>
12
- <select id="post_date_2i" name="post[date(2i)]">
13
- <option value='1' selected='selected'>January</option>
14
- <option value='2'>February</option>
15
- </select>
16
- }
17
- end
18
-
19
- before do
20
- page.extend(ElabsMatchers::Helpers::Capybara)
21
- page.visit "/"
22
- end
23
-
24
- describe "#select_year_and_month" do
25
- it "selects the year and momth selects" do
26
- page.select_year_and_month('2010', 'February', :from => "Date")
27
-
28
- page.find("#post_date_1i").find('option[selected]').text.should == "2010"
29
- page.find("#post_date_2i").find('option[selected]').text.should == "February"
30
- end
31
- end
32
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ElabsMatchers::Helpers::Session do
4
- let(:user) { "I'm a user record" }
5
-
6
- describe "#sign_in_as" do
7
- it "set $signed_in to true" do
8
- sign_in_as
9
- $signed_in.should be_true
10
- end
11
-
12
- it "uses sign_in as an alias" do
13
- sign_in
14
- $signed_in.should be_true
15
- end
16
-
17
- it "set current user to the given argument if any" do
18
- sign_in_as(user)
19
- current_user.should == user
20
- end
21
-
22
- it "set's the current user to nil if none given" do
23
- sign_in_as
24
- current_user.should be_nil
25
- end
26
- end
27
-
28
- describe "#sign_out" do
29
- it "sets $signed_in to nil" do
30
- sign_in
31
- sign_out
32
- $signed_in.should be_false
33
- end
34
- end
35
- end
@@ -1,202 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ElabsMatchers::Matchers::Capybara::Common do
4
- describe "#have_options" do
5
- let(:html) { Capybara.string("<select><option value='1'>A</option><option value='2'>B</option></select>") }
6
-
7
- it "returns true if the select tag have the requested option tags" do
8
- html.should have_options("A", "B")
9
- end
10
-
11
- it "returns true if given some of the options" do
12
- html.should have_options("B")
13
- end
14
-
15
- it "returns false if the select tag does not have the requested option tags" do
16
- html.should_not have_options("A", "C")
17
- end
18
- end
19
-
20
- describe "#have_table_row" do
21
- let(:html) do
22
- Capybara.string(%Q{
23
- <table>
24
- <caption>Posts</caption>
25
- <thead>
26
- <tr><th>Title</th><th>Author</th></tr>
27
- </thead>
28
- <tbody>
29
- <tr><td>First</td><td>Adam</td></tr>
30
- <tr><td>Second</td><td>David</td></tr>
31
- </tbody>
32
- </table>
33
- })
34
- end
35
-
36
- it "returns true when the one of the pairs in the row exists" do
37
- html.should have_table_row("Posts", "Title" => "First")
38
- end
39
-
40
- it "returns true when the all of the pairs in the row exists" do
41
- html.should have_table_row("Posts", "Title" => "First", "Author" => "Adam")
42
- end
43
-
44
- it "returns false when the header is wrong and the value is correct" do
45
- html.should_not have_table_row("Posts", "Label" => "First")
46
- end
47
-
48
- it "returns false when the header is correct and the value is wrong" do
49
- html.should_not have_table_row("Posts", "Title" => "Third")
50
- end
51
-
52
- it "returns false when on of the pairs is wrong" do
53
- html.should_not have_table_row("Posts", "Title" => "First", "Author" => "David")
54
- end
55
-
56
- it "returns false when given the value of another column" do
57
- html.should_not have_table_row("Posts", "Title" => "Adam")
58
- end
59
- end
60
-
61
- describe "#have_attribute" do
62
- let(:html) do
63
- Capybara.string(%Q{<div class="show_for post" id="post_1">
64
- <p class="wrapper post_status"><strong class="label">Title</strong><br />First</p>
65
- <p class="wrapper post_status"><strong class="label">Author</strong><br />Adam</p>
66
- </div>})
67
- end
68
-
69
- it "returns true when the label exists with the supplied value" do
70
- html.should have_attribute("Title", "First")
71
- end
72
-
73
- it "returns false when the label exists with but the value is wrong" do
74
- html.should_not have_attribute("Title", "Wrong")
75
- end
76
-
77
- it "returns false when the label does not exist even if the value does" do
78
- html.should_not have_attribute("Wrong", "First")
79
- end
80
- end
81
-
82
- describe "#have_image" do
83
- let(:html) { Capybara.string(%Q{<div><img src="logo.png" alt="Logo" /></div>}) }
84
-
85
- it "returns true if the image exists on the page" do
86
- html.should have_image("Logo")
87
- end
88
-
89
- it "returns false if the image doesn't exist on the page" do
90
- html.should_not have_image("Avatar")
91
- end
92
- end
93
-
94
- describe "#have_header" do
95
- let(:html) { Capybara.string(%Q{<div><h1>Elabs</h1><h2>Bespoke</h2><h3>Development</h3></div>}) }
96
-
97
- it "returns true if given the content of a h1 tag" do
98
- html.should have_header("Elabs")
99
- end
100
-
101
- it "returns true if given the content of a h2 tag" do
102
- html.should have_header("Bespoke")
103
- end
104
-
105
- it "returns false if given the content of a h3 tag" do
106
- html.should_not have_header("Development")
107
- end
108
-
109
- it "returns false if the content doesn't exist on the page" do
110
- html.should_not have_header("Bugs")
111
- end
112
- end
113
-
114
- describe "#have_flash_notice" do
115
- let(:html) { Capybara.string(%Q{<div id="flash" class="notice">Success</div><h1>Elabs</h1>}) }
116
-
117
- it "returns true if given the content of the flash notice" do
118
- html.should have_flash_notice("Success")
119
- end
120
-
121
- it "returns false if given content outside the flash notice" do
122
- html.should_not have_flash_notice("Elabs")
123
- end
124
-
125
- it "returns false if the content doesn't exist on the page" do
126
- html.should_not have_flash_notice("Failure")
127
- end
128
- end
129
-
130
- describe "#have_flash_alert" do
131
- let(:html) { Capybara.string(%Q{<div id="flash" class="alert">Error</div><h1>Elabs</h1>}) }
132
-
133
- it "returns true if given the content of the flash alert" do
134
- html.should have_flash_alert("Error")
135
- end
136
-
137
- it "returns false if given content outside the flash alert" do
138
- html.should_not have_flash_alert("Elabs")
139
- end
140
-
141
- it "returns false if the content doesn't exist on the page" do
142
- html.should_not have_flash_alert("Success")
143
- end
144
- end
145
-
146
- describe "#have_form_errors_on" do
147
- let(:html) do
148
- Capybara.string(%Q{
149
- <form>
150
- <span class="error">Can't be blank</span>
151
- <label for="name">Name</label>
152
- <input type="text" name="name" id="name" value="" />
153
- </form>
154
- })
155
- end
156
-
157
- it "returns true if the label and the error message is correct" do
158
- html.should have_form_errors_on("Name", "Can't be blank")
159
- end
160
-
161
- it "returns false if the label is correct by the error message is wrong" do
162
- html.should_not have_form_errors_on("Name", "Not good enough")
163
- end
164
-
165
- it "returns false if the label is wrong by the error message is correct" do
166
- html.should_not have_form_errors_on("Author", "Can't be blank")
167
- end
168
- end
169
-
170
- describe "#have_fields" do
171
- let(:html) do
172
- Capybara.string(%Q{
173
- <form>
174
- <label for="author">Author</label>
175
- <input type="text" name="author" id="author" value="Adam" />
176
- <label for="year">Year</label>
177
- <input type="text" name="year" id="year" value="2011" />
178
- </form>
179
- })
180
- end
181
-
182
- it "returns true with several fields if both labels and values are correct" do
183
- html.should have_fields("Author" => "Adam", "Year" => "2011")
184
- end
185
-
186
- it "returns true with one field if both labels and values are correct" do
187
- html.should have_fields("Year" => "2011")
188
- end
189
-
190
- it "returns false if the label is correct but the value is not" do
191
- html.should_not have_fields("Author" => "David")
192
- end
193
-
194
- it "returns false if the label is correct but the value is not" do
195
- html.should_not have_fields("Wrong" => "Adam")
196
- end
197
-
198
- it "returns false if the one of the pairs is incorrect" do
199
- html.should_not have_fields("Author" => "Adam", "Year" => "2012")
200
- end
201
- end
202
- end
@@ -1,74 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ElabsMatchers::Matchers::Rspec::Common do
4
- describe '#contain_hash' do
5
- context "with a simple hash" do
6
- it "returns true with the given value" do
7
- { "foo" => "bar", "baz" => "quox" }.should contain_hash({ "foo" => "bar" })
8
- { "foo" => "bar", "baz" => "quox" }.should contain_hash({ "baz" => "quox" })
9
- end
10
-
11
- it "returns false if key or value don't match" do
12
- { "foo" => "bar", "baz" => "quox" }.should_not contain_hash({ "foo" => "quox" })
13
- { "foo" => "bar", "baz" => "quox" }.should_not contain_hash({ "baz" => "bar" })
14
- end
15
- end
16
-
17
- context "with a simple array" do
18
- it "returns true with the given value" do
19
- [ "foo", "quox" ].should contain_hash(["foo"])
20
- [ "foo", "quox" ].should contain_hash(["quox"])
21
- [ "foo", "quox" ].should contain_hash(["foo", "quox"])
22
- end
23
-
24
- it "returns false if the array doesn't contain the given value" do
25
- [ "foo", "baz" ].should_not contain_hash(["blah"])
26
- end
27
- end
28
-
29
- context "with a nested hash" do
30
- it "returns true with the given value" do
31
- { "foo" => { "foo1" => "bar1", "foo2" => "bar2" }}.should contain_hash({ "foo" => { "foo1" => "bar1" }})
32
- { "foo" => { "foo1" => "bar1", "foo2" => "bar2" }}.should contain_hash({ "foo" => { "foo2" => "bar2" }})
33
- end
34
-
35
- it "returns false if key or value don't match" do
36
- { "foo" => { "foo1" => "bar1", "foo2" => "bar2" }}.should_not contain_hash({ "foo" => { "foo1" => "bar2" }})
37
- { "foo" => { "foo1" => "bar1", "foo2" => "bar2" }}.should_not contain_hash({ "foo" => { "foo2" => "bar1" }})
38
- { "foo" => { "foo1" => "bar1", "foo2" => "bar2" }}.should_not contain_hash({ "foo" => { "monkey" => "baz" }})
39
- { "foo" => { "foo1" => "bar1", "foo2" => "bar2" }}.should_not contain_hash({ "foo" => "monkey" })
40
- end
41
- end
42
-
43
- context "with a nested array" do
44
- it "returns true with the given value" do
45
- { "foo" => ['quox', { 'bar' => 'baz'}]}.should contain_hash({ "foo" => [{ "bar" => "baz" }]})
46
- { "foo" => ['quox', { 'bar' => 'baz'}]}.should contain_hash({ "foo" => ["quox"]})
47
- end
48
-
49
- it "returns false if array doesn't contain the given sequence" do
50
- { "foo" => ['quox', { 'bar' => 'baz'}]}.should_not contain_hash({ "foo" => [{ "bar" => "quox" }]})
51
- { "foo" => ['quox', { 'bar' => 'baz'}]}.should_not contain_hash({ "foo" => ["bar"]})
52
- { "foo" => ['quox', { 'bar' => 'baz'}]}.should_not contain_hash({ "foo" => "monkey"})
53
- end
54
- end
55
- end
56
-
57
- describe "#only_include" do
58
- it "returns true when all the elements are passed in the wrong order" do
59
- %w[foo bar].should only_include("bar", "foo")
60
- end
61
-
62
- it "returns true when all the elements are passed in the correct order" do
63
- %w[foo bar].should only_include("foo", "bar")
64
- end
65
-
66
- it "returns false when one or more element is missing" do
67
- %w[foo bar].should_not only_include("foo")
68
- end
69
-
70
- it "returns false when one of the element is not in the list" do
71
- %w[foo bar].should_not only_include("foo", "bar", "baz")
72
- end
73
- end
74
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ElabsMatchers::Matchers::Rspec::Orm do
4
- let(:post) { ElabsMatchers::Orm::Post.create(:title => "New", :body => "Lorem") }
5
-
6
- describe "#persist" do
7
- it "returns true if the value is the supplied" do
8
- post.should persist(:title, "Updated")
9
- end
10
-
11
- it "returns false if the value isn't the supplied" do
12
- post.stub(:title).and_return("New")
13
- post.should_not persist(:title, "Updated")
14
- end
15
- end
16
- end