Created
February 26, 2010 19:04
-
-
Save rcarver/316032 to your computer and use it in GitHub Desktop.
Sample cucumber support for Vanity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scenario: Choose a free plan, then create an account | |
When I go to the homepage | |
And I follow "Register" | |
Then I should see "Find the plan that's right for you" | |
When I follow "signup-trial" | |
Then I fill in "First Name" with "Joe" | |
And I fill in "Last Name" with "Johnson" | |
And I fill in "Email" with "[email protected]" | |
And I fill in "Password" with "test" | |
And I fill in "user[password_confirmation]" with "test" | |
And I check "I agree" | |
And I press "Create my account" | |
Then I should see "Thanks for signing up!" | |
And only these metrics were recorded: | |
| 1 | accounts created | | |
| 1 | subscriptions activated | | |
| 1 | trial subscriptions activated | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Then /^(only )?these metrics were recorded:$/ do |only, table| | |
expected_metrics = {} | |
if only | |
# Expect 0 on all unnamed metrics | |
Vanity.playground.metrics.keys.each do |metric_id| | |
expected_metrics[metric_id] = 0 | |
end | |
end | |
# Map given names to metric names and their expected value. | |
table.raw.each do |(value, metric_name)| | |
metric_id = metric_name.gsub(/\s+/, '_').to_sym | |
Vanity.playground.metric(metric_id) # ensure the metric name is valid | |
expected_metrics[metric_id] = value.to_i | |
end | |
# Check all expectations. | |
expected_metrics.each do |metric_id, expected_value| | |
actual = Vanity::Aggregation.new(metric_id).sum | |
unless actual == expected_value | |
raise Spec::Expectations::ExpectationNotMetError, "Expected #{metric_id} to be #{expected_value}, but was #{actual}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment