Skip to content

Commit

Permalink
add some test for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
moofkit committed Oct 29, 2018
1 parent 8310ee2 commit 9674fb4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
16 changes: 9 additions & 7 deletions lib/logux/class_finder.rb
Expand Up @@ -16,8 +16,8 @@ def find_action_class
Unable to find action #{class_name.camelize}
Should be in app/logux/#{class_namespace.downcase}/#{class_path}.rb
)
raise Logux::UnknownChannelError.new(message, meta: meta) if subscribe?
raise Logux::UnknownActionError.new(message, meta: meta)
raise Logux::UnknownActionError.new(message, meta: meta) if action?
raise Logux::UnknownChannelError.new(message, meta: meta)
end

def find_policy_class
Expand All @@ -29,11 +29,6 @@ def find_policy_class
), meta: meta)
end

def class_namespace
return 'Channels' if subscribe?
'Actions'
end

def class_name
if subscribe?
action.channel_name.camelize
Expand All @@ -42,6 +37,13 @@ def class_name
end
end

private

def class_namespace
return 'Channels' if subscribe?
'Actions'
end

def subscribe?
action.type == 'logux/subscribe'
end
Expand Down
12 changes: 11 additions & 1 deletion spec/logux/class_finder_spec.rb
Expand Up @@ -21,8 +21,18 @@

let(:action) { create(:logux_actions_add, type: 'test/test/name/try/user/add') }

it 'raise an error' do
it 'raise an error for unknown policy' do
expect { policy_class }.to raise_error(Logux::UnknownPolicyError)
end
end

describe '#find_action_class' do
subject(:action_class) { finder.find_action_class }

let(:action) { create(:logux_actions_add, type: 'test/test/name/try/user/add') }

it 'raise an error for unknown action' do
expect { action_class }.to raise_error(Logux::UnknownActionError)
end
end
end

0 comments on commit 9674fb4

Please sign in to comment.